【发布时间】:2016-07-12 06:41:19
【问题描述】:
我在 html 网页中有一个按钮,单击该按钮后它将获得 Geolocation 详细信息,可能是请求将处理大约 5 seconds,因此最好显示微调器或加载消息用户表明他们的请求正在处理中。
这是我尝试过的。
if (navigator.geolocation) {
//request starts Showing the spinner at this point.
navigator.geolocation.getCurrentPosition(function(position) {
//get coordinates
}, function (error) {
// Handle errors !!This callback isn't execute if a user close the
// geolocation prompt or click on `Not Now` option in the prompt
// So its not always correct to hide the spinner in here.
}, {enableHighAccuracy: true, timeout: 8000});
}
在errorCallback 中隐藏微调器并不总是正确的,因为如果用户close Geolocation prompt 或单击提示中的Not Now 选项,则不会执行此回调,如下图所示。
最好的方法是什么?
【问题讨论】:
标签: javascript jquery html geolocation