Search code examples
javascriptandroidiphonew3c-geolocation

Geolocation sharing Dialog is not showing every time on page refresh


Have written Geolocation API code for android and iphone. Take reference from http://dev.w3.org/geo/api/spec-source.html. One dialog box is showing - asking for sharing device current location. Once if I click on decline/share location, next time the dialog box is not showing. Dialog should be shown each and every time when the same page is refreshed. Below is the code sample:

function showMap(position) {
// Show a map centered at (position.coords.latitude, position.coords.longitude).
return function(position) {
    callback({
        latitude: position.coords.latitude,
        longitude: position.coords.longitude
    });
};

}

navigator.geolocation.getCurrentPosition(showMap);


Solution

  • It is browser dependent, but generally once you give a site permission to use your location, that permission is stored in the browser, and if you return, that permission will be used again. There is some controls, again depending on browser. Here's some info for Safari and Chrome:

    http://hiddencodes.wordpress.com/2012/01/16/geolocation-api-chrome-safari-permission-management-and-visual-differences/