I am using cordova 2.9.0 with PhoneGap Build. I wrote an application in which a user can register in a special place at a specific time. My problem is that when I install the application on various devices, I sometimes get a time schedule (this only happens on Android devices). When I restart the device, geolocation works, and I get GPS data. Now I would like to know if there is another way to solve this problem. My geolocation code in deviceReady function:
var geo = cordova.require('cordova/plugin/geolocation'); var optionsGeo = {maximumAge: 0, timeout: 30000, enableHighAccuracy: false}; var watchID = geo.watchPosition(onSuccessGeo, errorGeo, optionsGeo); function onSuccessGeo(position) { lat = (position.coords.latitude).toFixed(6); lon = (position.coords.longitude).toFixed(6); accuracy = (position.coords.accuracy).toFixed(0); console.log("Lat " + lat + " Lon " + lon + " & " + accuracy + "m"); } function errorGeo(error) { console.log("Geo-Fehler! Code: " + error.code + " Nachricht: " + error.message); }
I tried with different timeout values ββand with HighAccuracy enabled, but nothing helps. Thanks.
source share