Maplace.js

Styling

Brand colours

One palette across the delivery areas, the cluster badges and the 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>
<!-- One palette across the map: the delivery areas' colours at rest, hovered and selected, the
     cluster badge's (--maplace-cluster-background, --maplace-cluster-color), and the list's,
     through the classes Maplace.js's markup carries. -->
<style>
  #brand-maplibre-map { --maplace-cluster-background: #3b2416; --maplace-cluster-color: #f5ead9; }
  #brand-maplibre-map .maplace-option[data-hovered] { background: #f5ead9; color: #3b2416; }
  #brand-maplibre-map .maplace-option[data-selected] { background: #23735a; color: #fff; }
</style>
<maplace-map id="brand-maplibre-map" cluster list>
  <script type="application/json">
    [
      {"id": "north", "type": "polygon", "title": "North delivery area", "path": [{"lat": 55.697, "lng": 12.548}, {"lat": 55.697, "lng": 12.598}, {"lat": 55.684, "lng": 12.598}, {"lat": 55.684, "lng": 12.548}], "style": {"stroke": "#3b2416", "strokeWidth": 2, "fill": "#c8a27a", "fillOpacity": 0.3}, "hoveredStyle": {"stroke": "#23735a", "strokeWidth": 3}, "selectedStyle": {"stroke": "#23735a", "strokeWidth": 3, "fill": "#23735a", "fillOpacity": 0.4}},
      {"id": "south", "type": "polygon", "title": "South delivery area", "path": [{"lat": 55.677, "lng": 12.548}, {"lat": 55.677, "lng": 12.6}, {"lat": 55.658, "lng": 12.6}, {"lat": 55.658, "lng": 12.548}], "style": {"stroke": "#3b2416", "strokeWidth": 2, "fill": "#c8a27a", "fillOpacity": 0.3}, "hoveredStyle": {"stroke": "#23735a", "strokeWidth": 3}, "selectedStyle": {"stroke": "#23735a", "strokeWidth": 3, "fill": "#23735a", "fillOpacity": 0.4}},
      {"id": "stroget", "lat": 55.6784, "lng": 12.5755, "title": "Kaffa Strøget"},
      {"id": "amagertorv", "lat": 55.6786, "lng": 12.579, "title": "Kaffa Amagertorv"},
      {"id": "kobmagergade", "lat": 55.6807, "lng": 12.5773, "title": "Kaffa Købmagergade"},
      {"id": "gammeltorv", "lat": 55.6775, "lng": 12.5725, "title": "Kaffa Gammeltorv"},
      {"id": "nikolaj", "lat": 55.6789, "lng": 12.5822, "title": "Kaffa Nikolaj"},
      {"id": "christianshavn", "lat": 55.6729, "lng": 12.5935, "title": "Kaffa Christianshavn"},
      {"id": "torvegade", "lat": 55.672, "lng": 12.591, "title": "Kaffa Torvegade"},
      {"id": "overgaden", "lat": 55.6735, "lng": 12.596, "title": "Kaffa Overgaden"},
      {"id": "vesterbro", "lat": 55.6704, "lng": 12.556, "title": "Kaffa Vesterbro"},
      {"id": "norrebro", "lat": 55.692, "lng": 12.556, "title": "Kaffa Nørrebro"}
    ]
  </script>
</maplace-map>

How it works

One palette across the map: the delivery areas, the cluster badge and the list, each through its own hook.

  • HTML: the areas’ fields in a <script type="application/json"> inside <maplace-map>, as a polygon’s path takes more than an attribute (Data); a circle written as a <maplace-location> takes them as shape-style, hovered-style and selected-style. cluster on the map, on maplace-element-cluster.iife.js on Google.
  • Script and Bundler: style, hoveredStyle and selectedStyle on each location, in hex, as every provider reads them (Styles), with cluster: true in the options, on the cluster script for the Script version on Google.
  • React: the same locations, and the cluster prop of <MaplaceProvider>.
  • In every version: the badge takes --maplace-cluster-background and --maplace-cluster-color on the map or any element around it (Cluster badges), and the list the page’s rules on .maplace-option[data-hovered] and .maplace-option[data-selected]; Maplace.js’s own rules are in :where(), so any of yours wins (Styling). The single shops keep Maplace.js’s default pin; for pins in the brand’s colours, the --maplace-pin-* properties (Pin colours), or an icon of your own, as in HTML markers with CSS states.