0
現在地を追跡し、google.maps.Polylineで描画するアプリケーションを作成しています。 問題は、停止しても、現在の場所が変わってしまうことです。まっすぐ歩いている間も起こります。このように:Cordova Geolocation間違った座標
var watchOptions = { timeout: 1000, enableHighAccuracy: false // get the same behaviour with 'true' };
var track = []; // coordinates to draw with Polyline
watch = $cordovaGeolocation.watchPosition(watchOptions);
changeMarker(myMarker, latLng);
watch.then(
null,
function(err) {
console.log(err);
},
function(position) {
var latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
// push current position to array
track.push({ lat: position.coords.latitude, lng: position.coords.longitude});
var trackPath = new google.maps.Polyline({
path: track, // pass coordinates
strokeColor: "#2980b9",
geodesic: true,
strokeOpacity: 1.0,
strokeWeight: 2
});
// draw on map
trackPath.setMap($scope.map);
を、位置はセルラーデータを使用するよりもより正確です。間違った座標を防ぐ方法はありますか? – Cristiano
正確な精度をメートルで示す 'position.coords.accuracy'値があります。携帯データの場合、この値ははるかに高いので、不正確な位置を無視するために使用することができます。if(position.coords.accuracy> 50)はconsole.logを返します(「位置が不正確です。 – DaveAlden