0.1.3 • Published 6 months ago

maplibre-gl-basemaps v0.1.3

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

MapLibre GL Basemaps Control

The core interactions and styling of this control is based on Leaflet.Basemaps

A Maplibre GL Control for switching between basemaps. The control only supports raster sources.

Demo

Installation

npm install maplibre-gl-basemaps

Usage

import BasemapsControl from 'maplibre-gl-basemaps';
import 'maplibre-gl-basemaps/lib/basemaps.css';

map.addControl(new BasemapsControl(options));

To run the examples locally, install the dependencies and run npm run examples. Access the examples at localhost:8080.

Options

Control options

AttributeDescriptionDefault value
basemapsAn array of basemap objects (see the table below for attributes of basemap object)-
initialBasemapId of the basemap to set to active on initialization-
expandDirectionThe direction that the control expand on hoverright

Basemap object

AttributeDescription
idThe string to use for both the basemap source and layer
tilesAn array of one or more tile source URLs, as in the TileJSON spec (https://maplibre.org/maplibre-style-spec/sources/#raster)
sourceExtraParamsOther parameters accepted by MapLibre GL raster source to pass to the basemap (https://maplibre.org/maplibre-style-spec/sources/#raster)
layerExtraParamsOther parameters accepted by MapLibre GL raster layer to pass to the basemap (https://maplibre.org/maplibre-style-spec/sources/#raster)