Is your error callback being executed? If you donβt have one, try adding it. If it never fires, you can set a timeout in your function so that if it does not receive permission for a certain period of time, to display a notification.
Since errorCallback never fails if geo is disabled, create a wrapper around the function that will create the setting for another function. If any of the api callbacks are triggered, then remove the setting before it starts working.
var timeOutId; function disabledGeoHandler(){...} function show_map() { clearTimeout(timOutId); ... } function show_map_error() { clearTimeout(timOutId); ... } function lookup_location() { timeOutId = setTimeout(disabledGeoHandler, 1000); navigator.geolocation.getCurrentPosition(show_map, show_map_error); }
In fact, you can just use geo.js
source share