You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the infoWindow of a marker is visible and we click on a cluster somewhere else on the map, the map zooms and centers on the marker with infoWindow instead of zooming and centering on markers inside the cluster.
The text was updated successfully, but these errors were encountered:
This is an automated message, feel free to ignore.
smohadjer
changed the title
If an infoWindow is open on a map, clicking a cluster instead of zooming on markers inside the cluster will center the map on marker with visible infoWindow
Clicking a cluster zooms on marker outside it if the marker has a visible infoWindow
May 19, 2023
If I disable infoWindow's auto panning by setting disableAutoPan to true, this bug doesn't happen, so I think the problem happens because a click on cluster pushes the visible infoWindow out of map's visible viewport, so perhaps the bug is not in MarkerClusterer, but in how AutoPan is implemented by Google Maps.
@smohadjer While this bug is active, I was able to create a work around to this by adding a click event listener to the MarkerClusterer and use that event listener to close the active infoWindow
@HarrisonMaindonald I already tried that workaround, but that doesn't fix the problem completely. For example if infowindow is visible for a marker and you zoom out so that marker goes inside a cluster, now the call to close the infowindow won't close it anymore and if you click on a cluster it will still zoom and center the map on wrong marker. To solve the problem I ended up disabling autopan inside cluster's click handler before map.fitBounds() is called and then enabling it after map.fitBounds() call with a delay.
const onClusterClickHandler = (event, cluster, map) => {
// close any open infoWindow so that map doesn't center on wrong marker
infoWindow.close();
// disable AutoPan to avoid bug
infoWindow.setOptions({
disableAutoPan: true
});
map.fitBounds(cluster.bounds);
// enable AutoPan after cluster has finished centering the map
window.setTimeout(() => {
infoWindow.setOptions({
disableAutoPan: false
});
}, 500);
};
When the infoWindow of a marker is visible and we click on a cluster somewhere else on the map, the map zooms and centers on the marker with infoWindow instead of zooming and centering on markers inside the cluster.
The text was updated successfully, but these errors were encountered: