我在我的網站上使用Google地圖。將HTML追加到最初未加載的元素
現在,當在網站上顯示地圖時,可以點擊不同的引腳(位置)。
一旦你點擊一個位置,它會顯示一個彈出框(谷歌地圖氣泡)。現在我想要在地址字段旁邊添加其他內容,並且唯一的方法是使用jQuery。
這裏是彈出泡的HTML:
<div class="google-map-placeholder">
<div class="bubble-content">
<h4>Address: </h4>
<p class="custom-bubble-text">Lat and long...</p>
<p class="custom-bubble-text">PE Offices</p>
</div>
</div>
我想怎麼加我的自定義文本的自定義的地址:元素
的jQuery:
var x = $('div.google-map-placeholder').find('div.bubble-content p.custom-bubble-text').html();
if(x == 'NY Offices'){
$('div.google-map-placeholder').find('div.bubble-content h4').html('Address: My custom address');
}
,但它確實不工作(不追加我的HTML)...
我想我需要添加一個事件偵聽器時點擊地圖標記圖標,但我該怎麼做?
你應該添加一個谷歌地圖事件監聽器:https://developers.google.com/maps/documentation/javascript/events?hl=fr – 2013-04-08 12:11:28