Controls

Map controls are interactive buttons positioned over the map — zoom, compass, locate, and fullscreen.

Usage

{
  "controls": {
    "zoom": true,
    "compass": true,
    "fullscreen": false,
    "locate": false,
    "position": "top-right"
  }
}

Properties

PropertyTypeDefaultDescription
zoombooleantrueShow zoom in/out buttons
compassbooleantrueShow compass / reset north button
fullscreenbooleanfalseShow fullscreen toggle
locatebooleanfalseShow locate-me button (uses browser geolocation)
basemapSwitcherbooleanfalseShow light/dark/streets basemap toggle (bottom-left)
searchbooleanfalseShow geocoding search bar (top-left)
layerSwitcherboolean | objectfalseShow layer visibility toggle panel. Pass true to use controls position, or { "position": "bottom-left" } for independent placement. Panel opens downward from top corners, upward from bottom corners.
positionControlPosition"top-right"Corner to place controls

Positioning

Controls are rendered as React components with absolute positioning over the map container:

  • "top-left"
  • "top-right" (default)
  • "bottom-left"
  • "bottom-right"

Defaults

When controls is set in the spec, zoom and compass are enabled by default. If controls is omitted entirely, no controls are shown.

{ "controls": {} }

This shows zoom + compass at top-right.

Example

Full controls at bottom-right:

{
  "basemap": "streets",
  "center": [-73.98, 40.75],
  "zoom": 13,
  "controls": {
    "zoom": true,
    "compass": true,
    "fullscreen": true,
    "locate": true,
    "basemapSwitcher": true,
    "search": true,
    "layerSwitcher": { "position": "top-left" },
    "position": "bottom-right"
  }
}