-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Leaflet.MarkerCluster Plugin Added
- Loading branch information
Showing
9 changed files
with
84 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
BlazorLeafletInterop/Plugins/Leaflet.MarkerCluster/Components/MarkerClusterGroup.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
@using BlazorLeafletInterop.Components.Layers.Misc | ||
@using BlazorLeafletInterop.Components.Layers.Misc; | ||
@using BlazorLeafletInterop.Plugins.Leaflet.MarkerCluster.Models.Options; | ||
@using Microsoft.AspNetCore.Components; | ||
@using Microsoft.JSInterop; | ||
|
||
@namespace BlazorLeafletInterop.Plugins.Leaflet.MarkerCluster.Components | ||
|
||
@inherits FeatureGroup | ||
|
||
<CascadingValue Name="MarkerClusterGroup" Value="@this"> | ||
@ChildContent | ||
</CascadingValue> | ||
|
||
@code { | ||
[Parameter] | ||
public MarkerClusterGroupOptions Options { get; set; } = new(); | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
await base.OnInitializedAsync(); | ||
JsObjectReference = await CreateMarkerClusterGroup(); | ||
if (Map is null || JsObjectReference is null) return; | ||
await AddTo<MarkerClusterGroup>(Map.MapRef, JsObjectReference); | ||
} | ||
|
||
private async Task<IJSObjectReference> CreateMarkerClusterGroup() | ||
{ | ||
var module = await LayerFactory.GetModule(); | ||
return await module.InvokeAsync<IJSObjectReference>("createMarkerClusterGroup", Options); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...rLeafletInterop/Plugins/Leaflet.MarkerCluster/Models/Options/MarkerClusterGroupOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace BlazorLeafletInterop.Plugins.Leaflet.MarkerCluster.Models.Options; | ||
|
||
public class MarkerClusterGroupOptions | ||
{ | ||
public int MaxClusterRadius { get; set; } = 80; | ||
public bool SpiderfyOnEveryZoom { get; set; } = true; | ||
public bool ShowCoverageOnHover { get; set; } = true; | ||
public bool ZoomToBoundsOnClick { get; set; } = true; | ||
public bool SingleMarkerMode { get; set; } = false; | ||
public int? DisableClusteringAtZoom { get; set; } = null; | ||
public bool RemoveOutsideVisibleBounds { get; set; } = true; | ||
public bool Animate { get; set; } = true; | ||
public bool AnimateAddingMarkers { get; set; } = false; | ||
public int SpiderfyDistanceMultiplier { get; set; } = 1; | ||
public bool ChunkedLoading { get; set; } = true; | ||
public int ChunkInterval { get; set; } = 200; | ||
public int ChunkDelay { get; set; } = 50; | ||
} |
5 changes: 5 additions & 0 deletions
5
BlazorLeafletInterop/TypeScript/Plugins/leaflet-markercluster.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type * as L from "leaflet"; | ||
export function createMarkerClusterGroup(options: L.MarkerClusterGroupOptions): L.MarkerClusterGroup { | ||
// @ts-ignore | ||
return L.markerClusterGroup(options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters