Search this area
A switch above the list: every place, or only those in view as the map moves.
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>
<!-- A list on the map that follows it: its switch lists "All", or in "This area" what is in view as the map moves. -->
<maplace-map id="this-area-maplibre-map" list list-position="top-left" list-scope="viewport">
<maplace-location location-id="lisbon" lat="38.7223" lng="-9.1393" title="Lisbon"></maplace-location>
<maplace-location location-id="madrid" lat="40.4168" lng="-3.7038" title="Madrid"></maplace-location>
<maplace-location location-id="paris" lat="48.8566" lng="2.3522" title="Paris"></maplace-location>
<maplace-location location-id="brussels" lat="50.8503" lng="4.3517" title="Brussels"></maplace-location>
<maplace-location location-id="amsterdam" lat="52.3676" lng="4.9041" title="Amsterdam"></maplace-location>
<maplace-location location-id="berlin" lat="52.52" lng="13.405" title="Berlin"></maplace-location>
<maplace-location location-id="copenhagen" lat="55.6761" lng="12.5683" title="Copenhagen"></maplace-location>
<maplace-location location-id="vienna" lat="48.2082" lng="16.3738" title="Vienna"></maplace-location>
<maplace-location location-id="prague" lat="50.0755" lng="14.4378" title="Prague"></maplace-location>
<maplace-location location-id="warsaw" lat="52.2297" lng="21.0122" title="Warsaw"></maplace-location>
<maplace-location location-id="rome" lat="41.9028" lng="12.4964" title="Rome"></maplace-location>
<maplace-location location-id="athens" lat="37.9838" lng="23.7275" title="Athens"></maplace-location>
</maplace-map><!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element.iife.js"></script>
<!-- A list on the map that follows it: its switch lists "All", or in "This area" what is in view as the map moves. -->
<maplace-map id="this-area-map" api-key="YOUR_KEY" list list-position="top-left" list-scope="viewport">
<maplace-location location-id="lisbon" lat="38.7223" lng="-9.1393" title="Lisbon"></maplace-location>
<maplace-location location-id="madrid" lat="40.4168" lng="-3.7038" title="Madrid"></maplace-location>
<maplace-location location-id="paris" lat="48.8566" lng="2.3522" title="Paris"></maplace-location>
<maplace-location location-id="brussels" lat="50.8503" lng="4.3517" title="Brussels"></maplace-location>
<maplace-location location-id="amsterdam" lat="52.3676" lng="4.9041" title="Amsterdam"></maplace-location>
<maplace-location location-id="berlin" lat="52.52" lng="13.405" title="Berlin"></maplace-location>
<maplace-location location-id="copenhagen" lat="55.6761" lng="12.5683" title="Copenhagen"></maplace-location>
<maplace-location location-id="vienna" lat="48.2082" lng="16.3738" title="Vienna"></maplace-location>
<maplace-location location-id="prague" lat="50.0755" lng="14.4378" title="Prague"></maplace-location>
<maplace-location location-id="warsaw" lat="52.2297" lng="21.0122" title="Warsaw"></maplace-location>
<maplace-location location-id="rome" lat="41.9028" lng="12.4964" title="Rome"></maplace-location>
<maplace-location location-id="athens" lat="37.9838" lng="23.7275" title="Athens"></maplace-location>
</maplace-map><!doctype html>
<!-- A page of your own script: the MapLibre CDN script, which bundles maplibre-gl and its stylesheet, what the map mounts on, and the map made with Maplace. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<style>
#this-area-maplibre-script-map { height: 24rem; }
</style>
<div id="this-area-maplibre-script-map"></div>
<script type="module">
Maplace.createMapLibreMap("#this-area-maplibre-script-map", {
locations: [
{ id: "lisbon", lat: 38.7223, lng: -9.1393, title: "Lisbon" },
{ id: "madrid", lat: 40.4168, lng: -3.7038, title: "Madrid" },
{ id: "paris", lat: 48.8566, lng: 2.3522, title: "Paris" },
{ id: "brussels", lat: 50.8503, lng: 4.3517, title: "Brussels" },
{ id: "amsterdam", lat: 52.3676, lng: 4.9041, title: "Amsterdam" },
{ id: "berlin", lat: 52.52, lng: 13.405, title: "Berlin" },
{ id: "copenhagen", lat: 55.6761, lng: 12.5683, title: "Copenhagen" },
{ id: "vienna", lat: 48.2082, lng: 16.3738, title: "Vienna" },
{ id: "prague", lat: 50.0755, lng: 14.4378, title: "Prague" },
{ id: "warsaw", lat: 52.2297, lng: 21.0122, title: "Warsaw" },
{ id: "rome", lat: 41.9028, lng: 12.4964, title: "Rome" },
{ id: "athens", lat: 37.9838, lng: 23.7275, title: "Athens" },
],
list: { scope: "viewport", position: "top-left" },
});
</script><!doctype html>
<!-- A page of your own script: the CDN script, what the map mounts on, and the map made with Maplace, which adds Maps JS with your key. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element.iife.js"></script>
<style>
#this-area-script-map { height: 24rem; }
</style>
<div id="this-area-script-map"></div>
<script type="module">
Maplace.createGoogleMap("#this-area-script-map", {
apiKey: "YOUR_KEY",
locations: [
{ id: "lisbon", lat: 38.7223, lng: -9.1393, title: "Lisbon" },
{ id: "madrid", lat: 40.4168, lng: -3.7038, title: "Madrid" },
{ id: "paris", lat: 48.8566, lng: 2.3522, title: "Paris" },
{ id: "brussels", lat: 50.8503, lng: 4.3517, title: "Brussels" },
{ id: "amsterdam", lat: 52.3676, lng: 4.9041, title: "Amsterdam" },
{ id: "berlin", lat: 52.52, lng: 13.405, title: "Berlin" },
{ id: "copenhagen", lat: 55.6761, lng: 12.5683, title: "Copenhagen" },
{ id: "vienna", lat: 48.2082, lng: 16.3738, title: "Vienna" },
{ id: "prague", lat: 50.0755, lng: 14.4378, title: "Prague" },
{ id: "warsaw", lat: 52.2297, lng: 21.0122, title: "Warsaw" },
{ id: "rome", lat: 41.9028, lng: 12.4964, title: "Rome" },
{ id: "athens", lat: 37.9838, lng: 23.7275, title: "Athens" },
],
list: { scope: "viewport", position: "top-left" },
});
</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>
#this-area-maplibre-vanilla-map { height: 24rem; }
</style>
<div id="this-area-maplibre-vanilla-map"></div>
<script type="module" src="./vanilla.ts"></script>import "maplibre-gl/dist/maplibre-gl.css";
import { createMapLibreMap } from "@maplacejs/maplace/maplibre";
createMapLibreMap("#this-area-maplibre-vanilla-map", {
locations: [
{ id: "lisbon", lat: 38.7223, lng: -9.1393, title: "Lisbon" },
{ id: "madrid", lat: 40.4168, lng: -3.7038, title: "Madrid" },
{ id: "paris", lat: 48.8566, lng: 2.3522, title: "Paris" },
{ id: "brussels", lat: 50.8503, lng: 4.3517, title: "Brussels" },
{ id: "amsterdam", lat: 52.3676, lng: 4.9041, title: "Amsterdam" },
{ id: "berlin", lat: 52.52, lng: 13.405, title: "Berlin" },
{ id: "copenhagen", lat: 55.6761, lng: 12.5683, title: "Copenhagen" },
{ id: "vienna", lat: 48.2082, lng: 16.3738, title: "Vienna" },
{ id: "prague", lat: 50.0755, lng: 14.4378, title: "Prague" },
{ id: "warsaw", lat: 52.2297, lng: 21.0122, title: "Warsaw" },
{ id: "rome", lat: 41.9028, lng: 12.4964, title: "Rome" },
{ id: "athens", lat: 37.9838, lng: 23.7275, title: "Athens" },
],
// On the map, top-left: a list switched between "All" and "This area", what is in view.
list: { scope: "viewport", position: "top-left" },
});<!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>
#this-area-vanilla-map { height: 24rem; }
</style>
<div id="this-area-vanilla-map"></div>
<script type="module" src="./vanilla.ts"></script>import { createGoogleMap } from "@maplacejs/maplace/google";
createGoogleMap("#this-area-vanilla-map", {
locations: [
{ id: "lisbon", lat: 38.7223, lng: -9.1393, title: "Lisbon" },
{ id: "madrid", lat: 40.4168, lng: -3.7038, title: "Madrid" },
{ id: "paris", lat: 48.8566, lng: 2.3522, title: "Paris" },
{ id: "brussels", lat: 50.8503, lng: 4.3517, title: "Brussels" },
{ id: "amsterdam", lat: 52.3676, lng: 4.9041, title: "Amsterdam" },
{ id: "berlin", lat: 52.52, lng: 13.405, title: "Berlin" },
{ id: "copenhagen", lat: 55.6761, lng: 12.5683, title: "Copenhagen" },
{ id: "vienna", lat: 48.2082, lng: 16.3738, title: "Vienna" },
{ id: "prague", lat: 50.0755, lng: 14.4378, title: "Prague" },
{ id: "warsaw", lat: 52.2297, lng: 21.0122, title: "Warsaw" },
{ id: "rome", lat: 41.9028, lng: 12.4964, title: "Rome" },
{ id: "athens", lat: 37.9838, lng: 23.7275, title: "Athens" },
],
// On the map, top-left: a list switched between "All" and "This area", what is in view.
list: { scope: "viewport", position: "top-left" },
});<!doctype html>
<!-- The page react.tsx renders into: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<style>
#this-area-maplibre-react-root .map { height: 24rem; }
</style>
<div id="this-area-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";
const capitals: Location[] = [
{ id: "lisbon", lat: 38.7223, lng: -9.1393, title: "Lisbon" },
{ id: "madrid", lat: 40.4168, lng: -3.7038, title: "Madrid" },
{ id: "paris", lat: 48.8566, lng: 2.3522, title: "Paris" },
{ id: "brussels", lat: 50.8503, lng: 4.3517, title: "Brussels" },
{ id: "amsterdam", lat: 52.3676, lng: 4.9041, title: "Amsterdam" },
{ id: "berlin", lat: 52.52, lng: 13.405, title: "Berlin" },
{ id: "copenhagen", lat: 55.6761, lng: 12.5683, title: "Copenhagen" },
{ id: "vienna", lat: 48.2082, lng: 16.3738, title: "Vienna" },
{ id: "prague", lat: 50.0755, lng: 14.4378, title: "Prague" },
{ id: "warsaw", lat: 52.2297, lng: 21.0122, title: "Warsaw" },
{ id: "rome", lat: 41.9028, lng: 12.4964, title: "Rome" },
{ id: "athens", lat: 37.9838, lng: 23.7275, title: "Athens" },
];
function ThisArea() {
return (
<MaplaceProvider locations={capitals}>
<MaplaceMap createAdapter={createMapLibreAdapter} className="map">
{/* A list switched between "All" and "This area", what is in view as the map moves. */}
<LocationList scope="viewport" position="top-left" />
</MaplaceMap>
</MaplaceProvider>
);
}
createRoot(document.getElementById("this-area-maplibre-react-root") as HTMLElement).render(
<StrictMode>
<ThisArea />
</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>
#this-area-react-root .map { height: 24rem; }
</style>
<div id="this-area-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";
const capitals: Location[] = [
{ id: "lisbon", lat: 38.7223, lng: -9.1393, title: "Lisbon" },
{ id: "madrid", lat: 40.4168, lng: -3.7038, title: "Madrid" },
{ id: "paris", lat: 48.8566, lng: 2.3522, title: "Paris" },
{ id: "brussels", lat: 50.8503, lng: 4.3517, title: "Brussels" },
{ id: "amsterdam", lat: 52.3676, lng: 4.9041, title: "Amsterdam" },
{ id: "berlin", lat: 52.52, lng: 13.405, title: "Berlin" },
{ id: "copenhagen", lat: 55.6761, lng: 12.5683, title: "Copenhagen" },
{ id: "vienna", lat: 48.2082, lng: 16.3738, title: "Vienna" },
{ id: "prague", lat: 50.0755, lng: 14.4378, title: "Prague" },
{ id: "warsaw", lat: 52.2297, lng: 21.0122, title: "Warsaw" },
{ id: "rome", lat: 41.9028, lng: 12.4964, title: "Rome" },
{ id: "athens", lat: 37.9838, lng: 23.7275, title: "Athens" },
];
function ThisArea() {
return (
<MaplaceProvider locations={capitals}>
<MaplaceMap createAdapter={createGoogleAdapter} className="map">
{/* A list switched between "All" and "This area", what is in view as the map moves. */}
<LocationList scope="viewport" position="top-left" />
</MaplaceMap>
</MaplaceProvider>
);
}
createRoot(document.getElementById("this-area-react-root") as HTMLElement).render(
<StrictMode>
<ThisArea />
</StrictMode>,
);How it works
The list on the map, top left, has a switch above it: every place, or only those in view as the map moves.
- HTML:
list-scope="viewport"on<maplace-map>, besidelistandlist-position, witharea-only-label,show-all-labelandempty-area-labelfor its wording (Map attributes). - Script and Bundler:
list: { scope: "viewport", position: "top-left" }in the map’s options, withareaOnlyLabel,showAllLabelandemptyAreaLabel(List view options;position, on Google, on MapLibre). - React:
<LocationList scope="viewport" position="top-left" />inside the<MaplaceMap>(<LocationList>). - Its corner: any of the four,
top-lefthere. Left of the map is where a list has the most room on Google, which stacks its fullscreen button, camera control and Pegman on the right (On-map controls). Without aposition, the list goes top right.