UNPKG

@nativescript-community/ui-carto

Version:
114 lines 4.41 kB
import { DirAssetPackage, ZippedAssetPackage, nativeVectorToArray } from '../utils'; import { BaseVectorTileDecoder } from './index.common'; export class VectorTileDecoder extends BaseVectorTileDecoder { createNative(options) { const result = NTVectorTileDecoder.alloc().init(); return result; } } export class MBVectorTileDecoder extends BaseVectorTileDecoder { createNative(options) { let pack; if (options.pack) { pack = this.pack = options.pack.getNative(); } else if (!!options.zipPath) { pack = this.pack = new ZippedAssetPackage(options).getNative(); } else if (!!options.dirPath) { pack = this.pack = new DirAssetPackage({ dirPath: options.dirPath, loadUsingNS: options.liveReload }).getNative(); } if (options.cartoCss) { if (pack) { return NTMBVectorTileDecoder.alloc().initWithCartoCSSStyleSet(NTCartoCSSStyleSet.alloc().initWithCartoCSSAssetPackage(options.cartoCss, pack)); } else { return NTMBVectorTileDecoder.alloc().initWithCartoCSSStyleSet(NTCartoCSSStyleSet.alloc().initWithCartoCSS(options.cartoCss)); } } else if (pack) { const vectorTileStyleSet = NTCompiledStyleSet.alloc().initWithAssetPackageStyleName(pack, options.style); return NTMBVectorTileDecoder.alloc().initWithCompiledStyleSet(vectorTileStyleSet); } else { console.error(`could not create MBVectorTileDecoder pack for options: ${options}`); return null; } } set style(style) { if (style !== this.options.style) { this.options.style = style; if (this.native) { this.getNative().setCompiledStyleSet(NTCompiledStyleSet.alloc().initWithAssetPackageStyleName(this.pack, style)); } } } get style() { return this.options.style; } reloadStyle() { if (this.native) { if (this.pack) { if (this.options.style) { this.getNative().setCompiledStyleSet(NTCompiledStyleSet.alloc().initWithAssetPackageStyleName(this.pack, this.options.style)); } else if (this.options.cartoCss) { this.getNative().setCartoCSSStyleSet(NTCartoCSSStyleSet.alloc().initWithCartoCSSAssetPackage(this.options.cartoCss, this.pack)); } } else if (this.options.cartoCss) { this.getNative().setCartoCSSStyleSet(NTCartoCSSStyleSet.alloc().initWithCartoCSS(this.options.cartoCss)); } } } setStyleParameter(param, value) { this.getNative().setStyleParameterValue(param, value); } setStyleParameters(value) { let map = value; if (!(value instanceof NTStringMap)) { map = NTStringMap.new(); Object.keys(value).forEach((k) => { map.setX(k, value[k]); }); } this.getNative().setStyleParameters(map); } setJSONStyleParameters(value) { this.getNative().setJSONStyleParameters(typeof value === 'string' ? value : JSON.stringify(value)); } setCartoCSSStyleSet(cartoCss) { this.options.cartoCss = cartoCss; if (this.pack) { this.getNative().setCartoCSSStyleSet(NTCartoCSSStyleSet.alloc().initWithCartoCSSAssetPackage(cartoCss, this.pack)); } else { this.getNative().setCartoCSSStyleSet(NTCartoCSSStyleSet.alloc().initWithCartoCSS(cartoCss)); } } setCompiledStyleSet(param0) { this.getNative().setCompiledStyleSet(param0); } getCompiledStyleSet() { return this.getNative().getCompiledStyleSet(); } getCartoCSSStyleSet() { return this.getNative().getCartoCSSStyleSet(); } getStyleParameter(param0) { return this.getNative().getStyleParameter(param0); } getStyleParameters() { return nativeVectorToArray(this.getNative().getStyleParameters()); } addFallbackFont(param0) { return this.getNative().addFallbackFont(param0); } getMinZoom() { return this.getNative().getMinZoom(); } getMaxZoom() { return this.getNative().getMaxZoom(); } } //# sourceMappingURL=index.ios.js.map