Maplace.js

Lines and routes

Editable polyline

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

Markdown

Map and code

Run the examples on

Loading the map…

The map couldn't load.

Loading the map…

The map couldn't load.

Loading the map…

The map couldn't load.

Loading the map…

The map couldn't load.

Loading the map…

The map couldn't load.

Loading the map…

The map couldn't load.

Loading the map…

The map couldn't load.

Loading the map…

The map couldn't load.

These maps come from Google Maps and OpenFreeMap, which see your IP address. They stay off until you say so, once for the whole site. What loading the maps sends

<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<!-- A trail to edit (drag a point, or the middle of a segment), Cinque Terre's coastal path, with
     the villages along it and a list beside the map under a heading, all from inline JSON. -->
<maplace-map list list-heading="Along the trail">
  <script type="application/json">
    [{ "id": "trail", "type": "polyline", "title": "Sentiero Azzurro", "editable": true,
       "path": [{ "lat": 44.0996, "lng": 9.7377 }, { "lat": 44.1066, "lng": 9.7285 }, { "lat": 44.1197, "lng": 9.7103 },
                { "lat": 44.1348, "lng": 9.6847 }, { "lat": 44.1462, "lng": 9.6548 }] },
     { "id": "manarola", "lat": 44.1066, "lng": 9.7285, "title": "Manarola", "content": "Its harbour, and the houses above it." },
     { "id": "corniglia", "lat": 44.1197, "lng": 9.7103, "title": "Corniglia", "content": "The village on the cliff top." },
     { "id": "vernazza", "lat": 44.1348, "lng": 9.6847, "title": "Vernazza", "content": "A harbour and its castle's tower." }]
  </script>
</maplace-map>

How it works

A trail you can edit, Cinque Terre’s coastal path, with the villages along it as markers of their own and in the list beside the map.

  • HTML: a <script type="application/json"> inside <maplace-map> holding the data, as a path takes more than an attribute (Data); list and list-heading on the map (Map attributes).
  • Script and Bundler: type: "polyline", path and editable on a location (Polylines), and list: { container, heading } (List view options).
  • React: the same locations on <MaplaceProvider>, and <LocationList heading="Along the trail" /> beside the <MaplaceMap> (<LocationList>).