2
當要求瀏覽器訪問當前位置的權限時,確定用戶是忽略瀏覽器提示還是選擇了「現在不是」選項的最佳方法是什麼?navigator.geolocation.getCurrentPosition的「無動作」回調在哪裏?
對於這種情況,超時似乎不起作用。
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
currentLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
callback();
}, function() {
currentLocation = default_location;
callback();
},{timeout: 5000});
}
我現在使用一種解決方案是使用默認位置currentLocation並刷新頁面/視圖隨時隨地回調之一是由於用戶回答瀏覽器提示解僱。