leaflet-polar-graticule
v0.1.3
Published
Grid of latitidue and longitude lines, with support for polar map projections
Downloads
224
Maintainers
Readme
Leaflet.Graticule
Generate a graticule grid of latitude and longitude lines. The graticule inclues labels by default, and support for maps in polar projections.
This is heavily based on the original L.Graticule plugin and labels are provided using the Leaflet Textpath plugin.
Usage
L.graticule(options)
Create a new Graticule layer which inherits from L.GeoJSON
. The following options have been added:
intervalLat
: the gap between each line of latitude, in degreesintervalLon
: the gap between each line of longtitude, in degreeslatBounds
: the latitudes to draw the graticule over (default: [-90,90])lngBounds
: the longitudes to draw the graitcule over (default: [-180,180])centerLatLabels
: center labels along the graticule (default: true)centerLngLabels
: center labels along the graticule (default: false)style
: path options for the generated lines
Example
// Add a basic graticule with divisions every 20 degrees
// as a layer on a map
L.graticule().addTo(map);
// Specify divisions every 10 degrees
L.graticule({ intervalLat: 10, intervalLng: 10 }).addTo(map);
// Specify bold red lines instead of thin grey lines
L.graticule({
style: {
color: '#f00',
weight: 10
}
}).addTo(map);
Demos
For Antarctica
For Arctic
Installation
If you are using npm:
npm install leaflet-polar-graticule
Otherwise, its available through unpkg. In your html, add:
<script src="https://unpkg.com/[email protected]/L.Graticule.min.js" integrity="sha384-ZnsQFe3F+Xr0kzjaMGtAPO+41YGRanGndF7uefFEA/N87dUB4kHhq+xv7GHnWbh/" crossorigin="anonymous"></script>
Advanced Use
If you don't like how the labels are displayed, you can specify a custom display function. (See onEachFeature in L.Graticule.js)