簡體   English   中英

在Google Maps Infowindow中使用jQuery

[英]Using jQuery in Google Maps infowindow

我想用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是我要從中選擇的數據列表,它們存儲在不可見的分區中。

打開信息窗口后,我嘗試通過以下方式調用fcbkcomplete函數:

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

但這對select3部分沒有影響。 我試圖調用document.getElementById("select3") ,它給了我null。 我的問題是,在哪里可以調用此函數以確保它看到ID為select3的元素?

沒有加載Google地圖和所有內容,很難模擬,但是我在這里為您啟動了jsFiddle

您嘗試使用的插件似乎在我的上下文中有效; 但是,這可能無法解釋您在gmap info window嘗試使用它所看到的行為。 不過,如果您願意,可以將gmap內容添加到javascript源中,我可以幫助您從那里進行調試。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM