MarkerConfig
A marker is a pin or symbol placed at a specific coordinate on the map, used to highlight a location. The properties below are used in the markers option to define initial markers. The MarkerOptions properties also apply to markers added at runtime via addMarker().
Properties
id
- Type:
string(required)
Unique marker identifier. Use this ID to reference the marker when calling removeMarker().
coords
- Type:
[number, number](required)
Coordinates [lng, lat] or [easting, northing] depending on the CRS of the map provider.
options
- Type:
MarkerOptions
Optional marker appearance options. See MarkerOptions below.
MarkerOptions
Controls the visual appearance of a marker. All properties are optional — unset values fall back through the resolution order.
symbol
- Type:
string
Symbol to use for this marker. Built-in symbols: 'pin', 'circle', 'square', 'hexagon', 'triangle', 'diamond'. For a custom one-off symbol, use svgContent instead.
size
- Type:
'small' | 'medium' | 'large'
Size of the marker's symbol — see Symbol Config.
svgContent
- Type:
string
Inner SVG path content (no <svg> wrapper) to render instead of a registered symbol. Use {{token}} placeholders for colours. When set, symbol is ignored.
// Using built-in tokens with per-style coloursmarkers.add('id', coords, { svgContent: ` <path d="..." fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/> <path d="..." fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/> <path d="..." fill="{{foregroundColor}}"/> `, viewBox: '0 0 44 44', anchor: [0.5, 1], backgroundColor: { outdoor: '#d4351c', dark: '#ff6b6b' }})
// Using a custom tokenmarkers.add('id', coords, { svgContent: ` <path d="..." fill="{{customColor}}"/> `, viewBox: '0 0 38 38', anchor: [0.5, 0.5], customColor: { outdoor: '#1d70b8', dark: '#4c9ed9' }}){{selectedColor}} and {{activeColor}} are required to render the selection and focus rings.
NOTE
selectedColor and activeColor cannot be set per marker — they are controlled by MapStyleConfig.
viewBox
- Type:
string
SVG viewBox attribute for the symbol. Use alongside svgContent when your paths use a different coordinate space. Defaults to the registered symbol's viewBox, or '0 0 44 44'.
anchor
- Type:
[number, number]
Normalised [x, y] anchor point — which point on the symbol sits on the geographic coordinate. On a built-in symbol it's a fraction of the shape; on a custom SVG symbol it's a fraction of its viewBox. See Symbol Config: anchor.
anchor: [0.5, 1] // bottom-centre of the shapeanchor: [0.5, 0.5] // centrelabel
- Type:
string
Plain-text label for this marker. Serves two purposes:
- Accessible name — always used as the
aria-labelon the marker SVG, even when no bubble is visible. - Visible bubble — rendered as a tooltip-style label above the symbol when
showLabelistrue, or as a standalone label with a down-arrow whensymbolisnull.
// Accessible name only — no visible bubblemarkers.add('id', coords, { label: 'Town Hall' })
// Visible label bubble above the pinmarkers.add('id', coords, { label: 'Town Hall', showLabel: true })
// Standalone label — no symbol, arrow points to the coordinatemarkers.add('id', coords, { label: 'Town Hall', symbol: null })showLabel
- Type:
boolean- Default:
false
Whether to render a visible label bubble above the marker symbol. When false, label is still used as the accessible name of the marker.
Setting symbol: null creates a standalone label regardless of showLabel — the bubble is always visible in that case.
backgroundColor
- Type:
string | Record<string, string>
Background fill colour of the symbol.
foregroundColor
- Type:
string | Record<string, string>
Foreground fill colour of the symbol (e.g. the inner dot on a pin).
graphic
- Type:
string
SVG d attribute value for the foreground graphic path. Replaces the foreground shape of the symbol while keeping its background, halo and selection ring intact. Each built-in symbol (pin, circle) provides a default dot; pass a different d string to swap it. Use named values from graphics.js or supply your own path data.
Any custom tokens are also supported. See Symbol Config for the full property reference.