Hi, is there a way to location the current coordinates of the user? Im referring to this example
https://www.mapbox.com/mapbox-gl-js/example/locate-user/
Thanks!
@webdevsyd You can't use Mapbox's geolocate control directly, but it is not hard to make your own:
_locateUser() {
// https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation
navigator.geolocation.getCurrentPosition(position => {
this.updateViewport({
longitude: position.coords.longitude,
latitude: position.coords.latitude
});
});
}
GeolocateControl is included since version 4.1.3
Most helpful comment
@webdevsyd You can't use Mapbox's geolocate control directly, but it is not hard to make your own: