Google maps infowindow events on open
Asked Answered
M

1

17

Hi I am using google fusion tables and google maps, the thing is that my markers show up correctly, but I want to insert some images into the inforwindow. So the thing is that I do queries to find the location of those markers, and those markers can have many categories (that is why i couldnt use a merged table). And when the user clicks on the marker, the infowindow displays and shows the info on the marker. It used to include just a text of the categories, but I want to retrieve the icon from each category to display that on the infowindow. The thing is that the second query takes longer than the time it takes to display the info window. So i did a lame fix, I added

$('#infoWindowsCatDer').append(info);

at the end of the second query, so I guess you can see the problem, what happens if the windows takes a little bit longer to display than the query. This is something that should be handled by events right?

Is there an event for

lastWindow.open(map);

So when the infowindow is completly open it can append the images?

Monahon answered 5/7, 2012 at 18:21 Comment(1)
You haven't provider enough technical details about what you are attempting. In particular how are you executing your second query? Are you using the Fusion Table JSON API?Stratocumulus
C
39

The InfoWindow object fires the event domready event when it is attached (fully loaded) to the DOM. You can see this in the API docs: https://developers.google.com/maps/documentation/javascript/reference#InfoWindow

You could then have a listener like the one below to load content into the infoWindow after it has loaded itself:

var referenceToInfoWindow = new google.maps.InfoWindow({content: 'My info' });

google.maps.event.addListener(referenceToInfoWindow, 'domready', function(){
    //code to dynamically load new content to infowindow
    //for example:
    //    var existing_content = referenceToInfoWindow.getContent();
    //    var new_content = "...";
    //    referenceToInfoWindow.setContent(existing_content + new_content);
}); 
Caffeine answered 22/8, 2012 at 1:32 Comment(3)
Did I answer your question? Or is there something still missing?Caffeine
@JonathanWilson - I know this is a super old question, but what would you put as the "referenceToInfoWindow"? There is no class on that element.Judoka
@Judoka You should simply pass a variable which stores your InfoWindow.Hakon

© 2022 - 2024 — McMap. All rights reserved.