Skip to content

Map Configuration

Map configuration defines the initial view, interaction settings, controls, and legends for map blocks. All configuration follows the MapLibre GL JS API.

- type: map
id: my-map
config: # Map configuration
center: [lng, lat]
zoom: 12
mapStyle: "..."
pitch: 0
bearing: 0
# ... additional options
layers: [...] # Map layers
controls: {...} # Map controls (optional)
legend: {...} # Legend (optional)
PropertyTypeDescription
center[number, number]Initial map center [longitude, latitude]
zoomnumberInitial zoom level (0-24)
mapStylestring | objectMapLibre style URL or style object
config:
center: [-74.006, 40.7128]
zoom: 12
mapStyle: "https://demotiles.maplibre.org/style.json"

Control the camera position and orientation.

PropertyTypeDefaultRangeDescription
pitchnumber00-85Camera tilt angle in degrees
bearingnumber0-180 to 180Camera rotation in degrees
boundsarray--Fit map to geographic bounds
config:
center: [-122.4194, 37.7749]
zoom: 15
pitch: 60
bearing: 30
mapStyle: "https://demotiles.maplibre.org/style.json"
config:
center: [-74.006, 40.7128] # Fallback center
zoom: 12 # Fallback zoom
bounds: [-74.3, 40.5, -73.7, 40.9] # [west, south, east, north]
mapStyle: "https://demotiles.maplibre.org/style.json"

Limit user interaction to specific zoom levels, pitch angles, or geographic areas.

PropertyTypeDescription
minZoomnumberMinimum zoom level (0-24)
maxZoomnumberMaximum zoom level (0-24)
minPitchnumberMinimum pitch angle (0-85)
maxPitchnumberMaximum pitch angle (0-85)
maxBoundsarrayMaximum geographic bounds [west, south, east, north]
config:
center: [-74.006, 40.7128]
zoom: 12
minZoom: 8
maxZoom: 18
maxBounds: [-74.3, 40.5, -73.7, 40.9]
mapStyle: "https://demotiles.maplibre.org/style.json"

Control user interaction capabilities.

PropertyTypeDefaultDescription
interactivebooleantrueEnable all map interactions
scrollZoombooleantrueEnable scroll to zoom
boxZoombooleantrueEnable shift+drag box zoom
dragRotatebooleantrueEnable right-drag to rotate
dragPanbooleantrueEnable drag to pan
keyboardbooleantrueEnable keyboard shortcuts
doubleClickZoombooleantrueEnable double-click zoom
touchZoomRotatebooleantrueEnable touch zoom/rotate
touchPitchbooleantrueEnable two-finger touch pitch

Create a static map for presentation:

config:
center: [-74.006, 40.7128]
zoom: 12
interactive: false
mapStyle: "https://demotiles.maplibre.org/style.json"

Disable specific interactions:

config:
center: [-74.006, 40.7128]
zoom: 12
dragRotate: false # Disable rotation
touchPitch: false # Disable pitch on mobile
doubleClickZoom: false # Disable double-click zoom
mapStyle: "https://demotiles.maplibre.org/style.json"

Control map display and behavior.

PropertyTypeDefaultDescription
hashbooleanfalseSync map state with URL hash
attributionControlbooleantrueShow attribution control
logoPositionstring"bottom-left"MapLibre logo position
fadeDurationnumber300Fade duration in milliseconds
crossSourceCollisionsbooleantrueCheck for cross-source symbol collisions
config:
center: [-74.006, 40.7128]
zoom: 12
hash: true # Enable URL hash syncing
attributionControl: false # Hide attribution
logoPosition: bottom-right # Move logo
fadeDuration: 500 # Slower fade
mapStyle: "https://demotiles.maplibre.org/style.json"

Advanced rendering configuration.

PropertyTypeDefaultDescription
antialiasbooleanfalseEnable antialiasing
refreshExpiredTilesbooleantrueRefresh expired tiles
renderWorldCopiesbooleantrueRender multiple world copies
maxTileCacheSizenumber-Maximum tiles to cache
preserveDrawingBufferbooleanfalsePreserve drawing buffer for export
failIfMajorPerformanceCaveatbooleanfalseFail if WebGL performance is poor
config:
center: [-74.006, 40.7128]
zoom: 12
antialias: true # Smoother rendering
preserveDrawingBuffer: true # Enable map.getCanvas().toDataURL()
maxTileCacheSize: 100 # Cache more tiles
mapStyle: "https://demotiles.maplibre.org/style.json"

Customize UI text for different languages.

config:
center: [-74.006, 40.7128]
zoom: 12
locale:
"AttributionControl.ToggleAttribution": "Show attribution"
"FullscreenControl.Enter": "Enter fullscreen"
"FullscreenControl.Exit": "Exit fullscreen"
"GeolocateControl.FindMyLocation": "Find my location"
"NavigationControl.ResetBearing": "Reset bearing"
"NavigationControl.ZoomIn": "Zoom in"
"NavigationControl.ZoomOut": "Zoom out"
mapStyle: "https://demotiles.maplibre.org/style.json"

Configure which controls are displayed and where.

controls:
navigation: true | { enabled: true, position: "top-right" }
geolocate: true | { enabled: true, position: "top-right" }
scale: true | { enabled: true, position: "bottom-left" }
fullscreen: true | { enabled: true, position: "top-right" }
attribution: true | { enabled: true, position: "bottom-right" }
ControlDefault PositionDescription
navigationtop-rightZoom and rotation controls
geolocatetop-rightUser geolocation button
scalebottom-leftDistance scale indicator
fullscreentop-rightFullscreen toggle
attributionbottom-rightAttribution text
  • top-left
  • top-right
  • bottom-left
  • bottom-right
controls:
navigation: true
geolocate: true
scale: true
fullscreen: true
controls:
navigation:
enabled: true
position: top-left
scale:
enabled: true
position: bottom-right
fullscreen:
enabled: true
position: top-right
controls:
navigation: true
scale: true

Display a map legend showing layer information.

legend:
title: "Map Legend"
position: top-left
collapsed: false
items:
- color: "#ff0000"
label: "Category 1"
shape: circle
- color: "#00ff00"
label: "Category 2"
shape: square
PropertyTypeDefaultDescription
positionstring"top-left"Legend position
titlestring-Legend title
collapsedbooleanfalseStart collapsed
itemsarray-Custom legend items
PropertyTypeRequiredDefaultDescription
colorstringYes-Item color (CSS color)
labelstringYes-Item label text
shapestringNo"square"Symbol shape: circle, square, line, icon
iconstringNo-Icon name or URL (when shape: icon)

If items is not provided, legend items are extracted from layers with legend configuration:

legend:
title: "Earthquake Magnitude"
position: top-left
legend:
title: "Features"
position: top-right
collapsed: false
items:
- color: "#e74c3c"
label: "High Priority"
shape: circle
- color: "#f39c12"
label: "Medium Priority"
shape: circle
- color: "#2ecc71"
label: "Low Priority"
shape: circle
legend:
title: "Routes"
position: bottom-left
items:
- color: "#3b82f6"
label: "Highway"
shape: line
- color: "#10b981"
label: "Local Road"
shape: line
legend:
title: "Points of Interest"
position: top-left
items:
- color: "#000000"
label: "Restaurant"
shape: icon
icon: "restaurant"
- color: "#000000"
label: "Hotel"
shape: icon
icon: "hotel"
- type: map
id: basic-map
config:
center: [-74.006, 40.7128]
zoom: 12
mapStyle: "https://demotiles.maplibre.org/style.json"
layers:
- id: points
type: circle
source:
type: geojson
url: "https://example.com/points.geojson"
paint:
circle-radius: 8
circle-color: "#3b82f6"
controls:
navigation: true
scale: true
- type: map
id: 3d-map
config:
center: [-122.4194, 37.7749]
zoom: 15
pitch: 60
bearing: -45
mapStyle: "https://demotiles.maplibre.org/style.json"
layers:
- id: buildings
type: fill-extrusion
source:
type: vector
url: "https://demotiles.maplibre.org/tiles/tiles.json"
source-layer: building
paint:
fill-extrusion-color: "#aaa"
fill-extrusion-height: ["get", "height"]
fill-extrusion-opacity: 0.8
controls:
navigation:
enabled: true
position: top-left
fullscreen:
enabled: true
position: top-right
- type: map
id: constrained-map
config:
center: [-74.006, 40.7128]
zoom: 12
minZoom: 8
maxZoom: 16
maxBounds: [-74.3, 40.5, -73.7, 40.9]
mapStyle: "https://demotiles.maplibre.org/style.json"
layers:
- id: zones
type: fill
source:
type: geojson
url: "https://example.com/zones.geojson"
paint:
fill-color:
- match
- ["get", "type"]
- "residential"
- "#fef3c7"
- "commercial"
- "#dbeafe"
- "industrial"
- "#f3e8ff"
- "#e5e7eb"
fill-opacity: 0.6
controls:
navigation: true
scale: true
legend:
title: "Zone Types"
position: top-right
items:
- color: "#fef3c7"
label: "Residential"
shape: square
- color: "#dbeafe"
label: "Commercial"
shape: square
- color: "#f3e8ff"
label: "Industrial"
shape: square
- type: map
id: static-map
style: "height: 400px; width: 600px;"
config:
center: [0, 20]
zoom: 2
interactive: false
attributionControl: false
mapStyle: "https://demotiles.maplibre.org/style.json"
layers:
- id: earthquakes
type: circle
source:
type: geojson
url: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.geojson"
paint:
circle-radius: 6
circle-color: "#e74c3c"
circle-opacity: 0.8
- type: map-fullpage
id: immersive-map
config:
center: [-122.4194, 37.7749]
zoom: 13
pitch: 45
bearing: 0
hash: true
mapStyle: "https://demotiles.maplibre.org/style.json"
layers:
- id: buildings
type: fill-extrusion
source:
type: vector
url: "https://demotiles.maplibre.org/tiles/tiles.json"
source-layer: building
paint:
fill-extrusion-color: "#aaa"
fill-extrusion-height: ["get", "height"]
controls:
navigation: true
geolocate: true
fullscreen: true
scale: true

Define a default map style once in global config:

config:
defaultMapStyle: "https://demotiles.maplibre.org/style.json"
pages:
- path: "/"
title: "Home"
blocks:
- type: map
id: map1
config:
center: [-74, 40]
zoom: 12
# mapStyle inherited from global config
- type: map
id: map2
config:
center: [139, 35]
zoom: 12
# mapStyle inherited from global config
import {
type MapConfig,
type ControlsConfig,
type LegendConfig,
type MapBlock
} from '@maplibre-yaml/core/schemas';
const mapConfig: MapConfig = {
center: [-74.006, 40.7128],
zoom: 12,
mapStyle: "https://demotiles.maplibre.org/style.json",
pitch: 45,
bearing: 0
};
const controls: ControlsConfig = {
navigation: true,
scale: {
enabled: true,
position: "bottom-right"
}
};
const legend: LegendConfig = {
title: "Map Legend",
position: "top-left",
collapsed: false,
items: [
{ color: "#ff0000", label: "High", shape: "circle" }
]
};