0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
A zero-dependency map component using OpenStreetMap or CARTO tiles (or your own tile proxy). Renders a static map centred on given coordinates with a marker pin and address caption, and lazy-loads an accessible pan / zoom mode.
Overview
The <geo-map> component displays a map from free raster tiles. It computes the tiles needed to cover its box from lat/lng/zoom, re-lays them out when the element is resized, and draws a marker at the centre. Activating the map lazy-loads pan and zoom.
Key features:
Zero dependencies — no API keys, no external libraries
OpenStreetMap or CARTO tiles, or your own tile proxy, each with the credit its terms require
<!-- OpenStreetMap (default) --><geo-maplat="51.5007"lng="-0.1246"zoom="15"provider="osm"></geo-map><!-- CARTO light / dark --><geo-maplat="51.5007"lng="-0.1246"zoom="15"provider="carto-light"></geo-map><geo-maplat="51.5007"lng="-0.1246"zoom="15"provider="carto-dark"></geo-map><!-- CARTO, following the page's light / dark mode --><geo-maplat="51.5007"lng="-0.1246"zoom="15"provider="carto-auto"></geo-map>
Your Own Tiles and Attribution
For privacy, swappability, caching control, or rate limiting, point <geo-map> at your own endpoint. tile-url takes a URL template; every {z}, {x}, {y} is substituted, {s} rotates through subdomains a/b/c, and {r} becomes @2x on high-density screens. See Server-Side Service Facade for a Cloudflare Worker that proxies and caches OSM tiles.
A tile-url source has no built-in credit — supply the credit its licence needs with attribution (and attribution-href), or slot your own element with slot="attribution". If you proxy OpenStreetMap, credit OpenStreetMap.
By default the static map fetches its tiles as soon as it is near the viewport, even with interactive="click". Each tile request sends the visitor’s IP address and the page as referrer to the tile host:
osm: https://tile.openstreetmap.org
carto-*: https://basemaps.cartocdn.com
tile-url: whatever host you configure (nothing third-party if it is same-origin)
With a Content Security Policy, allow the tile host in img-src (for example img-src 'self' https://tile.openstreetmap.org). The component adopts its styles as a constructable stylesheet, so it does not need style-src 'unsafe-inline' in browsers that support adoptedStyleSheets.
Set loading="consent" to show a placeholder naming the tile host instead; no tile is requested until the user presses “Load map” (which then also activates interactive mode). Hovering or focusing that button preconnects to the tile host. Keep a link in the slotted address so the placeholder is still useful.
Load tiles only after consent
<geo-maplat="48.8584"lng="2.2945"zoom="16"loading="consent"><address><ahref="https://www.openstreetmap.org/?mlat=48.8584&mlon=2.2945#map=16/48.8584/2.2945"> Eiffel Tower, Champ de Mars, 75007 Paris</a></address></geo-map>
Marker
The marker pin is an SVG drawn at the centre of the map. By default it uses the theme’s --color-error; set --geo-map-marker-color in CSS for a site-wide colour, marker-color for one map, or hide it with marker="false".
Slot an <address> (or any content) as a caption at the bottom of the map. It is also the no-JS fallback and, by default, the map’s accessible name (“Map of …”). Links in the caption stay clickable above the activation surface.
Caption slot
1234567891011
<!-- Slotted address as caption --><geo-maplat="48.8584"lng="2.2945"zoom="16"><address><strong>Eiffel Tower</strong><br/> Champ de Mars, 5 Av. Anatole France<br/> 75007 Paris, France</address></geo-map><!-- No caption: name it with label --><geo-maplat="48.8584"lng="2.2945"zoom="16"label="Eiffel Tower and Champ de Mars"></geo-map>
No-JS Fallback
Before the component upgrades, the slotted content is visible as a styled card. Include a link to OpenStreetMap so users can still find the location.
Progressive enhancement
123456789
<!-- Before JS loads, the address is visible and clickable --><geo-maplat="40.7484"lng="-73.9857"zoom="15"><address><ahref="https://www.openstreetmap.org/?mlat=40.7484&mlon=-73.9857#map=15/40.7484/-73.9857"> Empire State Building<br/> 20 W 34th St, New York, NY 10001</a></address></geo-map>
Data Binding
Coordinates can come from 6 sources, checked in priority order. The first match wins:
Explicit lat/lng attributes — highest priority
src → <address data-lat data-lng> — reference an external address element by ID
src → <script type="application/ld+json"> — reference a JSON-LD script by ID
Slotted <address data-lat data-lng> — address inside the component
placeattribute — scans all JSON-LD scripts for a matching name
<meta name="geo.position"> — page-level fallback
src → address element
Point src to the ID of an <address> element with data-lat and data-lng attributes. The address stays visible as semantic content while the map reads its coordinates.
src → address
12345678
<!-- External address element with data-lat/data-lng --><addressid="office"data-lat="40.7484"data-lng="-73.9857"><strong>Empire State Building</strong><br/> 20 W 34th St, New York, NY 10001</address><!-- Map resolves coordinates from the address --><geo-mapsrc="office"zoom="15"></geo-map>
src → JSON-LD script
Point src to the ID of a <script type="application/ld+json"> element. The component reads geo.latitude and geo.longitude from the parsed JSON.
src → JSON-LD
12345678910111213141516
<!-- JSON-LD with geo coordinates --><scripttype="application/ld+json"id="place-data">{"@context": "https://schema.org","@type": "Place","name": "Eiffel Tower","geo": {"@type": "GeoCoordinates","latitude": 48.8584,"longitude": 2.2945 }}</script><!-- Map resolves coordinates from the JSON-LD script --><geo-mapsrc="place-data"zoom="16"></geo-map>
Slotted <address> with coordinates
Slot an <address> with data-lat and data-lng directly inside the component. The address appears as a caption and also provides the coordinates.
Slotted address
1234567
<!-- Slotted address with data-lat/data-lng --><geo-mapzoom="15"><addressdata-lat="51.5007"data-lng="-0.1246"><strong>Big Ben</strong><br/> Westminster, London SW1A 0AA</address></geo-map>
place attribute
Set place to a name that matches the name field in a JSON-LD Place script anywhere on the page. Useful when structured data already exists for SEO.
place attribute
12345678910111213141516
<!-- JSON-LD somewhere on the page --><scripttype="application/ld+json">{"@context": "https://schema.org","@type": "Place","name": "The Hi-Dive","geo": {"@type": "GeoCoordinates","latitude": 39.7316,"longitude": -104.9878 }}</script><!-- Map finds JSON-LD by matching the place name --><geo-mapplace="The Hi-Dive"zoom="16"></geo-map>
<meta> fallback
As a last resort, the component checks for a <meta name="geo.position"> tag in the document. The content format is "lat;lng".
Meta fallback
12345
<!-- In the document <head> --><metaname="geo.position"content="40.7484;-73.9857"/><!-- Map with no explicit coordinates falls back to meta --><geo-mapzoom="15"></geo-map>
JavaScript API
.data reads the map state; assigning a partial object writes the attributes as one batch and re-renders once. Assigning the current state is a no-op, an invalid markerColor is ignored, and '' clears it.
Property
Type
Description
data
{ lat, lng, zoom, marker, markerColor }
Get, or assign (partial) to update. Emits geo-map:data-changed.
markers
Array<{ lat, lng, color }>
Read-only. The centre marker as a one-element array, or [] without coordinates.
active
Boolean
Read-only. True in interactive mode (also :state(active)).
With the default interactive="click" the whole map surface is the activation target: click or tap anywhere, or Tab to the “Activate interactive map” button and press Enter. On touch screens the button is always visible. Activation lazy-loads the pan / zoom layer and moves focus to the map.
In interactive mode you can drag to pan, click a point to centre the map on it (a single-pointer alternative to dragging), pinch with two fingers, scroll, or use the on-screen + / −, recenter and exit buttons. Use interactive="eager" to activate on load, or interactive="none" / static-only for a static map.
Interactive variants
1234567891011
<!-- Default: activate first --><geo-maplat="40.7484"lng="-73.9857"zoom="15"><address>Empire State Building, New York</address></geo-map><!-- Eager: interactive on load (focus is not moved) --><geo-maplat="48.8584"lng="2.2945"zoom="14"interactive="eager"></geo-map><!-- Static --><geo-maplat="51.5007"lng="-0.1246"zoom="15"interactive="none"></geo-map><geo-maplat="35.6762"lng="139.6503"zoom="13"static-only></geo-map>
Keyboard
Key
Action
Arrow keys
Pan the map
+ / =
Zoom in
-
Zoom out
Home / 0
Recenter on the original location and zoom
Escape
Exit interactive mode; focus returns to the activate button
Tab
Move between the map and the zoom / recenter / exit buttons
Named image (static) or focusable map region (interactive)
tiles
Tile layer
Translated layer holding the tile images
marker
SVG pin
Marker styling
overlay
Activation surface
Full-surface click target containing the activate button
activate
Button
Activate (or, in consent mode, “Load map”) button
consent-note
Paragraph
Names the tile host in consent mode
controls
Button group
On-screen controls (interactive mode)
control
Button
Every control button; also zoom-in, zoom-out, recenter, exit
caption
Slot wrapper
Address / label display
attribution
Credit
Provider credit, attribution text, or the attribution slot
status
Live region
Visually hidden pan / zoom announcements
Localisation
Every built-in string is overridable with a data-label-*attribute: map, map-of ({name}), activate, consent, consent-note ({host}), zoom-in, zoom-out, recenter, exit, controls, instructions, moved ({lat}, {lng}, {zoom}), error-coords and error-tiles.
French strings
<geo-maplat="48.8584"lng="2.2945"zoom="16"data-label-map-of="Carte : {name}"data-label-activate="Activer la carte interactive"data-label-zoom-in="Zoom avant"data-label-zoom-out="Zoom arrière"data-label-recenter="Recentrer"data-label-exit="Quitter la carte"data-label-moved="Carte centrée sur {lat}, {lng}, zoom {zoom}"><address>Tour Eiffel, Paris</address></geo-map>
Events
Event
Detail
Description
geo-map:ready
{ lat, lng, zoom }
Static tiles finished loading (data-ready is set)
geo-map:activate
{ lat, lng, zoom }
Interactive mode started
geo-map:move
{ lat, lng, zoom }
After a pan or zoom in interactive mode (new centre)
geo-map:data-changed
{ data, source: 'property' }
After a .data assignment that changed something
geo-map:error
{ message }
No coordinates resolved, or every tile failed to load
A common use case: pair <geo-map> with a contact form in a sidebar layout.
Contact form with map
1234567891011121314151617181920212223
<layout-sidebardata-layout-gap="xl"data-layout-sidebar-width="wide"><formaction="/contact"method="POST"data-layout="stack"data-layout-gap="l"><h2>Send a message</h2><form-field><labelfor="name">Name</label><inputtype="text"id="name"name="name"required/></form-field><form-field><labelfor="message">Message</label><textareaid="message"name="message"rows="4"required></textarea></form-field><buttontype="submit">Send message</button></form><aside><geo-maplat="37.7749"lng="-122.4194"zoom="14"><address> 123 Business Ave<br/> San Francisco, CA 94102</address></geo-map></aside></layout-sidebar>
The static map is an image named from label, the slotted <address>, the src name, or place — not raw coordinates.
The activate button’s accessible name is its visible text; on touch screens it is always visible, and the whole map surface activates.
In interactive mode the map is a focusable region with aria-roledescription="map", instructions via aria-describedby, and a polite live region announcing the new centre and zoom.
Single-pointer alternatives to dragging and pinching: click-to-centre and the on-screen zoom, recenter and exit buttons (WCAG 2.5.7). All controls work from the keyboard.
The marker is decorative (aria-hidden); attribution links open in a new tab.
Limits to be aware of:
Raster tiles are pictures: street names and landmarks on the map are not available to screen readers. Always put the address (and ideally a link to a full map service or directions) in the slotted <address> — that text, not the map, is the accessible content.
Tile colours come from the provider and are not themed; check that your marker colour contrasts with the tiles you use, and prefer carto-auto for dark pages.
Announcements report coordinates, not place names (there is no geocoding).