cordova - Phonegap - Android Geolocation is not accurate -
i use cordova
// platform: android // 3.5.1
when use geolocation
var options = {enablehighaccuracy: true}; navigator.geolocation.getcurrentposition(that.geosuccess, that.geoerror, options); this.geosuccess = function(position) { console.log("geosuccess :"+position.coords.latitude+", "+ position.coords.longitude) that.mylocation = new google.maps.latlng(position.coords.latitude, position.coords.longitude); };
i in log:
31.4956033, 34.9326514
which 3.7 kilometre actual location.
any idea why? or how fix?
on ios following position:
31.518463052524, 34.90405467862522
which actual position, therefore code correct.
when use google map (on android device) position correct, therefore it's not hardware problem.
in manifest have:
<uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-permission android:name="android.permission.access_location_extra_commands" />
i noticed problem well. however, when polled location change using watchposition, fixed me. can tell, initial gps fix inaccurate. given time closes distance.
something like:
watchid = navigator.geolocation.watchposition(onsuccess, onerror, options); function onsuccess(position) { var mylatlng = new google.maps.latlng(position.coords.latitude, position.coords.longitude); map.setcenter(mylatlng); if(marker!=null) marker.setmap(null); marker = new google.maps.marker({ position: mylatlng, map: map, title: 'my location' }); }
Comments
Post a Comment