googlearchive/js-marker-clusterer

Info Window not opening in correct location

Opened this issue ยท 5 comments

When marker clusterer is enabled and an info window is dynamically populated using setContent(), the info window opens up in the upper left hand corner instead of being positioned near the marker:

$gmap.map = new google.maps.Map(document.getElementById('map'), {...});
$gmap.infoWindow = new google.maps.InfoWindow();
/* Push some markers to $gmap.markers */
$gmap.clusterer = new MarkerClusterer($gmap.map, $gmap.markers);
...
marker = $gmap.markers[0];
$gmap.infoWindow.setContent('Test');
$gmap.infoWindow.open($gmap.map, marker);

The interesting thing is, if I comment out setContent() then the info window shows up next to the marker. If I comment out new MarkerClusterer(), then the info window shows up correctly regardless.

For now here is my workaround:

...
marker = $gmap.markers[0];
$gmap.info.setPosition(marker.getPosition());
$gmap.info.open($gmap.map);

Great, thanks for sharing the solution .. it worked for me ๐Ÿ‘

@thdoan great, thx for sharing. helped me also out at the moment :) ๐Ÿ‘Œ๐Ÿฟ

I found that it was because the 'map' attribute of clusterer's markers[0] is null that when i open infowindow with markers[0]'s position it showed in the wrong position.so i rewrite this line 'this.markers_[i].setMap(null);' to 'this.markers_[i].setVisible(false);',then the infowindow shows in correct position

@QueridaChin Can you please write us in which file we should make the code update you advice us?
and write us the file path?

Thanks,
Daniel