Hello,
I'm trying to get devices position and Ti.GeoLocation.getCurrentPosition() is returning old data, judging by the timestamp and location it's providing. I ran GoogleMaps yesterday and it showed my position then, but now when I run my own application and try to get current position, it's still returning that old position from GoogleMaps, which is about 80km away from my current location. So...help? :)
Oh and, the application must work with both, GPS and network geolocation, depending on which is available.
Code:
function GetLocation() { if (Ti.Geolocation.locationServicesEnabled) { Ti.Geolocation.purpose = 'Get Current Location'; Ti.Geolocation.preferredProvider = Ti.Geolocation.PROVIDER_NETWORK; Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_LOW; Ti.Geolocation.getCurrentPosition(function(e) { if (e.error) { alert('Error: ' + e.error); } else { alert(e.coords); } }); } else { alert('Please enable location services'); } return ""; }
1 Answer
Accepted Answer
getCurrentLocation gets a "cached" value of the coordinates. It doesn't start the gps on the device so is not taking the real current position. You will have to use the location event for this.
Your Answer
Think you can help? Login to answer this question!