Skip to content

Disable map rotation

Replicates the MapLibre example Disable map rotation: north stays up.

disable-map-rotation.yaml
# yaml-language-server: $schema=https://docs.maplibre-yaml.org/schema/latest/map.schema.json
# Gallery twin of https://maplibre.org/maplibre-gl-js/docs/examples/disable-map-rotation/
# Right-drag and touch-rotate do nothing; north stays up.
type: map
id: disable-map-rotation
config:
center: [12.4964, 41.9028]
zoom: 10
dragRotate: false
touchZoomRotate: false
mapStyle: "https://demotiles.maplibre.org/style.json"
  • dragRotate: false kills right-drag rotation; touchZoomRotate: false disables the touch gesture wholesale (the upstream version keeps pinch-zoom while disabling only rotation — that finer split needs getMap()).