Skip to content

Commit a788b25

Browse files
committed
feat: minVisibleZoom/maxVisibleZoom
1 parent a133c79 commit a788b25

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,32 @@ export abstract class Layer<T extends com.carto.layers.Layer, U extends LayerOpt
2727
set visibleZoomRange(value: [number, number]) {
2828
this.native && this.native.setVisibleZoomRange(new com.carto.core.MapRange(value[0], value[1]));
2929
}
30+
get minVisibleZoom() {
31+
if (this.native) {
32+
const zoomRange = this.native.getVisibleZoomRange();
33+
return zoomRange.getMin();
34+
}
35+
return this.options.visibleZoomRange?.[0];
36+
}
37+
set minVisibleZoom(value: number) {
38+
if (this.native) {
39+
const zoomRange = this.native.getVisibleZoomRange();
40+
this.native.setVisibleZoomRange(new com.carto.core.MapRange(value, zoomRange.getMax()));
41+
}
42+
}
43+
get maxVisibleZoom() {
44+
if (this.native) {
45+
const zoomRange = this.native.getVisibleZoomRange();
46+
return zoomRange.getMax();
47+
}
48+
return this.options.visibleZoomRange?.[1];
49+
}
50+
set maxVisibleZoom(value: number) {
51+
if (this.native) {
52+
const zoomRange = this.native.getVisibleZoomRange();
53+
this.native.setVisibleZoomRange(new com.carto.core.MapRange(zoomRange.getMin(), value));
54+
}
55+
}
3056
refresh() {
3157
this.native && this.native.refresh();
3258
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export interface LayerOptions {
77
opacity?: number;
88
visible?: boolean;
99
visibleZoomRange?: [number, number];
10+
minVisibleZoom?: number;
11+
maxVisibleZoom?: number;
1012
}
1113

1214
export class Layer<T, U extends LayerOptions> extends BaseNative<T, U> {
@@ -17,6 +19,8 @@ export class Layer<T, U extends LayerOptions> extends BaseNative<T, U> {
1719
opacity: number;
1820
visible: boolean;
1921
visibleZoomRange: [number, number];
22+
minVisibleZoom?: number;
23+
maxVisibleZoom?: number;
2024
}
2125
export enum TileSubstitutionPolicy {
2226
TILE_SUBSTITUTION_POLICY_ALL,

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,33 @@ export abstract class Layer<T extends NTLayer, U extends LayerOptions> extends B
2020
set visibleZoomRange(value: [number, number]) {
2121
this.native && this.native.setVisibleZoomRange(NTMapRange.alloc().initWithMinMax(value[0], value[1]));
2222
}
23+
24+
get minVisibleZoom() {
25+
if (this.native) {
26+
const zoomRange = this.native.getVisibleZoomRange();
27+
return zoomRange.getMin();
28+
}
29+
return this.options.visibleZoomRange?.[0];
30+
}
31+
set minVisibleZoom(value: number) {
32+
if (this.native) {
33+
const zoomRange = this.native.getVisibleZoomRange();
34+
this.native.setVisibleZoomRange(NTMapRange.alloc().initWithMinMax(value, zoomRange.getMax()));
35+
}
36+
}
37+
get maxVisibleZoom() {
38+
if (this.native) {
39+
const zoomRange = this.native.getVisibleZoomRange();
40+
return zoomRange.getMax();
41+
}
42+
return this.options.visibleZoomRange?.[1];
43+
}
44+
set maxVisibleZoom(value: number) {
45+
if (this.native) {
46+
const zoomRange = this.native.getVisibleZoomRange();
47+
this.native.setVisibleZoomRange(NTMapRange.alloc().initWithMinMax(zoomRange.getMin(), value));
48+
}
49+
}
2350
refresh() {
2451
this.native && this.native.refresh();
2552
}

0 commit comments

Comments
 (0)