第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

geoloc.getCurrentPosition有時不起作用

geoloc.getCurrentPosition有時不起作用

胡說叔叔 2019-08-03 07:03:38
geoloc.getCurrentPosition有時不起作用因此,我有一個非常簡單的JS使用導(dǎo)航器.geolocation.getCurrentPoitationjammy。$(document).ready(function(){   $("#business-locate, #people-locate").click(function() {     navigator.geolocation.getCurrentPosition(foundLocation, noLocation);   });   navigator.geolocation.getCurrentPosition(foundLocation, noLocation);   function foundLocation(position) {     var lat = position.coords.latitude;     var lon = position.coords.longitude;     var userLocation = lat + ', ' + lon;     $("#business-current-location, #people-current-location").remove();     $("#Near-Me")       .watermark("Current Location")       .after("<input type='hidden' name='business-current-location' id='business-current-location' value='"+userLocation+"' />");     $("#people-Near-Me")       .watermark("Current Location")       .after("<input type='hidden' name='people-current-location' id='people-current-location' value='"+userLocation+"' />");   }   function noLocation() {     $("#Near-Me").watermark("Could not find location");     $("#people-Near-Me").watermark("Could not find location");   }})//end DocReady基本上,我們得到的是當前位置,如果得到了,兩個“水印”放置在兩個字段中,上面寫著“當前位置”,兩個隱藏字段是以長數(shù)據(jù)作為值創(chuàng)建的(它們在開始時被刪除,這樣它們就不會每次都被復(fù)制)。還有兩個按鈕有一個點擊函數(shù)綁定到它們來做同樣的事情。不幸的是,每隔三次左右,它就起作用了。這里有什么問題?
查看完整描述

3 回答

?
慕的地6264312

TA貢獻1817條經(jīng)驗 獲得超6個贊


這是我要解決的問題,至少在當前的所有瀏覽器中都能工作(在Windows上,我沒有Mac):

if (navigator.geolocation) {
    var location_timeout = setTimeout("geolocFail()", 10000);

    navigator.geolocation.getCurrentPosition(function(position) {
        clearTimeout(location_timeout);

        var lat = position.coords.latitude;
        var lng = position.coords.longitude;

        geocodeLatLng(lat, lng);
    }, function(error) {
        clearTimeout(location_timeout);
        geolocFail();
    });} else {
    // Fallback for no geolocation
    geolocFail();}

如果有人在Firefox上單擊“關(guān)閉”或選擇“NO”或“從不共享”選項,這也會有效。

笨重但有效。



查看完整回答
反對 回復(fù) 2019-08-05
?
翻過高山走不出你

TA貢獻1875條經(jīng)驗 獲得超3個贊

我每次都這樣:

navigator.geolocation.getCurrentPosition(getCoor, errorCoor, {maximumAge:60000, timeout:5000, enableHighAccuracy:true});

雖然不是很準確。有趣的是,在同一臺設(shè)備上,如果我運行這臺設(shè)備,它會把我推到100米左右(每次),但如果我去谷歌地圖,它就能準確地找到我的位置。因此,盡管我認為enableHighAccuracy:true有助于它持續(xù)工作,但它似乎并不能使它更加準確.




查看完整回答
反對 回復(fù) 2019-08-05
  • 3 回答
  • 0 關(guān)注
  • 755 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號