The website I'm working on uses HTML5 geolocation api. It works fine, but I need to know if the feature has been authorized.
navigator.geolocation
only tells if the feature is available. What I want to know is whether the user has enabled it already. Basically, I need to know if the browser will request permission to use the feature. Is it possible?
If the user does not allow your app to use the Geolocation API the methods getCurrentPosition
and watchPosition
will return an PositionError object via the error callback:
void getCurrentPosition(successCallback,
errorCallback,
options);
long watchPosition(successCallback,
errorCallback,
options);
The PositionError looks like:
PositionError {
code;
message;
};
where the possibles values of code are:
PositionError.PERMISSION_DENIED = 1;
PositionError.POSITION_UNAVAILABLE = 2;
PositionError.TIMEOUT = 3;
And more specific:
The documentation here.