0

Have a huge problem, searching for weeks now. I have many markers and big InfoWindows per marker that most of time don't show up completely in my map-bounds. How to move the map automaticly and show these big InfoWindow exactly in the center? Further I think of showing it not only in the center (because the InfoWindows are more long than broad) but, say, in a lower position of center (centered, but near to bottom on the map-bounds). I hope you understand, what I mean.

Further, my InfowWindow even changed in size after I click on a link in it and get even bigger (o my god ;-), so I also have to handle this also.

  • possible duplicate of [Include open infowindows within bounds of map, when using fitbounds](http://stackoverflow.com/questions/21002001/include-open-infowindows-within-bounds-of-map-when-using-fitbounds) – geocodezip Mar 13 '14 at 18:09

1 Answers1

0

You probably know that InfoWindow has an option disableAutoPan, but it's defaulted to false so that you should automatically see it whenever it's opened. If you want it in the center, then your best bet is in the click event before opening the InfoWindow, to center the map on the marker first. The autopan from opening should handle automatically and adjust the viewport to fit the InfoWindow from there as necessary.

//marker and map defined somewhere already  
var iw = new google.maps.InfoWindow();
google.maps.event.addListener(marker, 'click', function(){
    map.setCenter(marker.getPosition());
    iw.setContent('your content');
    iw.open(map,marker);
});
Sunny Patel
  • 7,830
  • 2
  • 31
  • 46