Primitives

Map

Interactive Leaflet map powered by OpenStreetMap — no API key required

The Map component renders a fully interactive map using Leaflet.js and OpenStreetMap tiles. No API key is ever required. Supports markers with optional popup labels, three free tile layers, and fully configurable dimensions.

Leaflet and its tiles load only when a map comes within 200px of the viewport. Once a map is ready, the block sets data-map-ready. A map inside a hidden or zero-size container (a closed modal, a collapsed accordion) never intersects, so it doesn’t load until it’s shown.

Default — marker at location (Paris)

Provide lat and lon. A marker is placed at the given coordinates by default. zoom defaults to 13.

default
---
import MapBlock from '@alfadormx/blocks/primitives/Map.astro';
---

<MapBlock lat={48.8566} lon={2.3522} />

Marker with popup label

Add markerTitle to display a popup label on the marker when the map loads.

popup
---
import MapBlock from '@alfadormx/blocks/primitives/Map.astro';
---

<MapBlock lat={48.8584} lon={2.2945} zoom={15} markerTitle="Eiffel Tower" />

Humanitarian tile layer

Use layer="humanitarian" for a high-contrast tile style provided by the HOT (Humanitarian OpenStreetMap Team).

humanitarian
---
import MapBlock from '@alfadormx/blocks/primitives/Map.astro';
---

<MapBlock
  lat={48.8566}
  lon={2.3522}
  zoom={13}
  layer="humanitarian"
  markerTitle="Paris"
  height="350px"
/>

Topographic layer — no marker

Use layer="topo" for terrain elevation rendering. Set showMarker={false} for a pin-free area view.

topo
---
import MapBlock from '@alfadormx/blocks/primitives/Map.astro';
---

<MapBlock lat={45.9} lon={6.9} zoom={10} layer="topo" showMarker={false} height="450px" />

Wide area overview

Low zoom level to show a country or region rather than a specific location.

overview
---
import MapBlock from '@alfadormx/blocks/primitives/Map.astro';
---

<MapBlock lat={46.6} lon={2.5} zoom={5} showMarker={false} height="400px" />

API Reference

PropTypeDefaultDescription
latnumber—Latitude of the map's center point, used to position the tile view and marker.
lonnumber—Longitude of the map's center point, used to position the tile view and marker.
zoomnumber13Initial zoom level of the map (default: 13).
layerMapLayer'mapnik'Tile layer style to render, e.g. street, humanitarian, or topographic (default: 'mapnik').
showMarkerbooleantrueWhether to show a marker at the lat/lon coordinates (default: true).
markerTitlestring—Popup text shown for the marker; opens automatically when the marker is displayed.
heightstring'400px'CSS height applied to the map container (default: '400px').
widthstring'100%'CSS width applied to the map container (default: '100%').
titlestring'OpenStreetMap'Accessible label for the map, used as the aria-label on the map container (default: 'OpenStreetMap').
classstring''Additional CSS class(es) applied to the outer wrapper element.