Brand colours
One palette across the delivery areas, the cluster badges and the list.
Map and code
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><!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-cluster.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-map { --maplace-cluster-background: #3b2416; --maplace-cluster-color: #f5ead9; }
#brand-map .maplace-option[data-hovered] { background: #f5ead9; color: #3b2416; }
#brand-map .maplace-option[data-selected] { background: #23735a; color: #fff; }
</style>
<maplace-map id="brand-map" api-key="YOUR_KEY" 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><!doctype html>
<!-- A page of your own script: the MapLibre CDN script, which bundles maplibre-gl, its stylesheet and its clustering, what the map and its list mount on, and the map made with Maplace; one palette across the areas, the cluster badge and the list. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<style>
#brand-maplibre-script-map-and-list { display: flex; height: 24rem; --maplace-cluster-background: #3b2416; --maplace-cluster-color: #f5ead9; }
#brand-maplibre-script-map { flex: 1 1 auto; min-width: 0; }
#brand-maplibre-script-list { display: contents; }
#brand-maplibre-script-list [role="listbox"] { flex: 0 1 16rem; }
/* On a phone the list goes under the map, as the element's does. */
@media (width < 40rem) {
#brand-maplibre-script-map-and-list { flex-direction: column; }
#brand-maplibre-script-list [role="listbox"] { flex: none; max-height: 40%; }
}
#brand-maplibre-script-map-and-list .maplace-option[data-hovered] { background: #f5ead9; color: #3b2416; }
#brand-maplibre-script-map-and-list .maplace-option[data-selected] { background: #23735a; color: #fff; }
</style>
<div id="brand-maplibre-script-map-and-list">
<div id="brand-maplibre-script-map"></div>
<div id="brand-maplibre-script-list"></div>
</div>
<script type="module">
/**
* The brand's palette on a delivery area, at rest, hovered and selected: hex colours, which every
* provider reads (a CSS variable is the page's, not the map's).
*/
const AREA = {
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 },
};
const locations = [
{ 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 }], ...AREA },
{ 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 }], ...AREA },
{ 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" },
];
Maplace.createMapLibreMap("#brand-maplibre-script-map", {
locations,
cluster: true,
list: { container: "#brand-maplibre-script-list" },
});
</script><!doctype html>
<!-- A page of your own script: the cluster CDN script, which bundles @googlemaps/markerclusterer, what the map and its list mount on, and the map made with Maplace, which adds Maps JS with your key; one palette across the areas, the cluster badge and the list. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-cluster.iife.js"></script>
<style>
#brand-script-map-and-list { display: flex; height: 24rem; --maplace-cluster-background: #3b2416; --maplace-cluster-color: #f5ead9; }
#brand-script-map { flex: 1 1 auto; min-width: 0; }
#brand-script-list { display: contents; }
#brand-script-list [role="listbox"] { flex: 0 1 16rem; }
/* On a phone the list goes under the map, as the element's does. */
@media (width < 40rem) {
#brand-script-map-and-list { flex-direction: column; }
#brand-script-list [role="listbox"] { flex: none; max-height: 40%; }
}
#brand-script-map-and-list .maplace-option[data-hovered] { background: #f5ead9; color: #3b2416; }
#brand-script-map-and-list .maplace-option[data-selected] { background: #23735a; color: #fff; }
</style>
<div id="brand-script-map-and-list">
<div id="brand-script-map"></div>
<div id="brand-script-list"></div>
</div>
<script type="module">
/**
* The brand's palette on a delivery area, at rest, hovered and selected: hex colours, which every
* provider reads (a CSS variable is the page's, not the map's).
*/
const AREA = {
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 },
};
const locations = [
{ 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 }], ...AREA },
{ 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 }], ...AREA },
{ 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" },
];
Maplace.createGoogleMap("#brand-script-map", {
apiKey: "YOUR_KEY",
locations,
cluster: true,
list: { container: "#brand-script-list" },
});
</script><!doctype html>
<!-- The page vanilla.ts runs on: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<style>
#brand-maplibre-vanilla-map-and-list { display: flex; height: 24rem; --maplace-cluster-background: #3b2416; --maplace-cluster-color: #f5ead9; }
#brand-maplibre-vanilla-map { flex: 1 1 auto; min-width: 0; }
#brand-maplibre-vanilla-list { display: contents; }
#brand-maplibre-vanilla-list [role="listbox"] { flex: 0 1 16rem; }
/* On a phone the list goes under the map, as the element's does. */
@media (width < 40rem) {
#brand-maplibre-vanilla-map-and-list { flex-direction: column; }
#brand-maplibre-vanilla-list [role="listbox"] { flex: none; max-height: 40%; }
}
#brand-maplibre-vanilla-map-and-list .maplace-option[data-hovered] { background: #f5ead9; color: #3b2416; }
#brand-maplibre-vanilla-map-and-list .maplace-option[data-selected] { background: #23735a; color: #fff; }
</style>
<div id="brand-maplibre-vanilla-map-and-list">
<div id="brand-maplibre-vanilla-map"></div>
<div id="brand-maplibre-vanilla-list"></div>
</div>
<script type="module" src="./vanilla.ts"></script>import "maplibre-gl/dist/maplibre-gl.css";
import type { Location } from "@maplacejs/maplace";
import { createMapLibreMap } from "@maplacejs/maplace/maplibre";
/**
* The brand's palette on a delivery area, at rest, hovered and selected: hex colours, which every
* provider reads (a CSS variable is the page's, not the map's).
*/
const AREA = {
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 },
};
const locations: Location[] = [
{
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 },
],
...AREA,
},
{
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 },
],
...AREA,
},
{ 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" },
];
createMapLibreMap("#brand-maplibre-vanilla-map", {
locations,
cluster: true,
list: { container: "#brand-maplibre-vanilla-list" },
});<!doctype html>
<!-- The page vanilla.ts runs on: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->Google's bootstrap loader, with your API key: from Google's docs
<script>
(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
key: "YOUR_KEY",
v: "weekly",
});
</script><style>
#brand-vanilla-map-and-list { display: flex; height: 24rem; --maplace-cluster-background: #3b2416; --maplace-cluster-color: #f5ead9; }
#brand-vanilla-map { flex: 1 1 auto; min-width: 0; }
#brand-vanilla-list { display: contents; }
#brand-vanilla-list [role="listbox"] { flex: 0 1 16rem; }
/* On a phone the list goes under the map, as the element's does. */
@media (width < 40rem) {
#brand-vanilla-map-and-list { flex-direction: column; }
#brand-vanilla-list [role="listbox"] { flex: none; max-height: 40%; }
}
#brand-vanilla-map-and-list .maplace-option[data-hovered] { background: #f5ead9; color: #3b2416; }
#brand-vanilla-map-and-list .maplace-option[data-selected] { background: #23735a; color: #fff; }
</style>
<div id="brand-vanilla-map-and-list">
<div id="brand-vanilla-map"></div>
<div id="brand-vanilla-list"></div>
</div>
<script type="module" src="./vanilla.ts"></script>import type { Location } from "@maplacejs/maplace";
import { createGoogleMap } from "@maplacejs/maplace/google";
/**
* The brand's palette on a delivery area, at rest, hovered and selected: hex colours, which every
* provider reads (a CSS variable is the page's, not the map's).
*/
const AREA = {
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 },
};
const locations: Location[] = [
{
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 },
],
...AREA,
},
{
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 },
],
...AREA,
},
{ 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" },
];
createGoogleMap("#brand-vanilla-map", {
locations,
cluster: true,
list: { container: "#brand-vanilla-list" },
});<!doctype html>
<!-- The page react.tsx renders into: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<style>
#brand-maplibre-react-root .map-and-list { display: flex; height: 24rem; --maplace-cluster-background: #3b2416; --maplace-cluster-color: #f5ead9; }
#brand-maplibre-react-root .map { flex: 1 1 auto; min-width: 0; }
#brand-maplibre-react-root [role="listbox"] { flex: 0 1 16rem; }
/* On a phone the list goes under the map, as the element's does. */
@media (width < 40rem) {
#brand-maplibre-react-root .map-and-list { flex-direction: column; }
#brand-maplibre-react-root [role="listbox"] { flex: none; max-height: 40%; }
}
#brand-maplibre-react-root .maplace-option[data-hovered] { background: #f5ead9; color: #3b2416; }
#brand-maplibre-react-root .maplace-option[data-selected] { background: #23735a; color: #fff; }
</style>
<div id="brand-maplibre-react-root"></div>
<script type="module" src="./react.tsx"></script>import "maplibre-gl/dist/maplibre-gl.css";
import type { Location } from "@maplacejs/maplace";
import { createMapLibreAdapter } from "@maplacejs/maplace/maplibre";
import { LocationList, MaplaceMap, MaplaceProvider } from "@maplacejs/maplace/react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
/**
* The brand's palette on a delivery area, at rest, hovered and selected: hex colours, which every
* provider reads (a CSS variable is the page's, not the map's).
*/
const AREA = {
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 },
};
const locations: Location[] = [
{
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 },
],
...AREA,
},
{
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 },
],
...AREA,
},
{ 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" },
];
function Brand() {
return (
<MaplaceProvider locations={locations} cluster>
<div className="map-and-list">
<MaplaceMap createAdapter={createMapLibreAdapter} className="map" />
<LocationList />
</div>
</MaplaceProvider>
);
}
createRoot(document.getElementById("brand-maplibre-react-root") as HTMLElement).render(
<StrictMode>
<Brand />
</StrictMode>,
);<!doctype html>
<!-- The page react.tsx renders into: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->Google's bootstrap loader, with your API key: from Google's docs
<script>
(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
key: "YOUR_KEY",
v: "weekly",
});
</script><style>
#brand-react-root .map-and-list { display: flex; height: 24rem; --maplace-cluster-background: #3b2416; --maplace-cluster-color: #f5ead9; }
#brand-react-root .map { flex: 1 1 auto; min-width: 0; }
#brand-react-root [role="listbox"] { flex: 0 1 16rem; }
/* On a phone the list goes under the map, as the element's does. */
@media (width < 40rem) {
#brand-react-root .map-and-list { flex-direction: column; }
#brand-react-root [role="listbox"] { flex: none; max-height: 40%; }
}
#brand-react-root .maplace-option[data-hovered] { background: #f5ead9; color: #3b2416; }
#brand-react-root .maplace-option[data-selected] { background: #23735a; color: #fff; }
</style>
<div id="brand-react-root"></div>
<script type="module" src="./react.tsx"></script>import type { Location } from "@maplacejs/maplace";
import { createGoogleAdapter } from "@maplacejs/maplace/google";
import { LocationList, MaplaceMap, MaplaceProvider } from "@maplacejs/maplace/react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
/**
* The brand's palette on a delivery area, at rest, hovered and selected: hex colours, which every
* provider reads (a CSS variable is the page's, not the map's).
*/
const AREA = {
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 },
};
const locations: Location[] = [
{
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 },
],
...AREA,
},
{
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 },
],
...AREA,
},
{ 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" },
];
function Brand() {
return (
<MaplaceProvider locations={locations} cluster>
<div className="map-and-list">
<MaplaceMap createAdapter={createGoogleAdapter} className="map" />
<LocationList />
</div>
</MaplaceProvider>
);
}
createRoot(document.getElementById("brand-react-root") as HTMLElement).render(
<StrictMode>
<Brand />
</StrictMode>,
);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 asshape-style,hovered-styleandselected-style.clusteron the map, onmaplace-element-cluster.iife.json Google. - Script and Bundler:
style,hoveredStyleandselectedStyleon each location, in hex, as every provider reads them (Styles), withcluster: truein the options, on the cluster script for the Script version on Google. - React: the same locations, and the
clusterprop of<MaplaceProvider>. - In every version: the badge takes
--maplace-cluster-backgroundand--maplace-cluster-coloron 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 aniconof your own, as in HTML markers with CSS states.