How to enable dynamic links to open thickbox in Google Map balloon?

309 Views Asked by At

I'm using following code to open thickbox for dynamically generated anchor tags, but it doesn't work for the first time, but second time it works.

function createMarker(point, InnerAddress) {
 //Other Code
var strFBUserID = new GMarker(point, markerOptions);

GEvent.addListener(strFBUserID, "click", function() {
    strFBUserID.openInfoWindowHtml(InnerAddress.split('$$')[0]);
    tb_init('a.gmapthickbox');//works second time
});

allmarkers.push(strFBUserID);
return strFBUserID;
}

It seems tb_init fires before, openInfoWindowHtml, any way to solve this issue? I tried setTimeOut but no success. Any help will be greatly appreciated.

1

There are 1 best solutions below

2
On BEST ANSWER

Try listening to the infowindowopen event on your map instance before calling tb_init. It should be fired once the content is ready in the DOM. http://code.google.com/apis/maps/documentation/javascript/v2/reference.html#GMap2.infowindowopen