A maplibre-gl-js plugin for drawing vector arrows with geographic coordinates. See this blog post for a live demo and motivation.
NPM
npm install --save @awesompehant/maplibre-arrowsBrowser
<script src="https://unpkg.com/@awesomephant/maplibre-arrows@latest/dist/index.min.js"></script>HTML
<div id="map"></div>Javascript
// Initialise maplibregl
const map = new maplibregl.Map({
container: "map",
style: "https://demotiles.maplibre.org/style.json",
center: [-96, 35],
zoom: 3.3
});
// Initialise maplibreArrows with the map object and a configuration object
const arrows = new maplibreArrows(map, {
arrows: [
{
layout: "straight",
lineColor: "#bf3a1a",
lineWidth: 38,
points: [
[-81, 35],
[-88, 43],
[-82, 41]
]
}
]
});maplibreArrows() takes two parameters:
map(required):Mapoptions(required): configuration object of the following shape:ArrowSpec[](required): The initial set of arrows to render
ArrowSpec is an object of the following shape:
points(required): Array of points in geographic coordinates.layout:"quadratic"|"straight"lineColor:colorlineWidth:number
This project uses esbuild and Node's built-in test runner.
npm ito install dependenciesnpm run testto run unit testsnpm version {patch, minor, major}npm publish --access public