public static async Task <SearchByBBoxResult> GetLocationByBBox(SearchByBBox bbox) { var jsonData = bbox.ToJson(); var httpResponseMessage = await HttpUtils.MakeRequest(Constants.LocationSearchByBBoxUrl, jsonData, HttpUtils.HttpMethod.Post); var responseData = await HttpUtils.ProcessResponse(httpResponseMessage); var locationList = JsonConvert.DeserializeObject <SearchByBBoxResult>(responseData, new JsonSerializerSettings { ContractResolver = new SnakeCasePropertyNamesContractResolver() }); return(locationList); }
private SearchByBBox GetBoundingBox() { Geopoint topLeft, bottomRight; var width = MapControl.ActualWidth; var height = MapControl.ActualHeight; try { MapControl.GetLocationFromOffset(new Point(0, 0), out topLeft); } catch (ArgumentException) { MapControl.GetLocationFromOffset(new Point(0, height), out topLeft); topLeft = new Geopoint(new BasicGeoposition() { Latitude = -90, Longitude = topLeft.Position.Longitude }); } try { MapControl.GetLocationFromOffset(new Point(width, height), out bottomRight); } catch (ArgumentException) { MapControl.GetLocationFromOffset(new Point(width, 0), out bottomRight); bottomRight = new Geopoint(new BasicGeoposition() { Latitude = 90, Longitude = bottomRight.Position.Longitude }); } var bbox = new SearchByBBox { LatMax = (float)topLeft.Position.Latitude, LongMin = (float)topLeft.Position.Longitude, LatMin = (float)bottomRight.Position.Latitude, LongMax = (float)bottomRight.Position.Longitude }; return(bbox); }