Maplace.js

Circles and polygons

Markers and shapes together

A marker, a circle, an area and a line on one map and in one list.

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 marker, a circle, a polygon and a polyline on one map and in one list: each location gives its
     own type, all from inline JSON. -->
<maplace-map list>
  <script type="application/json">
    [{ "id": "tower-of-london", "type": "marker", "title": "Tower of London", "lat": 51.5081, "lng": -0.0759 },
     { "id": "greenwich", "type": "circle", "title": "Greenwich", "center": { "lat": 51.4769, "lng": -0.0005 }, "radius": 500 },
     { "id": "hyde-park", "type": "polygon", "title": "Hyde Park",
       "path": [{ "lat": 51.5115, "lng": -0.1755 }, { "lat": 51.511, "lng": -0.16 }, { "lat": 51.503, "lng": -0.16 },
                { "lat": 51.5035, "lng": -0.1755 }] },
     { "id": "thames", "type": "polyline", "title": "Along the Thames",
       "path": [{ "lat": 51.5009, "lng": -0.1222 }, { "lat": 51.5085, "lng": -0.1166 }, { "lat": 51.5098, "lng": -0.1043 },
                { "lat": 51.5085, "lng": -0.0943 }, { "lat": 51.5079, "lng": -0.0877 }] }]
  </script>
</maplace-map>

How it works

A marker, a circle, a polygon and a polyline on one map and in one list: each location says what it is with its own type, and everything else about them works alike.

  • HTML: list on the map, and a <script type="application/json"> inside <maplace-map> holding all four, as a path takes more than an attribute (Data).
  • Script and Bundler: type on each location (Markers, Circles, Polylines, Polygons), and list: { container } (List view options).
  • React: the same locations on <MaplaceProvider>, and <LocationList /> beside the <MaplaceMap> (<LocationList>).