tags:

views:

3290

answers:

2

i have the following code:

   var point0 = new GLatLng(40.786729,-73.972766);
   var marker0 = new GMarker(point0);
   marker0.value = 0;
   GEvent.addListener(marker0, "click", function() {
   var myHtml = "<b><a href='http://Photos.Net'&gt;&lt;br />01-0001</a></b><br /><br /><img src=http://adam.kantro.net/pics/Apartment/Thumbnails/Apartment-pic001.jpg&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;";
   map.openInfoWindowHtml(point0, myHtml);
   });

the issue is that the image shows up outside the bounds of the popup window. Is there anyway to force the popup window to expand to fit this picture and the full html.

+1  A: 

Have you tried something like

map.openInfoWindowHtml('<div style="width: 20em">...</div>');

I don't believe it can auto size so you have to be cute and specify the width beforehand

also see here

Rippo
the issue is height
ooo
Well set the height as well! The info window still will not resize itself automatically so you will have to set it explicitly...I would probably use a css class e.g..infowindow { width:250px; height:150px; overflow:auto;}and in the mapmap.openInfoWindowHtml('<div class="infowindow" ......
Rippo
This isn't the problem - the problem is that the info window is created and sized before the picture downloads. When it finishes downloading, the size of the info window has already been set, and it overflows. You need to set a height on the image so the info window is created correctly, as Cannonade pointed out.
Chris B
Surely setting the height of the DIV will also solve the same problem?
Rippo
+3  A: 

This is a pretty common problem with Google maps info windows.

  • Set the height explicitly on the image tag:
<img height="112" src=http://.../Apartment-pic001.jpg&gt;
  • Check inherited styles being applied to the info window contents after it has been attached to the map.

Check out the following question:

http://stackoverflow.com/questions/919659/how-to-set-google-maps-markers-infowindow-max-height

Cannonade