2017-03-18 11 views
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); 

答えて

0

はまず、低精度ネットワーク三角測量を使用するenableHighAccuracy: false設定、enableHighAccuracy: trueとは対照的に、GPSハードウェアを係合する:

enter image description here

これはコードです。ナビゲーション(歩行など)の場合、常にtrueに設定する必要があります。

でも、GPSの位置は正確ではありません。あなたのデバイスのGPSハードウェア、木々や建物などの不明瞭なもの、衛星の数ロックされています。頻繁に送達される高精度の位置を有効にする

、Iのような設定をお勧めします:のWi-Fiを使用する場合

{ 
    enableHighAccuracy: true, 
    maxAge: 0, 
    timeout: 30000 
} 
+0

を、位置はセルラーデータを使用するよりもより正確です。間違った座標を防ぐ方法はありますか? – Cristiano

+0

正確な精度をメートルで示す 'position.coords.accuracy'値があります。携帯データの場合、この値ははるかに高いので、不正確な位置を無視するために使用することができます。if(position.coords.accuracy> 50)はconsole.logを返します(「位置が不正確です。 – DaveAlden

関連する問題