Skip to content

Instantly share code, notes, and snippets.

@wirasetiawan29
Created November 4, 2014 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wirasetiawan29/34c674307566ed8b277f to your computer and use it in GitHub Desktop.
Save wirasetiawan29/34c674307566ed8b277f to your computer and use it in GitHub Desktop.
public static async Task<string> TrackLocation()
{
Geolocator geoloc = new Geolocator();
Geoposition position = await geoloc.GetGeopositionAsync();
HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = new Uri("http://nominatim.openstreetmap.org");
HttpResponseMessage httpResult = await httpClient.GetAsync(
String.Format("reverse?format=json&lat={0}&lon={1}", position.Coordinate.Latitude, position.Coordinate.Longitude));
JsonObject jsonObject = JsonObject.Parse(await httpResult.Content.ReadAsStringAsync());
return jsonObject.GetNamedObject("address").GetNamedString("road") + DateTime.Now.ToString("‘ (‘HH:mm:ss')'");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment