diff --git a/BlazorLeafletInterop/Components/Layers/Misc/FeatureGroup.razor.cs b/BlazorLeafletInterop/Components/Layers/Misc/FeatureGroup.razor.cs index 2ab0a3f..ba0c7e2 100644 --- a/BlazorLeafletInterop/Components/Layers/Misc/FeatureGroup.razor.cs +++ b/BlazorLeafletInterop/Components/Layers/Misc/FeatureGroup.razor.cs @@ -45,7 +45,7 @@ public async Task BringToBack() /// /// Returns the LatLngBounds of the Feature Group (created from bounds and coordinates of its children). /// - /// IJSObjectReference + /// LatLngBounds /// public async Task GetBounds() { diff --git a/BlazorLeafletInterop/Models/Basics/LatLng.cs b/BlazorLeafletInterop/Models/Basics/LatLng.cs index 0d7a7cf..5ffcbcc 100644 --- a/BlazorLeafletInterop/Models/Basics/LatLng.cs +++ b/BlazorLeafletInterop/Models/Basics/LatLng.cs @@ -1,4 +1,6 @@ -namespace BlazorLeafletInterop.Models.Basics; +using System.Text.Json.Serialization; + +namespace BlazorLeafletInterop.Models.Basics; public class LatLng { @@ -20,8 +22,11 @@ public LatLng(double lat, double lng, double alt) Alt = alt; } + [JsonPropertyName("lat")] public double Lat { get; set; } + [JsonPropertyName("lng")] public double Lng { get; set; } + [JsonPropertyName("alt")] public double Alt { get; set; } public double GetDistanceToPointInMiles(LatLng to) diff --git a/BlazorLeafletInterop/Models/Basics/LatLngBounds.cs b/BlazorLeafletInterop/Models/Basics/LatLngBounds.cs index c3f6daa..4a05b5d 100644 --- a/BlazorLeafletInterop/Models/Basics/LatLngBounds.cs +++ b/BlazorLeafletInterop/Models/Basics/LatLngBounds.cs @@ -1,4 +1,6 @@ -namespace BlazorLeafletInterop.Models.Basics; +using System.Text.Json.Serialization; + +namespace BlazorLeafletInterop.Models.Basics; public class LatLngBounds { @@ -15,8 +17,10 @@ public LatLngBounds(LatLng southwest, LatLng northeast) } // ReSharper disable once MemberCanBePrivate.Global + [JsonPropertyName("_southWest")] public LatLng SouthWest { get; set; } // ReSharper disable once MemberCanBePrivate.Global + [JsonPropertyName("_northEast")] public LatLng NorthEast { get; set; } public LatLngBounds Extend(LatLng point) diff --git a/ExampleApp/Pages/GeoJsonTest.razor b/ExampleApp/Pages/GeoJsonTest.razor index c3d5495..33d3f04 100644 --- a/ExampleApp/Pages/GeoJsonTest.razor +++ b/ExampleApp/Pages/GeoJsonTest.razor @@ -18,6 +18,7 @@

Blazor Leaflet Interop GeoJson Test

+ @code { @@ -61,6 +62,13 @@ base.OnInitialized(); CreateRandomMarkersForFeatureCollection(); } + + private async Task GetBounds() + { + if (GeoJsonLayer == null) return; + var bounds = await GeoJsonLayer.GetBounds(); + if (bounds != null) Console.WriteLine(bounds.ToBBoxString()); + } private void GenerateNewFeatureCollection() {