maplibre-gl-layer
v0.3.2
Published
A layer control for MapLibre GL JS
Readme
maplibre-gl-layer
A layer control for MapLibre GL JS.

Installation
npm install maplibre-gl-layerUsage
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
}
]
})
layerControl.on('layerchange', (layer) => {
console.log('Layer changed to:', layer.name)
})
map.addControl(layerControl)License
This project is licensed under the terms of the MIT license.
