JSPM

mapbox-layer-switcher

0.0.6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q58227F
  • License GPL-3.0

Mapbox GL Layer Switcher

Package Exports

  • mapbox-layer-switcher

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mapbox-layer-switcher) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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