在Google Maps infowindow中使用jQuery

时间:2011-11-23 23:08:35

标签: jquery infowindow fcbkcomplete

我想使用我在Google地图fcbk_autocomplete中从http://www.emposha.com/javascript/fcbkcomplete.html下载的infowindow功能。

最初我设置了infowindow的内容,如下所示

var friends = document.getElementsByTagName('option'), 
    res = '';

for (var i = 0; i < friends.length; i++) {
    res = res + '<option value="'+friends[i].id+'">' + friends[i].value + '</option>';
}

var contentString = '<form method="post" action="mapit.do">' 
    + '<textarea name="comment" cols="40" rows="5">Enter your gossips here...</textarea><br>'
    + 'image url: <input type="text" cols="40" name="url"></input><br>'
    + '<input type="hidden" name="position" value="' + event.latLng.toUrlValue() + '"/>'
    + '<select id="select3" name="about">' + res + '</select>'
    + '<input type="submit" value="Submit" />'
    + '</form>';

options是我想要选择的数据列表,它们存储在一个不可见的部门中。

打开infowindow之后,我尝试通过以下方式调用fcbkcomplete函数:

$("#select3").fcbkcomplete({
    addontab: true,                   
    maxitems: 10,
    input_min_size: 0,
    height: 10,
    cache: true,
    newel: true,
});

但它对select3部分没有影响。我试着打电话给document.getElementById("select3"),它给了我null。我的问题是我在哪里可以调用此函数以确保它看到id为select3的元素?

1 个答案:

答案 0 :(得分:0)

如果没有谷歌地图加载和一切,很难模仿,但我开始jsFiddle for you here

您尝试使用的插件似乎在我的上下文中工作;但是,这可能无法解释您在gmap info window内尝试使用它时所看到的行为。不过,如果您愿意,可以将gmap内容添加到javascript源代码中,我可以帮助您从那里进行调试。