public async Task<GeoCoords> GetLocationAsync() { var locator = new Geolocator(this._appContext) { DesiredAccuracy = 30 }; var position = await locator.GetPositionAsync(30000); var result = new GeoCoords { Latitude = position.Latitude, Longitude = position.Longitude }; return result; }
public async Task<GeoCoords> GetLocationAsync() { var geolocator = new Windows.Devices.Geolocation.Geolocator(); var geoposition = await geolocator.GetGeopositionAsync(); var coords = new GeoCoords { Latitude = geoposition.Coordinate.Latitude, Longitude = geoposition.Coordinate.Longitude }; return coords; }
public async Task<VenuesResponse> GetVenues(string query, GeoCoords coords) { var v = DateTime.Now.ToString("yyyyMMdd"); var ll = string.Format("{0},{1}", coords.Latitude, coords.Longitude); var url = string.Format(@"https://api.foursquare.com/v2/venues/search?ll={0}&query={1}&client_id={2}&client_secret={3}&v={4}", ll, query, _CLIENT_ID, _CLIENT_SECRET, v); var client = new HttpClient(); var response = await client.GetStringAsync(url); JObject o = JObject.Parse(response); return await Task.Factory.StartNew(() => JsonConvert.DeserializeObject<VenuesResponse>(o["response"].ToString())); }