Maplace.js

Lines and routes

A polyline to edit, great-circle flights, air and sea lanes by colour, and a driving route through your own stops with directions by leg.

Markdown

Examples

  • Editable polyline

    A polyline to edit: a trail, with places along it.

  • Flight paths

    Great circles from one city to eight, the scheduled ones dashed; slide the flight to New York along its way.

  • Trade routes

    Air and sea trade lanes by colour; hover one, pick one for its volume.

  • Driving route

    A drive through your own places, with directions by leg: Google computes it live; on MapLibre it's one stored route, as your own routing service would answer.

Map images: © OpenStreetMap contributors, © OpenMapTiles, OpenFreeMap.

Reference

Polylines, from the Locations reference

Field Type What In HTML
path { lat, lng }[] Its points, at least 2
curve number How far each segment bows from a straight line, for the look, -1 to 1: at 1, its middle sits half its length (in degrees) to the left going from the first point to the last; to the right when negative. Default 0, straight; not with geodesic or editable
geodesic boolean Draws each segment along its great circle, the shortest way on the earth: a flight’s path, a point a degree of arc. Default false; not with curve or editable
progress number How much of the line is travelled, 0 to 1 along it as drawn: that part is drawn in the travelled look, the rest as the line, and a click or hover on either is the line’s. Unset, the line is drawn whole; not with editable
travelledStyle LineStyle The travelled part’s style, over its look: the line’s own in its state, at 40% of its opacity
style LineStyle How it is drawn: a stroke, no fill shape-style (JSON)
selectedStyle LineStyle Drawn over style while selected selected-style (JSON)
hoveredStyle LineStyle Drawn over style while hovered and not selected hovered-style (JSON)
active boolean Marks it as the page’s current one: drawn in the hovered look while neither hovered nor selected, not lifted above other shapes active
activeStyle LineStyle Drawn over style while active, neither hovered nor selected active-style (JSON)

Routes, from the Store reference

Field Type What
stops string[] Location ids, from 2 to the adapter’s routeStopLimit (27 on Google, none on MapLibre but your service’s)
via string[] Inner stops the route passes through without ending a leg
travelMode "driving" | "walking" | "bicycling" | "transit" Driving when left out
avoid ("tolls" | "highways" | "ferries")[] What the route keeps off where it reasonably can, in any order; on Google, driving routes only (routes)
style LineStyle How the route’s line is drawn
progress number How much of the route is travelled, 0 to 1 along its path, as a polyline’s: a new progress draws the line again without computing it. On Google, Maplace.js then draws the route itself in Google’s route look, in one colour for a transit route
travelledStyle LineStyle The travelled part’s style, over its look: the route’s own at 40% of its opacity