Skip to content

Commit

Permalink
feat: enable passing marker cluster options
Browse files Browse the repository at this point in the history
  • Loading branch information
Gugustinette committed Dec 9, 2024
1 parent 594eb6e commit 836eca8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 8 additions & 1 deletion playground/pages/map/markercluster.client.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ const locations = [
const onMapReady = async () => {
const { markers, markerCluster } = await useLMarkerCluster({
leafletObject: map.value.leafletObject,
markers: locations
markers: locations,
options: {
// showCoverageOnHover: true
// zoomToBoundsOnClick: true
// spiderfyOnMaxZoom: true
// removeOutsideVisibleBounds: true
// spiderLegPolylineOptions: { weight: 1.5, color: '#222', opacity: 0.5 }
}
});
// Access the markers
markers[3].bindPopup('<h1>Hello Pornic</h1><button type="button" style="background: black; color: white;">Click me</button>');
Expand Down
11 changes: 10 additions & 1 deletion src/runtime/composables/useLMarkerCluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,18 @@ interface MarkerProps {
popup?: string
}

interface MarkerClusterGroupOptions {
showCoverageOnHover?: boolean
zoomToBoundsOnClick?: boolean
spiderfyOnMaxZoom?: boolean
removeOutsideVisibleBounds?: boolean
spiderLegPolylineOptions?: any
}

interface Props {
leafletObject: Map
markers: MarkerProps[]
options?: MarkerClusterGroupOptions
}

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

// Initialize marker cluster
const markerCluster = new MarkerClusterGroup()
const markerCluster = new MarkerClusterGroup(props.options)

// Create an array to store the markers
const markers = [] as Marker[]
Expand Down

0 comments on commit 836eca8

Please sign in to comment.