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.
Best Answer
In Firefox you can give the geolocation permission per website:
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.