2009-04-19 80 views
0

您好,我正在尝试在Google地图中添加厚框。在我的JQuery onload函数上,我调用以下函数。地图工作正常。但是,当厚厚的盒子似乎没有被调用。这是确实工作从js文件调用thickbox

<a href="test.html?keepThis=true&TB_iframe=true&height=250&width=400" title="add a caption to title attribute/or leave blank" class="thickbox">Example 1</a> 

全功能

function load(lat, lng, zlevel, userKey, state) { 

     map = new GMap2(document.getElementById("map")); 
     map.disableDoubleClickZoom(); 
     map.setCenter(new GLatLng(lat, lng), zlevel); 

     if (state) { 

      dsp = true; 

      map.addControl(new GLargeMapControl()); 
      GEvent.addListener(map, "click", function(overlay, latlng) { 

       var zoom = map.getZoom(); 
       var display = '<h5 class="header-flag">Flag</h5><p class="maptext"><a href="#" onclick="javascript:openOverlay(' + latlng.lat() + ',' + latlng.lng() + ',' + zoom + ');">Click here</a> to enter your comment - 
<a href="test.html?keepThis=true&TB_iframe=true&height=250&width=400" title="add a caption to title attribute/or leave blank" class="thickbox">Example 1</a></p>'; 

       setTimeout(function() { map.openInfoWindowHtml(latlng, display, { maxWidth: 200 }); }, 0); 
      }); 
     } else { 


     } 

     mgr = new MarkerManager(map); 
     loadMarkers(userKey); 
     mgr.refresh(); 
    } 
+0

请澄清您的示例源代码 – pocheptsov 2009-04-19 11:52:31

+0

所以,使我的帖子有点混乱。我已经更新了:) – frosty 2009-04-19 12:31:32

回答

2

你还说你要激活的ThickBox到DOM的ThickBox的功能已经被称为后链接线。这是因为您正在map.openInfoWindowHtml函数内动态创建链接。执行此功能后,您需要调用thickbox函数。

问题是我刚看了一下thickbox docs,thickbox.js文件在thickbox.js文件中设置好了,一旦DOM加载,对您来说太快了。你可以尝试改变setTimeout函数:

我不能100%肯定这会工作,但这是问题的关键。