From 1d53ecccf55eb3f13f8940729b2f7e8ecaef0042 Mon Sep 17 00:00:00 2001 From: crazzywak Date: Mon, 4 Nov 2024 12:57:59 +0100 Subject: [PATCH] Fix ZoomToRect --- GMap.NET/GMap.NET.Avalonia/GMapControl.cs | 2 +- GMap.NET/GMap.NET.Core/Internals/Core.cs | 2 +- GMap.NET/GMap.NET.WindowsForms/GMapControl.cs | 2 +- GMap.NET/GMap.NET.WindowsPresentation/GMapControl.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/GMap.NET/GMap.NET.Avalonia/GMapControl.cs b/GMap.NET/GMap.NET.Avalonia/GMapControl.cs index 2a8f0231..28518737 100644 --- a/GMap.NET/GMap.NET.Avalonia/GMapControl.cs +++ b/GMap.NET/GMap.NET.Avalonia/GMapControl.cs @@ -1216,7 +1216,7 @@ public bool SetZoomToFitRect(RectLatLng rect) if (maxZoom > 0) { var center = - new PointLatLng(rect.Lat - rect.HeightLat / 2, rect.Lng + rect.WidthLng / 2); + new PointLatLng(rect.Lat + rect.HeightLat / 2, rect.Lng + rect.WidthLng / 2); Position = center; if (maxZoom > MaxZoom) diff --git a/GMap.NET/GMap.NET.Core/Internals/Core.cs b/GMap.NET/GMap.NET.Core/Internals/Core.cs index ffe43bd9..a1b5764a 100644 --- a/GMap.NET/GMap.NET.Core/Internals/Core.cs +++ b/GMap.NET/GMap.NET.Core/Internals/Core.cs @@ -261,7 +261,7 @@ public bool SetZoomToFitRect(RectLatLng rect) int mmaxZoom = GetMaxZoomToFitRect(rect); if (mmaxZoom > 0) { - var center = new PointLatLng(rect.Lat - rect.HeightLat / 2, rect.Lng + rect.WidthLng / 2); + var center = new PointLatLng(rect.Lat + rect.HeightLat / 2, rect.Lng + rect.WidthLng / 2); Position = center; if (mmaxZoom > MaxZoom) diff --git a/GMap.NET/GMap.NET.WindowsForms/GMapControl.cs b/GMap.NET/GMap.NET.WindowsForms/GMapControl.cs index 4d3cdd2c..06a8bf1e 100644 --- a/GMap.NET/GMap.NET.WindowsForms/GMapControl.cs +++ b/GMap.NET/GMap.NET.WindowsForms/GMapControl.cs @@ -748,7 +748,7 @@ public bool SetZoomToFitRect(RectLatLng rect) int maxZoom = Core.GetMaxZoomToFitRect(rect); if (maxZoom > 0) { - var center = new PointLatLng(rect.Lat - rect.HeightLat / 2, rect.Lng + rect.WidthLng / 2); + var center = new PointLatLng(rect.Lat + rect.HeightLat / 2, rect.Lng + rect.WidthLng / 2); Position = center; if (maxZoom > MaxZoom) diff --git a/GMap.NET/GMap.NET.WindowsPresentation/GMapControl.cs b/GMap.NET/GMap.NET.WindowsPresentation/GMapControl.cs index cb42681c..1439a364 100644 --- a/GMap.NET/GMap.NET.WindowsPresentation/GMapControl.cs +++ b/GMap.NET/GMap.NET.WindowsPresentation/GMapControl.cs @@ -1274,7 +1274,7 @@ public bool SetZoomToFitRect(RectLatLng rect) if (maxZoom > 0) { var center = - new PointLatLng(rect.Lat - rect.HeightLat / 2, rect.Lng + rect.WidthLng / 2); + new PointLatLng(rect.Lat + rect.HeightLat / 2, rect.Lng + rect.WidthLng / 2); Position = center; if (maxZoom > MaxZoom)