Xamarin Mobile Geolocator

Hey there,

I've been using Xamarin Mobile in order to retrieve the current location of the user. Everything works as expected, but the code uses a hardcoded time out (see code below). Does the Xamarin Mobile api support an event when the location is found instead of using a hard coded timeout?

It's a bit useless using a 5000 milisecond timeout when the location is already found after 2000 miliseconds.

var locator = new Geolocator { DesiredAccuracy = 50 }; // new Geolocator (this) { ... }; on Android locator.GetPositionAsync (timeout: 5000).ContinueWith (t => { CurrentPosition = new ParseGeoPoint() { Longitude = t.Result.Longitude, Latitude = t.Result.Latitude }; }, TaskScheduler.FromCurrentSynchronizationContext());


  • prashantvcprashantvc USXamarin Team Xamurai

    @Mittchel IIRC the GetPositionAsync method does not wait till the timeout to invoke callback method if location information available immediately or before the time out period.

Sign In or Register to comment.