File tree 4 files changed +85
-7
lines changed
4 files changed +85
-7
lines changed Original file line number Diff line number Diff line change @@ -263,11 +263,19 @@ export interface AddGeoJsonClusteredOptions {
263
263
clusters ?: MapboxCluster [ ] ;
264
264
}
265
265
266
+ // ------------------------------------------------------------
267
+
268
+ export type LayerType = "fill" | "line" | "symbol" | "circle" | "heatmap" | "fill-extrusion" | "raster" | "hillshade" | "background" | "sky"
269
+
270
+ export type SupportedLayerType = LayerType & ( "line" | "circle" | "fill" | "symbol" | "raster" )
271
+
272
+ // ------------------------------------------------------------
273
+
266
274
export interface AddLayerOptions {
267
275
id : string ;
268
276
source : string ;
269
277
sourceLayer : string ;
270
- type : string ;
278
+ type : SupportedLayerType ;
271
279
272
280
/**
273
281
* 'circle' paint properties
@@ -553,6 +561,7 @@ export interface LayerCommon {
553
561
getNativeInstance ( ) : any ;
554
562
setFilter ( filter : any [ ] ) : void ;
555
563
getFilter ( ) : any [ ] ;
564
+ type ( ) : LayerType ;
556
565
}
557
566
558
567
// ------------------------------------------------------------
Original file line number Diff line number Diff line change 1
- import { LayerCommon } from ' ../common' ;
1
+ import { LayerCommon , LayerType } from " ../common"
2
2
import { ExpressionParser } from '../expression/expression-parser' ;
3
3
import { PropertyParser } from './parser/property-parser' ;
4
4
@@ -43,6 +43,40 @@ export class Layer implements LayerCommon {
43
43
public getProperty ( name : string ) : any {
44
44
return PropertyParser . propertyValueFromLayer ( this . instance , name ) ;
45
45
}
46
+
47
+ public type ( ) : LayerType {
48
+ if ( this . instance instanceof com . mapbox . mapboxsdk . style . layers . FillLayer ) {
49
+ return "fill"
50
+ }
51
+ if ( this . instance instanceof com . mapbox . mapboxsdk . style . layers . LineLayer ) {
52
+ return "line"
53
+ }
54
+ if ( this . instance instanceof com . mapbox . mapboxsdk . style . layers . SymbolLayer ) {
55
+ return "symbol"
56
+ }
57
+ if ( this . instance instanceof com . mapbox . mapboxsdk . style . layers . CircleLayer ) {
58
+ return "circle"
59
+ }
60
+ if ( this . instance instanceof com . mapbox . mapboxsdk . style . layers . HeatmapLayer ) {
61
+ return "heatmap"
62
+ }
63
+ if ( this . instance instanceof com . mapbox . mapboxsdk . style . layers . FillExtrusionLayer ) {
64
+ return "fill-extrusion"
65
+ }
66
+ if ( this . instance instanceof com . mapbox . mapboxsdk . style . layers . RasterLayer ) {
67
+ return "raster"
68
+ }
69
+ if ( this . instance instanceof com . mapbox . mapboxsdk . style . layers . HillshadeLayer ) {
70
+ return "hillshade"
71
+ }
72
+ if ( this . instance instanceof com . mapbox . mapboxsdk . style . layers . BackgroundLayer ) {
73
+ return "background"
74
+ }
75
+
76
+ // there is no sky layer in the Android Mapbox SDK
77
+
78
+ return null ;
79
+ }
46
80
}
47
81
48
82
export class LayerFactory {
Original file line number Diff line number Diff line change 1
- import { LayerCommon } from ' ../common' ;
1
+ import { LayerCommon , LayerType } from " ../common"
2
2
3
3
declare class LayerFactory {
4
4
static createLayer ( style , source ) : Promise < LayerCommon > ;
@@ -16,4 +16,5 @@ export declare class Layer implements LayerCommon {
16
16
getFilter ( ) : any [ ] ;
17
17
setProperty ( name : string , value : any ) : void ;
18
18
getProperty ( name : string ) : any ;
19
- }
19
+ type ( ) : LayerType ;
20
+ }
Original file line number Diff line number Diff line change 1
- import { LayerCommon } from ' ../common' ;
1
+ import { LayerCommon , LayerType } from " ../common"
2
2
import { ExpressionParser } from '../expression/expression-parser' ;
3
3
import { PropertyParser } from './parser/property-parser' ;
4
4
@@ -53,13 +53,47 @@ export class LayerFactory {
53
53
54
54
export class Layer implements LayerCommon {
55
55
public id : string ;
56
- private instance ;
56
+ private instance : MGLStyleLayer ;
57
57
58
- constructor ( instance ) {
58
+ constructor ( instance : MGLStyleLayer ) {
59
59
this . instance = instance ;
60
60
this . id = instance . identifier ;
61
61
}
62
62
63
+ type ( ) : LayerType {
64
+ if ( this . instance instanceof MGLFillStyleLayer ) {
65
+ return "fill"
66
+ }
67
+ if ( this . instance instanceof MGLLineStyleLayer ) {
68
+ return "line"
69
+ }
70
+ if ( this . instance instanceof MGLSymbolStyleLayer ) {
71
+ return "symbol"
72
+ }
73
+ if ( this . instance instanceof MGLCircleStyleLayer ) {
74
+ return "circle"
75
+ }
76
+ if ( this . instance instanceof MGLHeatmapStyleLayer ) {
77
+ return "heatmap"
78
+ }
79
+ if ( this . instance instanceof MGLFillExtrusionStyleLayer ) {
80
+ return "fill-extrusion"
81
+ }
82
+ if ( this . instance instanceof MGLRasterStyleLayer ) {
83
+ return "raster"
84
+ }
85
+ if ( this . instance instanceof MGLHillshadeStyleLayer ) {
86
+ return "hillshade"
87
+ }
88
+ if ( this . instance instanceof MGLBackgroundStyleLayer ) {
89
+ return "background"
90
+ }
91
+
92
+ // there is no sky layer in the Mapbox iOS SDK
93
+
94
+ return null ;
95
+ }
96
+
63
97
visibility ( ) : boolean {
64
98
return this . instance . visible ;
65
99
}
You can’t perform that action at this time.
0 commit comments