Skip to content

Commit 836eca8

Browse files
committed
feat: enable passing marker cluster options
1 parent 594eb6e commit 836eca8

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

playground/pages/map/markercluster.client.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,14 @@ const locations = [
7676
const onMapReady = async () => {
7777
const { markers, markerCluster } = await useLMarkerCluster({
7878
leafletObject: map.value.leafletObject,
79-
markers: locations
79+
markers: locations,
80+
options: {
81+
// showCoverageOnHover: true
82+
// zoomToBoundsOnClick: true
83+
// spiderfyOnMaxZoom: true
84+
// removeOutsideVisibleBounds: true
85+
// spiderLegPolylineOptions: { weight: 1.5, color: '#222', opacity: 0.5 }
86+
}
8087
});
8188
// Access the markers
8289
markers[3].bindPopup('<h1>Hello Pornic</h1><button type="button" style="background: black; color: white;">Click me</button>');

src/runtime/composables/useLMarkerCluster.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,18 @@ interface MarkerProps {
1111
popup?: string
1212
}
1313

14+
interface MarkerClusterGroupOptions {
15+
showCoverageOnHover?: boolean
16+
zoomToBoundsOnClick?: boolean
17+
spiderfyOnMaxZoom?: boolean
18+
removeOutsideVisibleBounds?: boolean
19+
spiderLegPolylineOptions?: any
20+
}
21+
1422
interface Props {
1523
leafletObject: Map
1624
markers: MarkerProps[]
25+
options?: MarkerClusterGroupOptions
1726
}
1827

1928
export const useLMarkerCluster = async (props: Props) => {
@@ -25,7 +34,7 @@ export const useLMarkerCluster = async (props: Props) => {
2534
const { MarkerClusterGroup } = await import('leaflet.markercluster')
2635

2736
// Initialize marker cluster
28-
const markerCluster = new MarkerClusterGroup()
37+
const markerCluster = new MarkerClusterGroup(props.options)
2938

3039
// Create an array to store the markers
3140
const markers = [] as Marker[]

0 commit comments

Comments
 (0)