Question

If I click something to add 5 markers to the map that are spread out over, say, 100 miles - the markers are added, and the map zooms out to fit them all.

If I then click something that shows markers that are spread out over, say, 2 miles... the markers disappear properly, but the map is not zooming back in.

I'm using 2.1.1

This is my javascript call:

Gmaps.store.handler.removeMarkers(Gmaps.store.markers);
Gmaps.store.markers = Gmaps.store.handler.addMarkers(<%= raw @hash.to_json %>, {
  draggable: false,
  animation: google.maps.Animation.DROP
});
Gmaps.store.handler.bounds.extendWith(Gmaps.store.markers);
Gmaps.store.handler.fitMapToBounds();

Am I missing a call? I thought removeMarkers cleared the clusterer now?

Was it helpful?

Solution

You must explicitly reset your bounds:

handler.resetBounds();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top