Skip to content

Commit 2af9714

Browse files
committed
fix: reloadStyle and missing MBVectorTileDecoder
1 parent 5dbd400 commit 2af9714

File tree

3 files changed

+113
-2
lines changed

3 files changed

+113
-2
lines changed

src/ui-carto/vectortiles/index.android.ts

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { MBVectorTileDecoderOptions, VectorTileDecoderOptions } from '.';
22
import { File } from '@nativescript/core/file-system';
33
import { BaseVectorTileDecoder } from './index.common';
44
import { getFileName, getRelativePathToApp } from '../index.common';
5-
import { DirAssetPackage } from '../utils';
5+
import { DirAssetPackage, nativeVectorToArray } from '../utils';
66
import { profile } from '@nativescript/core';
77

88
export class VectorTileDecoder extends BaseVectorTileDecoder<com.carto.vectortiles.VectorTileDecoder, VectorTileDecoderOptions> {
@@ -55,7 +55,52 @@ export class MBVectorTileDecoder extends BaseVectorTileDecoder<com.carto.vectort
5555
return this.options.style;
5656
}
5757

58+
reloadStyle() {
59+
if (this.native) {
60+
if (this.pack) {
61+
if (this.options.style) {
62+
this.getNative().setCompiledStyleSet(new com.carto.styles.CompiledStyleSet(this.pack, this.options.style));
63+
} else if (this.options.cartoCss) {
64+
this.getNative().setCartoCSSStyleSet(new com.carto.styles.CartoCSSStyleSet(this.options.cartoCss, this.pack));
65+
}
66+
} else if (this.options.cartoCss) {
67+
this.getNative().setCartoCSSStyleSet(new com.carto.styles.CartoCSSStyleSet(this.options.cartoCss));
68+
}
69+
}
70+
}
71+
5872
setStyleParameter(param: string, value: string) {
5973
this.getNative().setStyleParameter(param, value);
6074
}
75+
setCartoCSSStyleSet(cartoCss: string) {
76+
if (this.pack) {
77+
this.getNative().setCartoCSSStyleSet(new com.carto.styles.CartoCSSStyleSet(cartoCss, this.pack));
78+
} else {
79+
this.getNative().setCartoCSSStyleSet(new com.carto.styles.CartoCSSStyleSet(cartoCss));
80+
}
81+
}
82+
setCompiledStyleSet(param0: com.carto.styles.CompiledStyleSet) {
83+
this.getNative().setCompiledStyleSet(param0);
84+
}
85+
getCompiledStyleSet() {
86+
return this.getNative().getCompiledStyleSet();
87+
}
88+
getCartoCSSStyleSet() {
89+
return this.getNative().getCartoCSSStyleSet();
90+
}
91+
getStyleParameter(param0: string) {
92+
return this.getNative().getStyleParameter(param0);
93+
}
94+
getStyleParameters() {
95+
return nativeVectorToArray(this.getNative().getStyleParameters());
96+
}
97+
addFallbackFont(param0: com.carto.core.BinaryData) {
98+
return this.getNative().addFallbackFont(param0);
99+
}
100+
getMinZoom() {
101+
return this.getNative().getMinZoom();
102+
}
103+
getMaxZoom() {
104+
return this.getNative().getMaxZoom();
105+
}
61106
}

src/ui-carto/vectortiles/index.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,27 @@ export class MBVectorTileDecoder extends BaseNative<any, MBVectorTileDecoderOpti
1717
style?: string;
1818
liveReload?: boolean;
1919
constructor(options: MBVectorTileDecoderOptions, native?: any);
20+
reloadStyle();
2021
setStyleParameter(param: string, value: string);
22+
setCartoCSSStyleSet(param0: string): void;
23+
24+
setCompiledStyleSet(param0: any): void;
25+
getCompiledStyleSet(): any;
26+
27+
getCartoCSSStyleSet(): any;
28+
getStyleParameter(param0: string): string;
29+
getStyleParameters(): core.StringVector;
30+
addFallbackFont(param0: core.BinaryData): void;
31+
getMaxZoom(): number;
32+
getMinZoom(): number;
33+
34+
// setFeatureIdOverride(value: boolean);
35+
// isFeatureIdOverride(): boolean;
36+
// setCartoCSSLayerNamesIgnored(ignore: boolean);
37+
// isCartoCSSLayerNamesIgnored(): boolean;
38+
39+
// setLayerNameOverride(name: string);
40+
// getLayerNameOverride(): string;
2141
}
2242

2343
// export interface CartoVectorTileDecoderOptions extends VectorTileDecoderOptions {

src/ui-carto/vectortiles/index.ios.ts

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DirAssetPackage } from '../utils';
1+
import { DirAssetPackage, nativeVectorToArray } from '../utils';
22
import { File } from '@nativescript/core/file-system';
33
import { getFileName, getRelativePathToApp } from '../index.common';
44
import { MBVectorTileDecoderOptions, VectorTileDecoderOptions } from '.';
@@ -56,7 +56,53 @@ export class MBVectorTileDecoder extends BaseVectorTileDecoder<NTMBVectorTileDec
5656
return this.options.style;
5757
}
5858

59+
reloadStyle() {
60+
if (this.native) {
61+
if (this.pack) {
62+
if (this.options.style) {
63+
this.getNative().setCompiledStyleSet(NTCompiledStyleSet.alloc().initWithAssetPackageStyleName(this.pack, this.options.style));
64+
} else if (this.options.cartoCss) {
65+
this.getNative().setCartoCSSStyleSet(NTCartoCSSStyleSet.alloc().initWithCartoCSSAssetPackage(this.options.cartoCss, this.pack));
66+
}
67+
} else if (this.options.cartoCss) {
68+
this.getNative().setCartoCSSStyleSet(NTCartoCSSStyleSet.alloc().initWithCartoCSS(this.options.cartoCss));
69+
}
70+
}
71+
}
72+
5973
setStyleParameter(param: string, value: string) {
6074
this.getNative().setStyleParameterValue(param, value);
6175
}
76+
setCartoCSSStyleSet(cartoCss: string) {
77+
this.options.cartoCss = cartoCss;
78+
if (this.pack) {
79+
this.getNative().setCartoCSSStyleSet(NTCartoCSSStyleSet.alloc().initWithCartoCSSAssetPackage(cartoCss, this.pack));
80+
} else {
81+
this.getNative().setCartoCSSStyleSet(NTCartoCSSStyleSet.alloc().initWithCartoCSS(cartoCss));
82+
}
83+
}
84+
setCompiledStyleSet(param0: NTCompiledStyleSet) {
85+
this.getNative().setCompiledStyleSet(param0);
86+
}
87+
getCompiledStyleSet() {
88+
return this.getNative().getCompiledStyleSet();
89+
}
90+
getCartoCSSStyleSet() {
91+
return this.getNative().getCartoCSSStyleSet();
92+
}
93+
getStyleParameter(param0: string) {
94+
return this.getNative().getStyleParameter(param0);
95+
}
96+
getStyleParameters() {
97+
return nativeVectorToArray(this.getNative().getStyleParameters());
98+
}
99+
addFallbackFont(param0: NTBinaryData) {
100+
return this.getNative().addFallbackFont(param0);
101+
}
102+
getMinZoom() {
103+
return this.getNative().getMinZoom();
104+
}
105+
getMaxZoom() {
106+
return this.getNative().getMaxZoom();
107+
}
62108
}

0 commit comments

Comments
 (0)