Build interactive marker maps and choropleth maps directly in Etch. The component supports one location, many locations, clustered markers, custom links, editable popup content, keyboard navigation, custom status messages, and reusable choropleth palettes.

No PHP, shortcode, Mapbox account, or API key is required for the default setup.

What is included

The V1 package contains two Etch components:

  • Geo Map — the map container, map configuration, controls, status, legend, and rendering logic.
  • Geo Map Feature — one marker location or one choropleth region and its optional action.

The Geo Map contains a features slot. Add Geo Map Feature components to this slot manually or generate them with an Etch loop.

Each Geo Map Feature has an optional popup slot. When Show Popup is enabled, the slot can contain headings, text, images, buttons, links, dynamic data, conditions, and other Etch elements.

V1 features

  • Marker and choropleth map modes
  • One location or many locations
  • Static features or features generated by an Etch loop
  • Automatic fitting for multiple markers
  • Configurable world center and zoom for choropleth maps
  • Marker clustering
  • Cluster expansion and spiderfy at maximum cluster zoom
  • Optional cluster pulse animation
  • Optional cluster coverage shape on hover
  • Five-step choropleth color scale
  • Reusable palette classes
  • Per-feature popup content built entirely in Etch
  • Per-feature URL when no popup is needed
  • Non-clickable features when no popup or URL is supplied
  • Separate zoom-control and reset-display options
  • Optional legend and live status
  • Per-instance custom status messages
  • Keyboard navigation on the real MapLibre canvas
  • Visible canvas and choropleth focus indicators
  • Reduced-motion support
  • OpenStreetMap default basemap
  • Custom MapLibre style and GeoJSON support
  • One guarded initializer to prevent duplicate maps and attribution controls

Requirements

  • Etch with component support
  • A modern browser with JavaScript enabled
  • Internet access when using the supplied external resources

The V1 component loads:

  • MapLibre GL JS 5.24.0 from unpkg.com
  • OpenStreetMap raster tiles from tile.openstreetmap.org
  • Default country boundaries from the datasets/geo-countries repository on GitHub

The default setup does not require an account, API key, or access token.

Quick start

  1. Import the supplied component JSON into Etch.
  2. Add Geo Map to a page or template.
  3. Choose Markers or Choropleth under Data & Rendering → Map Type.
  4. Open the map’s features slot.
  5. Add one or more Geo Map Feature components, manually or inside an Etch loop.
  6. Connect each feature’s properties to static values or loop data.
  7. Enable Show Popup when a feature needs an Etch-built popup.
  8. Add any Etch content you want to the feature’s popup slot.
  9. Preview the page and test it with a mouse, touch, and keyboard.

Only place Geo Map Feature components in the features slot. Do not place another Geo Map inside that slot.

Geo Map props

Grouped props are shown with their group name so they are easy to locate in Etch.

Prop nameTypeDefault valuePurpose
Map ARIA LabelTextInteractive locations mapGives the map container a useful name for screen-reader users. Change it to describe the specific map.
HeightText / CSS size800pxSets the map height. Values such as 42rem, 70vh, and clamp(28rem, 68vh, 50rem) are accepted.
Map Config → Center LatitudeText/number20Starting and reset latitude for choropleth maps. It is also the fallback center when a marker map has no valid coordinates.
Map Config → Center LongitudeText/number0Starting and reset longitude used with Center Latitude.
Map Config → ZoomText/number1.5Starting and reset zoom for choropleth maps. It is also used as the zoom level for a single marker.
Map Config → Max Fit ZoomText/number8Stops a multiple-marker map from zooming in too far when fitting all locations.
Map Config → Fit PaddingText/number48Adds space in pixels around the fitted marker bounds.
Map Config → Scroll ZoomBooleanOffAllows mouse-wheel or trackpad zoom. When off, normal page scrolling is less likely to become trapped by the map.
Map Config → Show Zoom ControlBooleanOnShows or hides MapLibre’s zoom-in and zoom-out buttons. Show Reset must also be on for these controls to be initialized in V1.
Map Config → Show ResetBooleanOnShows the Reset map button. In V1 this also enables creation of the MapLibre navigation control that contains the zoom buttons.
Map Config → Show LegendBooleanOnShows the Lower-to-Higher color legend. It is mainly useful for choropleth maps.
Map Config → Show StatusBooleanOffShows a polite live status message after the map loads.
Map Config → Status MessageTextEmptyOptional map-specific message. Use %count% anywhere the calculated feature count should appear. Leave empty for the automatic message.
Legend → Block PositionText/CSS size2.5remPositions the legend from the bottom edge of the map.
Legend → Inline PositionText/CSS size.65emPositions the legend from the right edge of the map.
Map ClassesClass listNoneAdds one or more Etch classes to this map instance for custom styling.
Data & Rendering → Map TypeSelectmarkersSelects Markers or Choropleth rendering.
Data & Rendering → Graduated PaletteClass list.geo-map--palette-oceanApplies a reusable class containing the five choropleth colors and related map colors.
Data & Rendering → Basemap Style JSON URLText / URLEmptyChoropleth panel option for a public MapLibre Style Specification JSON document. Leave empty for the built-in OpenStreetMap raster style. This is not a raster tile URL template.
Data & Rendering → Feature KeyTextADM0_A3Choropleth only. Names the GeoJSON property used to identify each boundary. Every Feature ID must match exactly one of its values.
Data & Rendering → GeoJSON URLText/ URLEmptyChoropleth only. Public GeoJSON FeatureCollection containing the boundaries. Leave empty for the supplied world-country boundary file.
Data & Rendering → Enable ClusteringBooleanOnMarker maps only. Combines nearby locations into numbered clusters when more than one valid marker exists.
Data & Rendering → Cluster RadiusText/number56Marker maps only. Pixel distance used to decide whether nearby markers belong to the same cluster.
Data & Rendering → Cluster Max ZoomText/number14Marker maps only. Last clustering level. A terminal cluster can be expanded into a spider pattern.
Data & Rendering → Pulse ClustersBooleanOnMarker maps only. Adds an animated pulse to cluster circles. It is disabled automatically when reduced motion is requested.
Data & Rendering → Show Coverage FeatureBooleanOnMarker maps only. Draws a temporary shape around a cluster’s locations while the cluster is hovered.

Custom status messages

Use %count% anywhere in Status Message:

There are %count% countries
Now showing %count% charging locations
Explore our work in %count% countries. Select a country for details.

The placeholder is case-insensitive and every %count% occurrence is replaced.

Do not use {count} in the Etch prop. Etch treats curly braces as dynamic-data syntax and removes that expression before the map JavaScript receives it.

When Status Message is empty, V1 uses one of these automatic forms:

  • Explore 10 locations. Use the arrow keys to move between map items.
  • Explore 10 mapped regions. Use the arrow keys to move between map items.

For a marker map, the count includes features with valid latitude and longitude values. For a choropleth map, it includes the supplied Geo Map Feature records.

Geo Map Feature props

One Geo Map Feature represents one marker or one choropleth value.

Prop nameTypeDefault valuePurpose
Feature IDTextUSAUnique identifier. On choropleth maps it must exactly match the selected GeoJSON Feature Key value.
LabelTextUnited StatesHuman-readable name used by keyboard navigation, screen readers, and fallback popup content.
LatitudeText/number38Required for marker maps. On choropleth maps it can optionally define the location the map centers on during keyboard navigation.
LongitudeText/number-97Required for marker maps. On choropleth maps, it can optionally define the location the map centers on during keyboard navigation.
ValueText/number10Numeric value used to select one of the five choropleth colors. Marker maps ignore it.
Popup → Show PopupBooleanOffMakes the popup slot available and opens that content when the feature is activated.
Popup → Popup StylesClass listNoneAdds Etch classes to the feature’s popup wrapper. It is shown in the prop panel when Show Popup is on.
Popup → Custom URLText / URLEmptyUsed when Show Popup is off. Activating the feature follows this URL. Only HTTP and HTTPS destinations are accepted.

Slots

Geo Map: features slot

The features slot supplies the records the map renders.

It can contain:

  • One Geo Map Feature
  • Several Geo Map Feature components
  • An Etch loop that generates Geo Map Feature components

The feature elements are visually hidden after the map reads their data. They remain in the page as the component’s structured data source and accessible fallback content.

Geo Map Feature: popup slot

The popup slot is rendered only when Popup → Show Popup is on.

Build a popup with normal Etch elements, including:

  • Headings
  • Paragraphs
  • Images
  • Buttons and links
  • Dynamic post, term, option, or loop data
  • Conditional content
  • Nested layouts

The component clones that markup into a MapLibre popup. Every feature and every map instance can therefore have different popup content without editing PHP or JavaScript.

If the popup contains a link or button, keyboard focus moves to the first actionable element when the popup opens. Focus returns to the map canvas when the popup closes.

Creating features with an Etch loop

A common loop structure is:

{#loop chargingLocations as item}
  [Geo Map Feature using item values]
{/loop}

Map the loop fields to the feature props:

JSON or query fieldGeo Map Feature prop
Unique ID or region codeFeature ID
Location or region nameLabel
LatitudeLatitude
LongitudeLongitude
Numeric totalValue
Destination URLPopup → Custom URL

Limiting a large JSON array

Use Etch’s .slice() modifier when you only want to render the first part of an array. This example renders indexes 0 through 199:

{#loop chargingLocations.slice(0, 200) as item}
  [Geo Map Feature using item values]
{/loop}

This limits the number of features Etch renders. It does not necessarily reduce the size of the JSON file downloaded by the browser. Limiting or paginating the source is still preferable for very large remote datasets.

Marker maps

Use Markers when each item has a latitude and longitude.

One marker

  1. Add one Geo Map Feature to the features slot.
  2. Enter its Label, Latitude, and Longitude.
  3. Set the Geo Map’s Zoom to the desired close-up level.
  4. Enable Show Popup or enter a Custom URL if the marker should be actionable.

The map centers on the marker and uses the Zoom prop.

Multiple markers

Add several features or use an Etch loop. The map fits all valid coordinates into view using Fit Padding and Max Fit Zoom.

Center Latitude, Center Longitude, and Zoom do not override that automatic multiple-marker fit. They remain the fallback view when no valid markers exist.

Popup versus Custom URL

  • When Show Popup is on, the popup takes priority.
  • When Show Popup is off and Custom URL contains a valid web address, activation follows the link.
  • When both are empty, the feature remains visible but is not presented as clickable and does not use a pointer cursor.

Styling the Popup

There is a styling prop that manages the popup’s content, but to access the popup wrapper, you need to add a style to the main map. Here is an example (used on the Italy popup)

.popover--primary {
  & .maplibregl-popup-content {
    background: var(--tertiary-semi-dark) !important;
  }
  .maplibregl-popup-tip {
    border-top-color: var(--tertiary-semi-dark) !important;
  }
  & :where(p, a, h2, h3, h4),
  & .maplibregl-popup-close-button {
    color: var(--white);
  }
  & .geo-map__status {
    color: initial;
  }
  & .geo-map__popup {
    padding: 1rem;
  }
}
CSS

Clusters

When clustering is enabled, nearby markers are combined into numbered circles.

  • Clicking a cluster smoothly zooms in on its location.
  • Clicking a terminal cluster at the maximum cluster level spreads its locations into a spider pattern.
  • Clicking a spiderfied point opens that location’s popup or follows its URL.
  • Moving the map clears the spider pattern.
  • Show Coverage Feature draws a temporary convex boundary around the cluster’s locations on hover.
  • Pulse Clusters animates a ring around clusters unless reduced motion is enabled.
  • Keyboard item navigation continues to work whether markers are clustered or not.

Clustering starts only when at least two valid marker locations exist.

Choropleth maps

Use Choropleth to color regions such as countries, states, counties, or service areas according to numeric values.

Each Geo Map Feature needs:

  • A Feature ID that matches a boundary in the GeoJSON
  • A numeric Value
  • A useful Label

Latitude and Longitude are optional for choropleth features. When they are empty, V1 finds the matching boundary and uses its center for keyboard navigation.

Initial world view

Choropleth maps use these three props for their initial and reset view:

  • Center Latitude
  • Center Longitude
  • Zoom

The V1 defaults are longitude 0, latitude 20, and zoom 1.5. This centers the map slightly north of the equator, without fully fitting the GeoJSON bounds.

World copies are disabled, so North America and other regions do not repeat horizontally.

How matching works

Three values must agree:

  1. Feature Key on Geo Map names a property in the GeoJSON.
  2. That property exists on every boundary that should be matched.
  3. Feature ID on each Geo Map Feature exactly matches the property value.

Example using the default country boundaries:

Feature KeyFeature IDRegion
ADM0_A3USAUnited States
ADM0_A3DEUGermany
ADM0_A3AUSAustralia

Matching is case-sensitive. USA, usa, and US are different values.

Custom GeoJSON

GeoJSON URL must return a public GeoJSON FeatureCollection. Each boundary needs a property that can be matched to Feature ID.

For example:

{
  "type": "Feature",
  "properties": {
    "region_code": "north"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": []
  }
}
JSON

Set:

  • Feature Key to region_code
  • Feature ID to north

The server must allow browser requests from your website. If it blocks cross-origin requests, the component cannot load the boundary file.

How values become colors

V1 finds the largest supplied value and assigns each positive value to one of five levels. It uses a square-root scale so smaller positive values remain easier to distinguish.

Zero, negative, missing, and invalid values use --geo-map-no-data.

The visible legend ramp uses:

  • --geo-map-low, which points to level 1
  • --geo-map-mid, which points to level 3
  • --geo-map-high, which points to level 5

The legend communicates relative lower-to-higher values. V1 does not print numeric thresholds in the legend.

Choropleth palettes

The Graduated Palette prop accepts an Etch class. This keeps color choices out of the JavaScript and makes a palette reusable across maps.

A palette may use five shades of one color or five different colors. The important requirement is that the order clearly communicates lower to higher values.

Included palette

The supplied .geo-map--palette-ocean class is a complete working example:

.geo-map--palette-ocean {
  --scale-color:#2557D7;
  --map-bg: var(--base);
  --geo-map-level-1: color-mix(in srgb, var(--scale-color) 65%, transparent);
  --geo-map-level-2: color-mix(in srgb, var(--scale-color) 75%, transparent);
  --geo-map-level-3: color-mix(in srgb, var(--scale-color) 80%, transparent);
  --geo-map-level-4: color-mix(in srgb, var(--scale-color) 95%, transparent);
  --geo-map-level-5: var(--scale-color);
  --geo-map-no-data: var(--map-bg);
  --geo-map-outline: color-mix(in srgb, var(--scale-color) 28%, transparent);}
CSS

Multi-hue palette example

.geo-map--palette-multi {
  --geo-map-level-1: #e8f5e9;
  --geo-map-level-2: #9bd7a7;
  --geo-map-level-3: #4eb3a8;
  --geo-map-level-4: #3678b7;
  --geo-map-level-5: #4b2a83;
  --geo-map-no-data: #f2f2f2;
  --geo-map-outline: rgb(23 32 51 / 28%);
  --geo-map-focus: #111827;
}
CSS

Create the class in Etch, then select it under Data & Rendering → Graduated Palette.

Styling

The component uses CSS custom properties so it can follow the site’s design system.

Custom propertyDefaultPurpose
--geo-map-heightclamp(28rem, 68vh, 50rem)Internal height fallback. The Height prop normally overrides it.
--geo-map-radiusvar(--radius-m, 0.875rem)Outer corner radius.
--geo-map-borderMixed from the current text colorOuter border color.
--geo-map-surfacevar(--white, #fff)Control, popup, legend, and status surface color.
--geo-map-textvar(--text, #172033)Main text color.
--geo-map-accentvar(--primary, #2557d6)Marker, cluster, coverage, and default choropleth accent.
--geo-map-no-dataLight transparent current colorChoropleth regions without a positive value.
--geo-map-level-124% accentLowest positive choropleth step.
--geo-map-level-240% accentSecond choropleth step.
--geo-map-level-358% accentMiddle choropleth step.
--geo-map-level-476% accentFourth choropleth step.
--geo-map-level-5Accent colorHighest choropleth step.
--geo-map-outline25% current colorBoundary outline.
--geo-map-focus#111827Choropleth keyboard-focus outline.
--geo-map-lowLevel 1Low end of the visible legend ramp.
--geo-map-midLevel 3Middle of the visible legend ramp.
--geo-map-highLevel 5High end of the visible legend ramp.

Use Map Classes to style one map instance. Use Graduated Palette for a reusable choropleth color system. Use Popup Styles when selected popups need a different design.

Basemap and attribution

Leave Basemap Style JSON URL empty to use the built-in OpenStreetMap raster basemap.

A custom URL must point to a complete public MapLibre Style Specification JSON document. It may define:

  • A light or dark basemap
  • Different labels, roads, or boundaries
  • Self-hosted vector or raster sources
  • A third-party map provider

A raster tile template such as .../{z}/{x}/{y}.png is not a complete style document.

The MapLibre attribution control is always enabled in V1. The default map shows attribution for MapLibre and OpenStreetMap. Custom styles may add their own source attribution. Keep all required attribution for the library, tile provider, and data sources.

Keyboard and accessibility

The real MapLibre canvas is the keyboard navigation control. There is no separate hidden navigator button.

  1. Press Tab until focus reaches the map canvas.
  2. Use Right Arrow or Down Arrow for the next map item.
  3. Use Left Arrow or Up Arrow for the previous map item.
  4. Use Home for the first item.
  5. Use End for the last item.
  6. Press Enter or Space to open the current item’s popup or follow its URL.
  7. Press Escape to close an open popup.
  8. Use + or − to change zoom in 0.25 steps when the navigation control is enabled.

Arrow-key item navigation wraps from the last item to the first and from the first item to the last. V1 stops MapLibre’s normal arrow-key panning while this item navigator is active, so one key press selects one item.

When a choropleth item is selected with the keyboard, its matching region receives a dark outline with a white halo. The canvas itself has a visible focus outline.

Additional accessibility behavior includes:

  • Map ARIA Label names the outer map container.
  • The canvas label announces the selected item and its position, such as “Map item 2 of 10: Germany.”
  • The optional status uses role="status" with polite live announcements.
  • Non-actionable markers and regions do not use a pointer cursor.
  • Popup focus moves to the first link, button, or other focusable element.
  • Focus returns to the map canvas when the popup closes.
  • Reset, zoom, item movement, cluster expansion, and pulse animation respect reduced-motion preferences.
  • World copies are disabled.

Privacy and external requests

MapLibre is open source and does not require an account in this component. The supplied V1 setup is not fully self-hosted.

Visitors’ browsers request files from:

  • unpkg.com for MapLibre JavaScript and CSS
  • tile.openstreetmap.org for the default map tiles
  • raw.githubusercontent.com for the default country GeoJSON

Those services can receive ordinary request information such as the visitor’s IP address and browser headers.

For stricter first-party hosting, self-host the MapLibre files, basemap style or tiles, and boundary data. The MapLibre URLs and default country URL are constants in the component JavaScript, so changing those particular defaults requires editing the component script.

Common setups

Locations with custom Etch popups

Use a loop inside the features slot. Bind Label, Latitude, and Longitude to the current loop item. Turn on Show Popup and build the popup slot with dynamic values such as name, address, image, phone number, distance, or detail link.

Locations that open another page

Turn Show Popup off and bind Custom URL to the loop item’s URL. The marker or choropleth region follows that link when activated.

Non-clickable map features

Turn Show Popup off and leave Custom URL empty. The marker or region remains visible but does not show a pointer cursor or behave like a link.

Country totals

Choose Choropleth, keep the default Feature Key, and use three-letter country IDs such as USA, DEU, and AUS. Bind Value to the total for each country.

States, counties, or custom service areas

Provide a custom GeoJSON URL. Set Feature Key to the property containing the region IDs, then use those exact IDs in Geo Map Feature.

Troubleshooting

The map is blank

  • Confirm the page can load MapLibre from unpkg.com.
  • Confirm the map has a valid Height.
  • For markers, confirm at least one feature has numeric Latitude and Longitude.
  • For choropleths, open the GeoJSON URL and confirm it returns a valid FeatureCollection.
  • Check the browser console for a network, style, or CORS error.

Marker features are missing

  • Make sure Map Type is Markers.
  • Check that Latitude and Longitude are not reversed.
  • Make sure loop values contain plain numbers.
  • Place Geo Map Feature inside the Geo Map’s features slot.
  • Do not place another Geo Map inside that slot.

A large marker loop is slow

  • Limit the rendered array with .slice(0, 200) while testing.
  • Reduce the source response itself when possible.
  • Keep clustering enabled for dense marker sets.
  • Avoid unusually heavy popup markup for every record.

Choropleth regions remain the no-data color

  • Confirm Feature Key exactly matches a GeoJSON property name.
  • Confirm Feature ID exactly matches that property’s value.
  • Check capitalization and punctuation.
  • Confirm Value is numeric and greater than zero.
  • Confirm the selected palette defines the expected level variables.

Only one static country is colored

  • Confirm the Etch loop is inside the features slot.
  • Confirm the loop creates one Geo Map Feature per item.
  • Bind Feature ID to the current item’s country code rather than a fixed value.
  • Bind Value to the current item’s numeric total.

The world view ignores my marker fit settings

Marker maps and choropleth maps use different view rules:

  • Multiple markers use Fit Padding and Max Fit Zoom.
  • A single marker uses Zoom.
  • A choropleth uses Center Latitude, Center Longitude, and Zoom.

A feature looks clickable when it should not

Show Popup must be off and Custom URL must be empty. V1 only uses the pointer cursor when a feature has one of those actions.

Custom URL does not open

  • Turn Show Popup off because popup content takes priority.
  • Use a complete or site-relative web URL.
  • Only HTTP and HTTPS destinations are accepted.

Clusters do not appear

  • Choose Markers.
  • Turn Enable Clustering on.
  • Supply at least two valid marker coordinates.
  • Increase Cluster Radius when nearby locations remain separate.

A terminal cluster does not reveal every location

Click the cluster to zoom toward it. At the terminal cluster level, click again to spiderfy its locations.

Keyboard arrows pan the map instead of changing items

  • Tab to the MapLibre canvas before pressing an arrow key.
  • Confirm the canvas announces “Map item 1 of…” rather than only “Map.”
  • Confirm only the current V1 initializer is present.
  • Reimport or replace the component script if the page still uses an older version.

The status shows text without a number

Use %count%, not {count}:

There are %count% countries

Etch consumes curly-brace expressions before JavaScript receives the prop.

The legend overlaps another control

Adjust Legend → Block Position and Inline Position, or turn Show Legend off.

Zoom controls remain hidden

Show Reset must be on in V1 because it also enables creation of the MapLibre navigation control. Then use Show Zoom Control to toggle the zoom buttons.

Duplicate maps or attribution controls appear

V1 contains one guarded initializer. If duplicates appear after manual editing, confirm the script was not pasted twice and that an older global initializer is not still running.

Technical notes

  • Component release: V1
  • Etch export format version: 2.1
  • MapLibre GL JS version: 5.24.0
  • Internal minimum zoom: 1
  • Internal maximum zoom: 18
  • Zoom-button and keyboard zoom step: 0.25
  • Normal item and zoom movement: about 420ms
  • Initial multiple-marker fit: about 500ms
  • Reset and cluster expansion: about 700ms
  • Multiple marker maps fit automatically and respect Max Fit Zoom.
  • Single marker maps use the configured Zoom.
  • Choropleth maps use the configured Center Latitude, Center Longitude, and Zoom.
  • renderWorldCopies is disabled.
  • Cooperative gestures are enabled.
  • The component listens for the custom geo-map:refresh document event.
  • Initialization is guarded by data-geo-map-ready.
  • MapLibre is loaded once and shared by all map instances on the page.
  • The component contains one initializer.

V1 boundaries

V1 intentionally does not include:

  • Address geocoding; marker coordinates must already be supplied
  • Server-side pagination or source-data limiting
  • Numeric legend thresholds
  • A prop for hiding required attribution
  • Built-in search or filtering controls
  • Offline or fully self-hosted assets
  • Mapbox-specific styles, accounts, or access tokens

These can be added in future versions without changing the Geo Map Feature data model.

External resources