Search code examples
javascriptvue.jsgeolocationgoogle-geolocationvue2-google-maps

Google geolocation.getcurrentposition doesn't work after refresh page on mobile


A made a website which use a Google Geolocation Javascipt API, with vue2-google-maps package. The relevant code like:

`geolocate () {
            var self = this
            this.loading = true
            navigator.geolocation.getCurrentPosition(position => {
                this.loading = true
                this.center = {
                    lat: position.coords.latitude,
                    lng: position.coords.longitude
                }
}`

The problem is, that if user open page, and click on the pop-up window and don't allow location, the MOBILE browser save it somewhere, and if user refresh the page, the pop-up window, which ask user that want a share own location or not, didn't appear again.

Is there any way, that if refresh the page, the pop-up window will appear on every refresh?

I tried to delete the -> setting -> webpage setting -> location -> my site, but after refresh and accept again the browser automatically save my answer behind the scene and the third refresh, the pop-up window again does not appear :(


Solution

  • As mentioned by @matthew-shwery, you can't.

    The user must manage their browser settings manually because your site is added to a blacklist when denied location permissions.

    You might consider to notify the user. See Request location coordinates after user has blocked access in javascript