Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/ui-mapbox/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,19 @@ export interface AddGeoJsonClusteredOptions {
clusters?: MapboxCluster[];
}

// ------------------------------------------------------------

export type LayerType = "fill" | "line" | "symbol" | "circle" | "heatmap" | "fill-extrusion" | "raster" | "hillshade" | "background" | "sky"

export type SupportedLayerType = LayerType & ("line" | "circle" | "fill" | "symbol" | "raster")

// ------------------------------------------------------------

export interface AddLayerOptions {
id: string;
source: string;
sourceLayer: string;
type: string;
type: SupportedLayerType;

/**
* 'circle' paint properties
Expand Down Expand Up @@ -553,6 +561,7 @@ export interface LayerCommon {
getNativeInstance(): any;
setFilter(filter: any[]): void;
getFilter(): any[];
type(): LayerType;
}

// ------------------------------------------------------------
Expand Down
36 changes: 35 additions & 1 deletion src/ui-mapbox/layers/layer-factory.android.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LayerCommon } from '../common';
import { LayerCommon, LayerType } from "../common"
import { ExpressionParser } from '../expression/expression-parser';
import { PropertyParser } from './parser/property-parser';

Expand Down Expand Up @@ -43,6 +43,40 @@ export class Layer implements LayerCommon {
public getProperty(name: string): any {
return PropertyParser.propertyValueFromLayer(this.instance, name);
}

public type(): LayerType {
if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.FillLayer) {
return "fill"
}
if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.LineLayer) {
return "line"
}
if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.SymbolLayer) {
return "symbol"
}
if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.CircleLayer) {
return "circle"
}
if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.HeatmapLayer) {
return "heatmap"
}
if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer) {
return "fill-extrusion"
}
if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.RasterLayer) {
return "raster"
}
if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.HillshadeLayer) {
return "hillshade"
}
if (this.instance instanceof com.mapbox.mapboxsdk.style.layers.BackgroundLayer) {
return "background"
}

// there is no sky layer in the Android Mapbox SDK

return null;
}
}

export class LayerFactory {
Expand Down
5 changes: 3 additions & 2 deletions src/ui-mapbox/layers/layer-factory.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LayerCommon } from '../common';
import { LayerCommon, LayerType } from "../common"

declare class LayerFactory {
static createLayer(style, source): Promise<LayerCommon>;
Expand All @@ -16,4 +16,5 @@ export declare class Layer implements LayerCommon {
getFilter(): any[];
setProperty(name: string, value: any): void;
getProperty(name: string): any;
}
type(): LayerType;
}
38 changes: 36 additions & 2 deletions src/ui-mapbox/layers/layer-factory.ios.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LayerCommon } from '../common';
import { LayerCommon, LayerType } from "../common"
import { ExpressionParser } from '../expression/expression-parser';
import { PropertyParser } from './parser/property-parser';

Expand Down Expand Up @@ -55,11 +55,45 @@ export class Layer implements LayerCommon {
public id: string;
private instance;

constructor(instance) {
constructor(instance: MGLStyleLayer) {
this.instance = instance;
this.id = instance.identifier;
}

type(): LayerType {
if (this.instance instanceof MGLFillStyleLayer) {
return "fill"
}
if (this.instance instanceof MGLLineStyleLayer) {
return "line"
}
if (this.instance instanceof MGLSymbolStyleLayer) {
return "symbol"
}
if (this.instance instanceof MGLCircleStyleLayer) {
return "circle"
}
if (this.instance instanceof MGLHeatmapStyleLayer) {
return "heatmap"
}
if (this.instance instanceof MGLFillExtrusionStyleLayer) {
return "fill-extrusion"
}
if (this.instance instanceof MGLRasterStyleLayer) {
return "raster"
}
if (this.instance instanceof MGLHillshadeStyleLayer) {
return "hillshade"
}
if (this.instance instanceof MGLBackgroundStyleLayer) {
return "background"
}

// there is no sky layer in the Mapbox iOS SDK

return null;
}

visibility(): boolean {
return this.instance.visible;
}
Expand Down