3

I inserted a simple button for geolocation into a Leaflet-generated map by adding

L.control.locate().addTo(map);  

into my HTML file.

In Chrome and Firefox it works great, Safari and Internet Expolorer are rejecting the function by showing following error:

english: "geolocation error: This website does not have permission to use the Geolocation API"

german: "geolocation error: Diese Website verfügt nicht über die Berechtigung zur Verwendung der Geolocation-API"

Do you have any idea, where this issue can come from? I've tried to use the functionality on different browsers on different devices (desktop and mobile), all with the same error. I've checked the location permissions on the devices as well.

  • Late but worth mentioning: make sure your site is served over https:// – Marc Pfister Dec 29 '18 at 20:22
1

In Firefox you can give the geolocation permission per website:

Screenshot of Firefox's permission settings

Screenshot of Firefox's location permission settings

I assume that it is the same for other browsers. So while the browser itself can have permission to access the Geolocation API, it could be blocked for your specific application.

PS.: I wonder if Internet Explorer even supports the Geolocation API. For Safari, this support article could help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.