Skip to main content
2 of 3
naming
Vince
  • 20.3k
  • 16
  • 48
  • 65

Leaflet geolocation alternative for if access is denied

I have the following that prompts the user to give location access. On granting permission the user's location is shown and the map loads. I'm trying to find a solution for if the user accidentally denies location access. Can anyone advise?

 function onLocationFound(e) {
        var radius = e.accuracy / 4;

        L.circle(e.latlng, radius).addTo(map);
    }

    function onLocationError(e) {
        alert(e.message);
    }

    map.on('locationfound', onLocationFound);
    map.on('locationerror', onLocationError);

    map.locate({setView: true, maxZoom: 16});