Forum Xamarin.Forms

Help with Geolocator.

Hi. I'm developing an app that has to get the location of the user, and depending on this, ask an api to get the nearest places.
I'm currently using this plugin to get the position:

var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 50;

var position = await locator.GetPositionAsync (timeout: 10000);

Console.WriteLine ("Position Status: {0}", position.Timestamp);
Console.WriteLine ("Position Latitude: {0}", position.Latitude);
Console.WriteLine ("Position Longitude: {0}", position.Longitude);

And getting good results.
The problem comes when I want to execute the second method (getJSON()) AFTER get the location. As the location is an async method, I'm sending the request to the getJSON() BEFORE get the response of the getPosition().

What I'd need is execute getPosition(), and after the position is recieved, execute getJSON(currentposition)

Any Idea on how could I manage this?


Sign In or Register to comment.