File tree Expand file tree Collapse file tree 4 files changed +84
-6
lines changed Expand file tree Collapse file tree 4 files changed +84
-6
lines changed Original file line number Diff line number Diff line change @@ -263,11 +263,19 @@ export interface AddGeoJsonClusteredOptions {
263263 clusters ?: MapboxCluster [ ] ;
264264}
265265
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+
266274export interface AddLayerOptions {
267275 id : string ;
268276 source : string ;
269277 sourceLayer : string ;
270- type : string ;
278+ type : SupportedLayerType ;
271279
272280 /**
273281 * 'circle' paint properties
@@ -554,6 +562,7 @@ export interface LayerCommon {
554562 getNativeInstance ( ) : any ;
555563 setFilter ( filter : any [ ] ) : void ;
556564 getFilter ( ) : any [ ] ;
565+ type ( ) : LayerType ;
557566}
558567
559568// ------------------------------------------------------------
Original file line number Diff line number Diff line change 1- import { LayerCommon } from ' ../common' ;
1+ import { LayerCommon , LayerType } from " ../common"
22import { ExpressionParser } from '../expression/expression-parser' ;
33import { PropertyParser } from './parser/property-parser' ;
44
@@ -43,6 +43,40 @@ export class Layer implements LayerCommon {
4343 public getProperty ( name : string ) : any {
4444 return PropertyParser . propertyValueFromLayer ( this . instance , name ) ;
4545 }
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+ }
4680}
4781
4882export class LayerFactory {
Original file line number Diff line number Diff line change 1- import { LayerCommon } from ' ../common' ;
1+ import { LayerCommon , LayerType } from " ../common"
22
33declare class LayerFactory {
44 static createLayer ( style , source ) : Promise < LayerCommon > ;
@@ -16,4 +16,5 @@ export declare class Layer implements LayerCommon {
1616 getFilter ( ) : any [ ] ;
1717 setProperty ( name : string , value : any ) : void ;
1818 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"
22import { ExpressionParser } from '../expression/expression-parser' ;
33import { PropertyParser } from './parser/property-parser' ;
44
@@ -55,11 +55,45 @@ export class Layer implements LayerCommon {
5555 public id : string ;
5656 private instance ;
5757
58- constructor ( instance ) {
58+ constructor ( instance : MGLStyleLayer ) {
5959 this . instance = instance ;
6060 this . id = instance . identifier ;
6161 }
6262
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+
6397 visibility ( ) : boolean {
6498 return this . instance . visible ;
6599 }
You can’t perform that action at this time.
0 commit comments