以下代碼存在問題.. Google地圖標記顯示正常,但關聯的信息窗口不會在點擊時顯示。點擊時,不會發生任何操作。有什麼建議麼?謝謝!谷歌API循環信息窗口問題
var length = data[0].length;
var infowindow = [];
var contentString = [];
var marker = [];
for (var i = 0; i < length; i++) {
var x = data[0][i].number;
var pos = new google.maps.LatLng(data[0][i].lat, data[0][i].long);
marker[i] = new google.maps.Marker({
position: pos,
map: map,
icon: 'http://maps.google.com/mapfiles/ms/icons/' + data[0][i].color + '-dot.png',
description: data[0][i].providerfirst,
id: i
});
//document.write(marker[i].icon);
contentString[i] = '<div id="content" class="infowindow">' +
'<div id="siteNotice">' +
'</div>' +
'<h1 id="firstHeading" class="firstHeading"> ' + data[0][i].providerfirst + ' ' +
data[0][i].providerlast + ', ' + data[0][i].credentials + '</h1>' +
'<p>' +
data[0][i].address + '<br>' +
data[0][i].city + ', ' + data[0][i].state + ', ' + data[0][i].zip + '<br>' +
'</p>' +
'<p>NPI: ' + data[0][i].npi + '</p>' +
'<p>Network: ' + data[0][i].type + '</p>' +
'<div id="bodyContent">' +
'</div>' +
'</div>';
//document.write(contentString[i]);
//document.write(infowindow[i].content);
infowindow[i] = new google.maps.InfoWindow({
content: contentString[i]
})
}
您沒有任何事件監聽器來點擊標記。 – duncan