/// <summary> /// Zooms map to current selection. /// </summary> private void ZoomToSelection() { // Get dictionary of bounds from API IDictionary <string, PostGisPoint> bounds = new ApiHandler.ApiHandler().GetBounds().ToDictionary(pair => pair.Key, pair => pair.Value); // Ensure that bounds exist if (!bounds.TryGetValue("top_left", out PostGisPoint topLeft) || !bounds.TryGetValue("bottom_right", out PostGisPoint botRight)) { // TODO : Add some sort of error return; } BoundTopLeft = topLeft; BoundBottomRight = botRight; // Calculate the center point Geopoint centerGeopoint = new Geopoint(new BasicGeoposition { Latitude = ((BoundTopLeft.Latitude - BoundBottomRight.Latitude) / 2) + BoundBottomRight.Latitude, Longitude = ((BoundBottomRight.Longitude - BoundTopLeft.Longitude) / 2) + BoundTopLeft.Longitude }); // Set viewport to bounds MyMapControl.TrySetViewAsync(centerGeopoint, 16); }
/// <summary> /// Zooms map to current selection. /// </summary> private void ZoomToSelection() { // Calculate the center point Geopoint centerGeopoint = new Geopoint(new BasicGeoposition { Latitude = 43.1927816, Longitude = -80.3851837 }); // Set viewport to bounds MyMapControl.TrySetViewAsync(centerGeopoint, 16); }