A layer control for MapLibre GL JS
npm install maplibre-gl-layerA layer control for MapLibre GL JS.
``sh`
npm install maplibre-gl-layer
`js
import { Map } from "maplibre-gl";
import "maplibre-gl/dist/maplibre-gl.css";
import { LayerControl } from "maplibre-gl-layer";
import 'maplibre-gl-layer/style.css'
const map = new Map({ / YOUR_MAP_OPTIONS / });
/**
* Parameters for LayerControl
* {
* layers: Array<{
* name: string;
* style: string | StyleSpecification;
* checked?: boolean;
* }>;
* }
*/
const layerControl = new LayerControl({
layers: [
{
name: 'STYLE 1',
style: YOUR_AWESOME_STYLE
},
{
name: 'STYLE 2',
style: YOUR_AWESOME_STYLE
}
]
})
map.addControl(layerControl)
``
This project is licensed under the terms of the MIT license.