Closed webalchemist closed 10 years ago
There is no way to update the location more frequently. But I will try to improve this issue.
I am currently using the cordova gelocation plugin to achieve more frequent updates. I attach the geolocation watch:
navigator.geolocation.getCurrentPosition(geolocationSuccess,
[geolocationError],
[geolocationOptions]);
then I use the geolocationSuccess
to update the googlemaps-plugin camera position.
function geolocationSuccess(position) {
plugin.google.maps.LatLng(position.coords.latitude,position.coords.longitude);
map.moveCamera({
'target': currentLocation,
'zoom': 16
});
}
I know that I am using 2 plugin but at least I know I am using the best in the geolocalization and the best on the google map.
Thank you, @fabriziogiordano , and sorry for your inconvenience.
This plugin uses the "getLastKnownLocation" in Android, because I think the App should save the battery of the device. But I know the "getLastKnowLocation" is not best way especially for tracking. I'm planing to provide another way to tracking the current location, and also an option to get the current location mandatory.
The current solution is @fabriziogiordano way.
Thanks for the quick replies.
The cordova-geolocation-plugin has been deprecated. I believe the code has already been removed in cordova 3.5.0 (see https://issues.apache.org/jira/browse/CB-5977). I think you're now supposed to use the HTML5 browser geolocation directly. The code is exactly the same as using the plugin.
I was previously using the geolocation plugin and then the HTML5 version without the plugin, but after installing the googlemaps-plugin it stopped working. I just get timeouts now. That's why I tried using the geolocation from the googlemaps-plugin.
I'll try again to get the HTML5 geolocation code working with the googlemaps-plugin.
Umm, the googlemaps-plugin should not disrupt the HTML5 geolocation API though :(
How about this plugin? https://github.com/christocracy/cordova-plugin-background-geolocation
Thank you @webalchemist So far my app is working. I will have to update my code then on future releases.
For anyone following this issue - I've now got the HTML5 geolocation working with the googlemaps plugin.
I'm not sure what the issue was, but a clean rebuild and a reboot of the phone and everything was working again!
:+1:
@webalchemist I tried the same thing using navigator.geolocation.getCurrentPosition()
on iOS but the phone triggered the permission dialog twice: once as the app and the second one as the .html file within the browser. See the second permission in attached pic. Any suggestion?
@quanghoc Did you add the cordova plugin for geolocation? - if not you are using html 5, simply add geolocation plugin
I'm trying to convert an app from the google maps web API to the android API using your plugin.
The problem I'm having is that the app using tracking and the results from getMyLocation() only seem to change every few minutes - even though I'm calling it every 3 seconds.
Is there a way to get more frequently updated location data?