New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

maplibre-grid

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maplibre-grid

Grid / graticule plugin for MapLibre GL JS / Mapbox GL JS

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
64
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

maplibre-grid

Grid / graticule plugin for MapLibre GL JS / Mapbox GL JS

Demo

Screenshot

Install

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>

Usage

import Maplibre from 'maplibre-gl';
import * as MaplibreGrid from 'maplibre-grid';

API

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, required
  • gridHeight - number, required
  • units - 'degrees' | 'radians' | 'miles' | 'kilometers', grid width/height units, required
  • minZoom - number, min zoom to display the grid
  • maxZoom - number, max zoom to display the grid
  • paint - maplibregl.LinePaint, layer line paint properties

Multiple grids can be added to display major and minor grid together, or different grids depending on zoom level.

Basic

const grid = new MaplibreGrid.Grid({
  gridWidth: 10,
  gridHeight: 10,
  units: 'degrees',
  paint: {
    'line-opacity': 0.2
  }
});
map.addControl(grid);

Multiple grids

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);

Click event

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.

Destroy

map.removeControl(grid);

Keywords

FAQs

Package last updated on 26 Oct 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc