Class WebMapLayers<M, L, E, O>

Type Parameters

Hierarchy

Implemented by

Constructors

Properties

_initMapState: Record<string, any> = {}

From runtime params

_starterKits: StarterKit[]
emitter: StrictEventEmitter<EventEmitter, WebMapEvents, WebMapEvents, "addEventListener" | "removeEventListener", "on" | "addListener" | "removeListener" | "once" | "emit"> = ...
getPaintFunctions: {
    [name: string]: GetPaintFunction;
} = WebMapMain.getPaintFunctions

Type declaration

id: number = ...
keys: Keys = WebMapMain.keys
mapAdapter: MapAdapter<M, any, any>
mapState: Type<StateItem<any>>[] = ...
options: O = ...
runtimeParams: RuntimeParams[] = []
getPaintFunctions: {
    [name: string]: GetPaintFunction;
}

Type declaration

keys: Keys = ...

Methods

  • Create layer from GeoJson data. Set style and behavior for selection.

    Example

    // Add simple layer
    webMap.addGeoJsonLayer({ data: geojson, paint: { color: 'red' } });

    // Add styled by feature property layer with selection behavior
    webMap.addGeoJsonLayer({
    data: geojson,
    paint: function (feature) {
    return { color: feature.properties.color, opacity: 0.5 }
    },
    selectedPaint: function (feature) {
    return { color: feature.properties.selcolor, opacity: 1 }
    },
    selectable: true,
    multiselect: true
    });

    // Add marker layer styled with use [Icons](icons)
    webMap.addGeoJsonLayer({ data: geojson, paint: webMap.getIcon({ color: 'orange' })});

    // work with added layer
    const layer = webMap.addGeoJsonLayer({ data: geojson, id: 'my_layer_name'});
    // access layer by id
    webMap.showLayer('my_layer_name');
    // or access layer by instance
    webMap.showLayer(layer);

    Type Parameters

    Parameters

    Returns Promise<VectorLayerAdapter<any, any, any, Feature<Geometry, GeoJsonProperties>, GeoJsonProperties, Record<string, any> | {
        [name: string]: any;
    }>>

  • Push new the GeoJSON features into given vector layer.

    Example

    const layer = webMap.addLayer('GEOJSON', {data: geojson_features_5}).then((layer) => {
    console.log(layer.getLayers().length) // > 5;
    webMap.addLayerData(layer, geojson_features_3);
    console.log(layer.getLayers().length) // > 8;
    });

    Parameters

    Returns void

  • Remove from vector layer all features. it is possible to remove only some objects if you specify a callback function.

    Example

    const layer = webMap.addLayer('GEOJSON', {data: geojson}).then((layer) => {
    webMap.clearLayerData(layer, (feture) => feture.id === 42);
    webMap.clearLayerData(layer);
    });

    Parameters

    • layerDef: LayerDef
    • Optional cb: ((feature) => boolean)
        • (feature): boolean
        • Parameters

          • feature: Feature<Geometry, GeoJsonProperties>

          Returns boolean

    Returns void

  • Hide features from a vector layer using a callback function.

    Example

    const layer = webMap.addLayer('GEOJSON', {data: geojson}).then((layer) => {
    webMap.filterLayer(layer, ({feature}) => feature.id === '42');
    });

    Parameters

    Returns LayerDefinition<Feature<Geometry, GeoJsonProperties>, L>[]

  • Returns the map's geographical centerpoint.

    Returns

    lngLat Array of two numbers representing longitude and latitude of the center of the map view.

    Example

    // Mount Everest 27° 59′ 17″ N, 86° 55′ 31″ E
    webMap.getCenter(); // [86.925278, 27.988056]

    Returns undefined | LngLatArray

  • Checking the status of any asynchronous operation

    Example

    var webMap = new WebMap(options);
    webMap.getEventStatus('create'); // false
    webMap.emitter.on('create', function () {
    webMap.getEventStatus('create'); // true
    })

    Parameters

    • event: keyof E

      The name of the event whose status is checked

    Returns boolean

  • helper method to wait for events to load. By default, card creation is tracked

    Example

    var webMap = new WebMap(options);
    webMap.onLoad().then(function () {
    webMap.getEventStatus('create'); // true
    })

    // use async/await syntax
    async function () {
    await webMap.onLoad();
    doSomething();
    }

    Parameters

    • event: keyof WebMapEvents = 'create'

      The name of the event whose status is checked

    Returns Promise<WebMapLayers<M, L, E, O>>

  • Remove all layer from map and memory.

    Parameters

    • Optional allowCb: ((layer, adapter) => boolean)
        • (layer, adapter): boolean
        • Parameters

          Returns boolean

    Returns void

  • Mark the layer as selected. If the adapter is a vector layer and supports data selection, you can pass a callback function to specify which data will be selected.

    Example

    const layer = webMap.addLayer('GEOJSON', {data: geojson}).then((layer) => {
    webMap.selectLayer(layer, ({feature}) => feature.id === '42');
    });

    Parameters

    Returns void

  • Sets the GeoJSON data for given vector layer.

    Example

    const layer = webMap.addLayer('GEOJSON').then((layer) => {
    webMap.setLayerData(layer, geojson);
    });

    Parameters

    Returns void | Promise<void>

  • Change added layer visibility on the map by given status or inverse current status.

    Example

    webMap.addLayer('TILE', {id: 'my_layer', url: ''}).then((layer) => {
    webMap.toggleLayer(layer, true);
    webMap.toggleLayer('my_layer', false);
    webMap.toggleLayer('my_layer');
    webMap.isLayerVisible(layer); // true
    });

    Parameters

    Returns Promise<void>

  • Unselect the given layer. If the adapter is a vector layer and supports data selection, you can pass a callback function to specify which data will be unselected.

    Example

    const layer = webMap.addLayer('GEOJSON', {data: geojson}).then((layer) => {
    webMap.unSelectLayer(layer, ({feature}) => feature.id === '42');
    });

    Parameters

    Returns void

Generated using TypeDoc