Skip to content

Locate the user

Replicates the MapLibre example Locate the user.

Click the geolocate button and grant permission
locate-the-user.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/locate-the-user/
# The control tracks with high accuracy by default; click it and grant the
# browser permission.
type: map
id: locate-the-user
config:
center: [-24, 42]
zoom: 1
mapStyle: "https://demotiles.maplibre.org/style.json"
controls:
geolocate: true
  • controls.geolocate: true adds the control with high-accuracy tracking enabled.
  • Position takes the usual { enabled, position } block form.