【问题标题】:How to enable dynamic links to open thickbox in Google Map balloon?如何启用动态链接以在谷歌地图气球中打开厚框?
【发布时间】:2012-01-31 06:24:11
【问题描述】:

我正在使用以下代码为动态生成的锚标签打开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;
}

似乎 tb_init 之前触发过,openInfoWindowHtml,有什么办法可以解决这个问题?我试过 setTimeOut 但没有成功。任何帮助将不胜感激。

【问题讨论】:

    标签: asp.net google-maps jquery thickbox


    【解决方案1】:

    在调用tb_init 之前,尝试在您的地图实例上监听infowindowopen 事件。一旦内容在 DOM 中准备就绪,就应该触发它。 http://code.google.com/apis/maps/documentation/javascript/v2/reference.html#GMap2.infowindowopen

    【讨论】:

    • 感谢@Dave 回复。我确实检查了 infowindowopen 事件,但我使用以下代码解决了我的问题: var strFBUserID = new GMarker(point, markerOptions); var openFnCallback = function() { tb_init('a.thickbox'); }; GEvent.addListener(strFBUserID, "click", function() { strFBUserID.openInfoWindowHtml(InnerAddress.split('$$')[0], { onOpenFn: openFnCallback }); });再次感谢。 :)
    • 哦,好主意,我忘了onOpenFn - 这是对您现有代码的一个小得多的更改。
    猜你喜欢
    • 2010-11-21
    • 2015-04-23
    • 1970-01-01
    • 2012-11-04
    • 1970-01-01
    • 1970-01-01
    • 2013-11-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多