Phonegap geolocation is slow on Android
Warning: mysql_get_server_info(): Access denied for user ''@'localhost' (using password: NO) in /home/blucel/public_html/wp-content/plugins/xml-google-maps/xmlgooglemaps_dbfunctions.php on line 10
Warning: mysql_get_server_info(): A link to the server could not be established in /home/blucel/public_html/wp-content/plugins/xml-google-maps/xmlgooglemaps_dbfunctions.php on line 10
Whilst developing a geolocation based app for android using Cordova 3.3, I found that the geolocated position was not updated very fast.
Turns out that there is a setting in the geolocation plugin java files that control the minimum time that phonegap / Cordova will check for changes.
This is regardless of wether I use watchPosition or getCurrentPosition.
If I want it to check at least every 5 seconds, I can change the files as follows:
GeoBroker.java
Change line 75
from:
this.getCurrentLocation(callbackContext, enableHighAccuracy, args.optInt(2, 60000));
to:
this.getCurrentLocation(callbackContext, enableHighAccuracy, args.optInt(2, 5000));
GPSListener.java
Change line 44
from:
this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 0, this);
to:
this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 0, this);
Then remake your project.
Worked fine for me and the Nexus 7 (2013) is updating my map every second or two.
Hope this helps someone.
Mark