Skip to main content

alphaThis is a new frontend component. Help us improve it and give your feedback on Slack.

Use Location Plugin

Lets users centre the map on their current location. It adds a "Use your location" button that centres the map there, at zoom 12. If their location can't be found, for example because they've denied permission, a panel explains why.

The button is hidden in browsers without geolocation.

Usage

import createUseLocationPlugin from '@defra/interactive-map/plugins/use-location'
const interactiveMap = new InteractiveMap('map', {
plugins: [createUseLocationPlugin()]
})

For UMD, add plugins/use-location/dist/umd/index.js and call defra.useLocationPlugin().

Options

This plugin takes no options.

Methods

This plugin does not expose any public methods.

Events

This plugin does not emit any custom events.