InfoBubble打开特定选项卡

时间:2012-06-04 21:01:33

标签: javascript google-maps-api-3 infobubble

在JavaScript中,我发现了谷歌地图API v3的这个简洁的小插件,名为InfoBubble。它使得高度自定义的Info Windows变得非常容易。我似乎无法在那里找到的是如何通过函数调用打开特定选项卡而不是单击选项卡按钮。我尝试了setTabActive(index),这是插件的功能之一,但它似乎不起作用。我错过了一些明显的东西,还是只是在js文件中挖掘正确的功能?

供参考,这是我的代码:

var center = new google.maps.LatLng(//...getting some lat/lng coords...
var bubble = new InfoBubble(
{
    map: motherMap,
    position: center,
    minHeight: 250,
    maxHeight: 250,
    minWidth: 250,
    maxWidth: 250,
    tabClassName: "contentTab",
    padding: 3
});

//...creating tabs, getting which tab should be opened, setting the value of tabToShow and so on...

//at this point I've checked with console.out() and tabToShow is a number 0-2
bubble.setTabActive(tabToShow);

即使使用该代码,每次都会打开第一个选项卡。任何想法都将不胜感激。

编辑:我实际上是在发布此处后自行解决了问题...在仔细查看代码后,我注意到作者无论出于何种原因,使用的编号从1开始而不是0。一个不错的插件,但肯定需要一些文档...

1 个答案:

答案 0 :(得分:0)

确保选项卡已打开(您可以使用isOpen()方法进行检查。)

如果需要,可以修改InfoBubble.prototype.open以打开特定选项卡:

  window.setTimeout(function() {
         that.open_(opt_map, opt_anchor);
         that.setTabActive(_defaultTab);        
  }, 0);
相关问题