Ant*_*ine 3 javascript w3c-geolocation
我正在使用的网站使用HTML5地理定位API.它工作正常,但我需要知道该功能是否已被授权.
navigator.geolocation仅告知该功能是否可用.我想知道的是用户是否已经启用它.基本上,我需要知道浏览器是否会请求使用该功能的权限.可能吗?
如果用户不允许您的应用使用Geolocation API方法getCurrentPosition,watchPosition则会通过错误回调返回PositionError对象:
void getCurrentPosition(successCallback,
errorCallback,
options);
long watchPosition(successCallback,
errorCallback,
options);
Run Code Online (Sandbox Code Playgroud)
PositionError看起来像:
PositionError {
code;
message;
};
Run Code Online (Sandbox Code Playgroud)
代码的可能值是:
PositionError.PERMISSION_DENIED = 1;
PositionError.POSITION_UNAVAILABLE = 2;
PositionError.TIMEOUT = 3;
Run Code Online (Sandbox Code Playgroud)
更具体:
这里的文档.