From 2ec5094481baae6a05a233fe1bc941e346c4d9c7 Mon Sep 17 00:00:00 2001 From: Dmitry Kaznacheev Date: Wed, 7 Feb 2024 20:55:24 +1000 Subject: [PATCH] some map updates --- src/GenOne.Blazor.Map/src/Component/Map.razor.cs | 11 +++++++++-- src/GenOne.Blazor.Map/src/EventedExtensions.cs | 7 ++++++- src/GenOne.Blazor.Map/src/IMapIconFactory.cs | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/GenOne.Blazor.Map/src/Component/Map.razor.cs b/src/GenOne.Blazor.Map/src/Component/Map.razor.cs index 6465e40..bfc0a38 100644 --- a/src/GenOne.Blazor.Map/src/Component/Map.razor.cs +++ b/src/GenOne.Blazor.Map/src/Component/Map.razor.cs @@ -108,8 +108,15 @@ public async Task ViewAllMarkers(bool flyTo = true, int? zoom = null) switch (MarkerPosition is not null, ConsumerLocation is not null) { case (true, true): - var bounds = GeoBounds.FromLocations(MarkerPosition!, ConsumerLocation!.Location); - await _map.FlyToBounds(bounds.LatLngBounds()); + var bounds = GeoBounds.FromLocations(MarkerPosition!, ConsumerLocation!.Location).LatLngBounds(); + if (flyTo) + { + await _map.FlyToBounds(bounds); + } + else + { + await _map.FitBounds(bounds); + } break; case (true, false): diff --git a/src/GenOne.Blazor.Map/src/EventedExtensions.cs b/src/GenOne.Blazor.Map/src/EventedExtensions.cs index a27da16..c2147f7 100644 --- a/src/GenOne.Blazor.Map/src/EventedExtensions.cs +++ b/src/GenOne.Blazor.Map/src/EventedExtensions.cs @@ -14,7 +14,12 @@ public static Task OnDragStart(this Evented evented, Func call return evented.On("dragstart", callback); } - public static Task OnMoveEnd(this Evented evented, Func callback) + public static Task OnZoomStart(this Evented evented, Func callback) + { + return evented.On("zoomstart", callback); + } + + public static Task OnMoveEnd(this Evented evented, Func callback) { return evented.On("moveend", callback); } diff --git a/src/GenOne.Blazor.Map/src/IMapIconFactory.cs b/src/GenOne.Blazor.Map/src/IMapIconFactory.cs index cbbd9a4..9b006db 100644 --- a/src/GenOne.Blazor.Map/src/IMapIconFactory.cs +++ b/src/GenOne.Blazor.Map/src/IMapIconFactory.cs @@ -2,6 +2,7 @@ namespace GenOne.Blazor.Map; +//todo better to split factories and use delegates public interface IMapIconFactory { Task PrepareMarkerOptions(bool draggable);