A Leaflet Plugin for PMTiles formatted vector data. Built on Leaflet.VectorGrid and the PMTiles javascript package.
With npm:
npm install leaflet-pmtiles-layer
Script tag:
<script src="https://unpkg.com/leaflet-pmtiles-layer@latest/dist/Leaflet.PMTilesLayer.js"></script>
var options = {
style: {
weight: 1,
radius: 4,
fillColor: '#3388ff',
fill: true
}
};
var url = "https://example.com/path/to/dataset.pmtiles"
L.pmtilesLayer(url, options).addTo(map)
Leaflet.PMTilesLayer extends Leaflet.VectorGrid, so many of its options are available.
Unlike Leaflet.VectorGrid, layers can be styled using the style
option with Path-type keys and values.
Use the autoScale
layer option to define auto scaling behavior. If a PMTiles layer has a maxZoom less than maxZoom of the map, tile features can be scaled for display at higher zoom levels.
Option | Value | Description |
---|---|---|
autoScale |
'pmtiles' |
Default value. Use algorithms in the plug-in itself. |
autoScale |
'leaflet' |
Use leaflet's built-in autoscaling. |
autoScale |
false |
Disable autoscaling. |
Install dependencies
yarn install
Build the project
yarn build
Run end-to-end tests
yarn cypress run
Lint using StandardJS
yarn lint