0.0.6 • Published 5 years ago

mapbox-layer-switcher v0.0.6

Weekly downloads
1
License
GPL-3.0
Repository
github
Last release
5 years ago

Mapbox GL JS Layer Switcher

Adds a Layer switcher to mapbox-gl

Installation:

npm i mapbox-layer-switcher --save

Usage:

import { MapboxLayerSwitcherControl } from "mapbox-layer-switcher";
import { Map as MapboxMap } from "mapbox-gl";

import "mapbox-layer-switcher/styles.css";

const map = new MapboxMap();
map.addControl(new MapboxLayerSwitcherControl());

Options:

If you want to supply your own list of layers, pass them in the constructor.

import { MapboxLayerDefinition, MapboxLayerSwitcherControl } from "mapbox-layer-switcher";

const layers: MapboxLayerDefinition[] = [
    {
        id: "here-map",
        title: "Here",
        visibility: 'visible',
        type: 'base'
    },
    {
        id: "google-map",
        title: "Google",
        visibility: 'none',
        type: 'base'
    },
    {
        id: "composite",
        title: "MapBox",
        visibility: 'none',
        type: 'base'
    }
];

map.addControl(new MapboxLayerSwitcherControl(layers));

Screenshots

Closed

Open

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago