1

I loaded my Leaflet Map on a Server. I have a GPS Function on my Map. But every time I get the error alert "Geolocation error: User denied geolocation prompt."

What is the problem?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Patrick Wer
  • 11
  • 1
  • 2
  • 1
    Possible duplicate of [html navigator "User denied Geolocation"](https://stackoverflow.com/questions/11725594/html-navigator-user-denied-geolocation) – Ken Y-N Sep 19 '17 at 23:52
  • Plus add some code and some more information about the error – pucky124 Sep 20 '17 at 02:40

3 Answers3

4

You're probably not using https. Most modern browsers require https to use geolocation. You can check it in Mozillas Browser Compatibility list.

Qback
  • 4,310
  • 3
  • 25
  • 38
  • 1
    That doesn't help much for local app development on FF v71 when the ionic server only issues a http server. Fortunately Vivaldi v2.10.1745.21 is working with this http method and geo is working. :) – vr_driver Dec 22 '19 at 13:28
1

You can try this on Mac.

brew install nss

then

mkcert -install

then you need to allow location in your security settings.

After that it worked for me in firefox.

See also how to do https on localhost.

Pana
  • 29
  • 2
  • I recently upgraded macOS and I got this error because geolocation services were disabled by default after that upgrade. I only had to re-enable it in the system settings, but I did not have to install anything with `brew`. – Tristan Jahier Apr 08 '23 at 14:27
0

You might need to check api if you are using any webview. In my case I am trying to load map in webview using flutter in mobile device and I ran into same problem.
I was using InAppWebView to load map.
There I had the same issue which is "Geolocation error: User denied geolocation prompt".
So later I noticed I had to use androidOnGeolocationPermissionsShowPrompt parameter in InAppWebView.
I am sure other package has same method.

Kunchok Tashi
  • 2,413
  • 1
  • 22
  • 30