/// <summary> /// Sets the TargetZoomLevel and TargetCenter properties so that the specified bounding box /// fits into the current view. The TargetHeading property is set to zero. /// </summary> public void ZoomToBounds(BoundingBox boundingBox) { var rect = MapProjection.BoundingBoxToRect(boundingBox); var center = new Point(rect.X + rect.Width / 2d, rect.Y + rect.Height / 2d); var scale = Math.Min(RenderSize.Width / rect.Width, RenderSize.Height / rect.Height); TargetZoomLevel = ViewTransform.ScaleToZoomLevel(scale); TargetCenter = MapProjection.MapToLocation(center); TargetHeading = 0d; }
/// <summary> /// Transforms a Point in view coordinates to a Location in geographic coordinates. /// </summary> public Location ViewToLocation(Point point) { return(MapProjection.MapToLocation(ViewTransform.ViewToMap(point))); }