我使用下面的代码为动态生成的锚点标记打开thickbox,但第一次不起作用,但第二次起作用了。
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;
}openInfoWindowHtml,看起来tb_init以前触发过,有什么办法解决这个问题吗?我尝试了setTimeOut,但没有成功。任何帮助都将不胜感激。
发布于 2012-01-31 14:29:26
在调用tb_init之前,尝试侦听地图实例上的infowindowopen事件。一旦DOM中的内容准备就绪,就应该触发它。http://code.google.com/apis/maps/documentation/javascript/v2/reference.html#GMap2.infowindowopen
https://stackoverflow.com/questions/9075319
复制相似问题