2017-04-14 13 views
2

距離を計算するために使用するアプリを作成しました。開始位置を保存して動作し、正常に機能しているロジックを使用して、この位置からの現在位置の距離を評価します。しかし問題はnavigator.geolocation.getCurrentPosition()は同じポイントに立っていても私が変化する座標を返すことです。この座標は正確な位置から30mの距離までです。誰も私はどのように正確な座標を得ることができます示唆?navigator.geolocation.getCurrentPosition()は同じ場所に立っていても異なる座標を返すのはなぜですか?

答えて

1

試しましたenableHighAccuracytrue

var options = { 
    enableHighAccuracy: true, 
    timeout: 5000, 
    maximumAge: 0 
}; 

function success(pos) { 
    var crd = pos.coords; 

    console.log('Your current position is:'); 
    console.log(`Latitude : ${crd.latitude}`); 
    console.log(`Longitude: ${crd.longitude}`); 
    console.log(`More or less ${crd.accuracy} meters.`); 
}; 

function error(err) { 
    console.warn(`ERROR(${err.code}): ${err.message}`); 
}; 

navigator.geolocation.getCurrentPosition(success, error, options); 

出典:返信用https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition

+0

おかげで、私は真と同様に偽であることを両方enableHighAccuracyを試してみましたが、それは何のメリットもしませんでした –

関連する問題