The specific use case I have is that an image is being dynamically
loaded into an InfoWindow. I do not know the specific image dimensions
until after the image has loaded into the browser. If a user opens the
InfoWindow before the image has been appended to it, it will calculate
it's size without the image, and does not appear to recalculate it's
size after that point, even if it is closed and reopened.
Once you inject content into the infowindow with this method it re-
calculates it's own height.
If you want me to get more specific, post a link
var info_window = new google.maps.InfoWindow({
content:'<div class="parent"><div class="image"/></div>'
});
$('<img src="' + image_src + '" />')
.bind('load', function () {
var content = info_window.getContent();
$(this).appendTo($(content).find('.image'));
info_window.setContent(content);
});
I've also tried to empty the InfoWindow object before appending new
content, but this doesn't alter the height. Experimentally the height
of 'div.parent' above is set when the InfoWindow is first opened, and
seemingly not again after that point.
I also load some dynamic content into an InfoWindow which nearly
always requires a resize. I call setContent() with a loading
indicator for the original IW, start the data load, then call
setContent() again when I have the data. I find that sometimes the IW
resizes and sometimes it doesn't. It's quite erratic and I can't
figure out why.
An additional complication is that I am doing this work with GWT, but
it's not fundamentally any different - my code just calls
setContent(Element) with the dom element from my widget.
Thanks,
Jeff
The part of my widget that changes size is nested inside another
widget, so when I call setContent() I'm actually calling it with the
same Element that setContent() was originally called with.
Is it possible that setContent() is checking that the new Element is
the same as the old and erroneously not checking the size? I don't
actually have much idea what's going on inside that method.
Another thought... the difference between the size of the old widget
and the size of the updated widget is a body of text. Is it possible
there's some sort of byzantine browser behavior involved here,
something about text not expanding the size of the container widget?
I'm grasping.
Thanks,
Jeff
Something along these lines seems to be consistent with observed
behavior:
* Setting a fresh Element causes a proper resize of the InfoWindow
bubble
* Setting the same Element (but with different content) produces
erratic behavior
Jeff