From 63c06188d26e6af20eb39502b528788726f30dba Mon Sep 17 00:00:00 2001 From: mike lorengo Date: Wed, 6 Nov 2024 22:17:50 -0800 Subject: [PATCH] Fixes [BUG] Map not responding to span (zoom) requests in Windows #1686 (#2323) --- .../Handler/Map/MapHandler.Windows.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/CommunityToolkit.Maui.Maps/Handler/Map/MapHandler.Windows.cs b/src/CommunityToolkit.Maui.Maps/Handler/Map/MapHandler.Windows.cs index ac60f4e73..71d8492e9 100644 --- a/src/CommunityToolkit.Maui.Maps/Handler/Map/MapHandler.Windows.cs +++ b/src/CommunityToolkit.Maui.Maps/Handler/Map/MapHandler.Windows.cs @@ -170,7 +170,7 @@ protected override void DisconnectHandler(FrameworkElement platformView) mapHandler.regionToGo = newRegion; } - CallJSMethod(handler.PlatformView, $"setRegion({newRegion.Center.Latitude.ToString(CultureInfo.InvariantCulture)},{newRegion.Center.Longitude.ToString(CultureInfo.InvariantCulture)});"); + CallJSMethod(handler.PlatformView, $"setRegion({newRegion.Center.Latitude.ToString(CultureInfo.InvariantCulture)},{newRegion.Center.Longitude.ToString(CultureInfo.InvariantCulture)},{newRegion.LatitudeDegrees.ToString(CultureInfo.InvariantCulture)},{newRegion.LongitudeDegrees.ToString(CultureInfo.InvariantCulture)});"); } static void CallJSMethod(FrameworkElement platformWebView, string script) @@ -290,11 +290,9 @@ function setMapType(mauiMapType) }); } - function setRegion(latitude, longitude) + function setRegion(latitude, longitude, latitudeDegrees, longitudeDegrees) { - map.setView({ - center: new Microsoft.Maps.Location(latitude, longitude), - }); + map.setView({bounds: new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(latitude, longitude), latitudeDegrees, longitudeDegrees) }); } function addLocationPin(latitude, longitude)