Skip to content

Commit ad7e55e

Browse files
committed
fix: use L.DomUtil.create() instead of L.popup()
1 parent 3fbe325 commit ad7e55e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

playground/pages/map/markercluster.client.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ const onMapReady = async () => {
7979
markers: locations
8080
});
8181
// Access the markers
82-
markers[3].bindPopup('Hello Pornic');
82+
markers[3].bindPopup('<h1>Hello Pornic</h1><button type="button" style="background: black; color: white;">Click me</button>');
83+
const popupDiv = markers[2].getPopup()?.getContent() as HTMLElement;
84+
popupDiv.addEventListener('click', () => {
85+
console.log("click")
86+
});
8387
// Access the markerCluster
8488
markerCluster.on('clusterclick', (event: any) => {
8589
console.log('Cluster clicked', event);

src/runtime/composables/useLMarkerCluster.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ export const useLMarkerCluster = async (props: Props) => {
4040

4141
// If a popup is provided, bind it to the marker
4242
if (location.popup) {
43-
marker.bindPopup(L.popup().setContent(location.popup))
43+
const popup = L.DomUtil.create('div', 'popup')
44+
popup.innerHTML = location.popup
45+
marker.bindPopup(popup)
4446
}
4547

4648
// Add the marker to the cluster

0 commit comments

Comments
 (0)