1

I'm trying to add a few tweets to an infowindow in Google Maps. I get the tweets to display in a div that is the content of my infowindow, but it's the wrong size.

I thought by calling 'content_changed' when the marker is clicked, the infowindow would resize - it doesn't.

I'm sure this is pretty straightforward, can someone help me out?

Thanks,

James

var myLatlng = new google.maps.LatLng(51.500261,-0.126793);
var myOptions = {
  zoom: 12,
  center: myLatlng,
  mapTypeId: google.maps.MapTypeId.ROADMAP
};

var map = new google.maps.Map(document.getElementById("map_canvas"),
    myOptions);

var marker = new google.maps.Marker({
  position: myLatlng,
  map: map,
});

var infowindow = new google.maps.InfoWindow();
infowindow.setContent(document.getElementById("station"));

google.maps.event.addListener(marker, 'click', function() {
    google.maps.event.trigger(infowindow, 'content_changed');
    infowindow.open(map,marker);
});

3 Answers 3

1

Try to call infowindow.close(); before open(). I'm pretty sure that it will force it to rerender

0
0

This isn't exactly a supported solution, but after poking around in Firebug, I found an easy way to force a resize on the window:

infoWindow.b.contentSize = new google.maps.Size(w, h);
google.maps.event.trigger(infoWindow.b, 'contentsize_changed');

As far as what the real W/H should be set to on the first line, that's a matter of looking at infoWindow.b.contentNode and getting a real width/height either through the standard properties or jQuery's methods.

I'm not sure exactly what infoWindow.b is, but it seems like it's some sort of "content" object. I wish they would expose this and document it.

0

I ended up with:

infoWindowLinea.setContent(infoWindowLinea.getContent());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.