# Designed markers render in any MapLibre client

A marker set placed in MapMap Studio now compiles into the published `style.json` itself: an inline GeoJSON source called `mm-user-markers`, plus two symbol layers drawn over a signed-distance-field sprite sheet. Any MapLibre client that loads the style URL draws those markers, including MapLibre Native on iOS and Android, a server-side renderer, or a plain `new maplibregl.Map({ style })`. No MapMap SDK, no marker code, no runtime rasterising.

## Why did this need fixing at all?

Because until this change, a designed marker only existed where our own JavaScript ran. Markers rode the theme's opaque `extra` block, and `extra` is never copied into the compiled style. The web SDK's `MarkersLayer` read the block at runtime, rasterised each pin on a canvas, and registered the result with `map.addImage`. That works well inside a browser running `@mapmap/maps`. It renders nothing in MapLibre Native, nothing in a static render, and nothing for a customer who was handed a style URL and told to point their existing map at it.

We think that shape is worth naming. A marker design that only renders in the vendor's own SDK is a lock-in mechanism wearing a design tool's costume: the design is real, the portability is not, and the thing between you and any other renderer is a runtime you have to keep installed. MapLibre already has a published format for exactly this, the style specification plus the sprite specification, and every client in the ecosystem already reads it. Compiling to that format is the honest option, so that is what the compiler now does.

## What does the compiler actually put in the style?

Three things, and only when a theme carries a non-empty `extra.markers` block. A theme with no markers compiles to byte-identical output, which is covered by a test.

First, an inline GeoJSON source, `mm-user-markers`, with one Point feature per renderable marker. Each feature carries its own `icon`, `colour`, precomputed `iconSize` and `bodySize` ratios, `anchor`, `textSize` and `label`, so a single pair of layers covers every marker without a per-marker layer explosion.

Second, two symbol layers appended after every other layer, so markers sit on top of the map. `mm-user-markers` draws the coloured pin body. `mm-user-markers-glyph` draws the white glyph on top, plus the label. Trimmed to the load-bearing parts:

```json
{
  "id": "mm-user-markers",
  "type": "symbol",
  "source": "mm-user-markers",
  "layout": {
    "icon-image": ["case", ["==", ["get", "icon"], "dot"], "marker-glyph-dot", "marker-pin"],
    "icon-size": ["get", "bodySize"],
    "icon-anchor": ["get", "anchor"],
    "icon-allow-overlap": true
  },
  "paint": {
    "icon-color": ["case", ["==", ["get", "icon"], "dot"], "#ffffff", ["get", "colour"]]
  }
}
```

```json
{
  "id": "mm-user-markers-glyph",
  "type": "symbol",
  "source": "mm-user-markers",
  "layout": {
    "icon-image": ["concat", "marker-glyph-", ["get", "icon"]],
    "icon-size": ["get", "iconSize"],
    "text-field": ["get", "label"],
    "text-font": ["MapMap Sans Regular"],
    "text-size": ["get", "textSize"],
    "text-optional": true
  },
  "paint": {
    "icon-color": ["case", ["==", ["get", "icon"], "dot"], ["get", "colour"], "#ffffff"],
    "text-color": "#333333",
    "text-halo-color": "#ffffff",
    "text-halo-width": 1.5
  }
}
```

Two stacked layers rather than one "pin minus glyph" shape, because a knockout hole would show the map through the glyph instead of white. The `dot` marker inverts the pair: a white disc slightly larger than the coloured one, which is how it gets its outline ring.

Third, the style's `sprite` is set to `https://api.mapmap.ai/sprite/marker-sprite`, unless the theme names a `sprite` of its own, in which case the theme wins.

## Where does the sprite come from, and what is in it?

`map-assets/sprites/marker-sprite[@2x].json|png`, generated in the repo by `node map-assets/icons/markers/generate-sprite.mjs` from the same SVGs the SDK rasterises, and served by the gateway at `/sprite/marker-sprite[@2x].json|png`. That route is public and unmetered, alongside the glyph ranges at `/fonts/{fontstack}/{range}.pbf`, and answers with `Cache-Control: public, max-age=3600` and an `ETag`, so a client that already holds the sprite revalidates with a 304 rather than downloading it again.

The sheet holds 22 entries, every one marked `"sdf": true`: `marker-pin` for the teardrop body, and `marker-glyph-<id>` for each of the 21 locked glyph ids. Each image is 38 by 38 at pixel ratio 1, which is a 32 pixel content square plus 3 pixels of padding on each side, giving the distance field room to fall away. It is a separate sheet from the spreet-built `sprite` sheet because SDF is a whole-sheet mode and that sheet carries full-colour camera, lane and shield icons.

## How does a third-party client consume it?

It loads the style URL. That is the whole integration.

```sh
curl -fsS -X POST "https://api.mapmap.ai/styles/midnight-fleet-9f3a2c" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "theme": {
      "name": "midnight-fleet",
      "base": "dark",
      "extra": { "markers": { "version": 1, "items": [
        { "id": "depot", "lng": -0.1276, "lat": 51.5072,
          "icon": "fuel", "colour": "#FF7A1F", "size": "l", "label": "Depot" }
      ] } }
    }
  }'
```

`200 OK`:

```json
{
  "id": "midnight-fleet-9f3a2c",
  "version": 2,
  "style_url": "https://api.mapmap.ai/styles/midnight-fleet-9f3a2c@2.json"
}
```

Then, in a client that has never heard of MapMap:

```js
import * as maplibregl from "maplibre-gl";

const map = new maplibregl.Map({
  container: "map",
  style: "https://api.mapmap.ai/styles/midnight-fleet-9f3a2c@2.json",
});
```

Style reads are public and unmetered, so the URL can be referenced from a browser client by bare URL. Publishing a version is metered as a Standard call, which is 0.05p per call once you are past the 50,000 free calls a month. Rendering credits `© OpenStreetMap contributors`, as everything drawn on these tiles does.

If you are already using our SDK, `MarkersLayer` takes over a baked style rather than drawing a second copy: given markers, it removes both baked layers and installs its own, and constructed without markers it leaves them alone. `hasBakedMarkers(map)` tells you which style you are on.

## What does not survive the bake?

Four real limits, and the first one is the one that will catch you.

- **Custom images do not bake.** A marker with an `image` (a `data:` URI) cannot live in a static sprite, so the compiler leaves it out rather than substituting its `icon` and drawing the wrong marker. Those markers render only through the web SDK's `MarkersLayer`. A theme of nothing but image markers bakes nothing at all.
- **SDF is single-channel, so full-colour artwork does not survive it.** An SDF image stores distance from the shape edge, not colour, which is exactly why one sheet can serve every style: `icon-color` recolours the shared shapes at render time. The two colours a marker has come from stacking two layers, a coloured body and a white glyph, not from one multi-colour image. If you want per-pixel colour in a marker, SDF is the wrong path for it.
- **Caps.** Up to 200 markers per theme, each `image` capped at 64 KB decoded, and the whole `extra` block capped at 256 KB serialised. The per-image caps multiply, so a handful of full-size images hits the block cap first. Labels are capped at 120 characters and ids at 64.
- **A theme that sets its own `sprite` replaces the marker sheet.** That is deliberate, because a self-hosted deployment points at its own copy. It also means a custom sheet has to carry the `marker-pin` and `marker-glyph-*` entries, or the baked layers have nothing to draw.

Two more things are still SDK-only. Route start, destination and waypoint pins are a separate block, `extra.nav.endpoints`, and that one is still never compiled into the style: `RouteLayer`'s `endpoints` option draws it. Numbered and lettered short-text pins are also runtime-only, because the baked layers draw glyphs from the sheet rather than arbitrary text.

## How does a client pick up an updated marker set?

By fetching the style again. Markers live in the style, not in the sprite, so changing a marker means publishing a new style version. `GET /styles/{id}@{version}.json` is immutable and cached for a year, so a client pinned to a version keeps the markers it was given. `GET /styles/{id}.json` serves the latest with a 60-second TTL, so a client on the unpinned URL picks up a new set within a minute of the publish. The sprite sheet only changes when the glyph set changes, which is a schema change coordinated across the Rust validator, the SDK and Studio.

Customer-supplied artwork is a different mechanism and it is not finished. `sn-sprites`, our pack compiler, is built: sanitised SVGs in, a MapLibre sprite sheet out, 1x and 2x, optional SDF, with a pack id that is a BLAKE3 digest over the inputs rather than the compiled PNG bytes. It caps a pack at 512 icons, 32 KB per icon and 2 MB compiled. What it does not have yet is a gateway surface, so there is no endpoint you can post your own icons to today. That work is queued behind a gateway rebuild.

## Where POI markers sit in this

POI markers stay circles, on purpose. The Markers tab is for the things you place: depots, stops, sites, the pins a designer wants to ship with the style. POI categories are themed separately through `extra.poi`, which recolours the category dot and the label text, and swapping those dots for sprite glyphs is queued behind the same marker-pack work. A category dot is a density signal, not a brand surface, and it reads better as a circle at the zoom levels where hundreds of them are on screen at once.

## Try it

Place a few markers in [MapMap Studio](/news/map-studio), publish, and open the returned `style_url` in whatever MapLibre client you already run. The style and sprite reference is in the [maps documentation](/docs/maps), the `MarkersLayer` and `hasBakedMarkers` reference is in the [SDK documentation](/docs/sdks), and the wider argument for a style being a portable document rather than a runtime is in [vector tiles and styles](/news/vector-tiles-and-styles). If you are coming from another provider, the [migration notes](/news/migrating-from-mapbox) cover what ports and what does not.
