![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
maplibre-grid
Advanced tools
Grid / graticule plugin for MapLibre GL JS / Mapbox GL JS
npm install maplibre-gl maplibre-grid
or
<script src="https://unpkg.com/maplibre-gl@1.13.0-rc.5/dist/maplibre-gl.js"></script>
<link href="https://unpkg.com/maplibre-gl@1.13.0-rc.5/dist/maplibre-gl.css" rel="stylesheet">
<script src="https://unpkg.com/maplibre-grid@1.0.0/dist/maplibre-grid.js"></script>
import Maplibre from 'maplibre-gl';
import * as MaplibreGrid from 'maplibre-grid';
export interface GridConfig {
gridWidth: number;
gridHeight: number;
units: Units;
minZoom?: number;
maxZoom?: number;
paint?: maplibregl.LinePaint;
}
const grid = new MaplibreGrid.Grid(config: GridConfig);
gridWidth
- number, requiredgridHeight
- number, requiredunits
- 'degrees' | 'radians' | 'miles' | 'kilometers', grid width/height units, requiredminZoom
- number, min zoom to display the gridmaxZoom
- number, max zoom to display the gridpaint
- maplibregl.LinePaint, layer line paint propertiesMultiple grids can be added to display major and minor grid together, or different grids depending on zoom level.
const grid = new MaplibreGrid.Grid({
gridWidth: 10,
gridHeight: 10,
units: 'degrees',
paint: {
'line-opacity': 0.2
}
});
map.addControl(grid);
const grid1 = new MaplibreGrid.Grid({
gridWidth: 10,
gridHeight: 10,
units: 'degrees',
paint: {
'line-opacity': 0.2
}
});
map.addControl(grid1);
const grid2 = new MaplibreGrid.Grid({
gridWidth: 5,
gridHeight: 5,
units: 'degrees',
paint: {
'line-opacity': 0.2
}
});
map.addControl(grid2);
map.on(MaplibreGrid.GRID_CLICK_EVENT, event => {
console.log(event.bbox);
});
Click event can be used to implement grid cell selection. Create a polygon feature from event.bbox
, and add it to your custom layer. See demo for details.
map.removeControl(grid);
1.0.0
FAQs
Grid / graticule plugin for MapLibre GL JS / Mapbox GL JS
The npm package maplibre-grid receives a total of 64 weekly downloads. As such, maplibre-grid popularity was classified as not popular.
We found that maplibre-grid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.