【发布时间】:2013-04-04 06:26:07
【问题描述】:
我正在尝试创建一组带有信息框的标记。但是,无论我单击哪个标记,它总是会打开最后一个详细标记的信息框。有谁知道为什么?请帮忙。
var stepDisplay = new google.maps.InfoWindow();
function AddDetailMarker(map, itinerary) {
var markers = [];
for (var i = 1; i < itinerary.Legs.length; i++) {
var position = new google.maps.LatLng(itinerary.Legs[i].BusStop.Latitude, itinerary.Legs[i].BusStop.Longitude);
var title = itinerary.Legs[i].BusStop.Code + ": " + itinerary.Legs[i].BusStop.Location + " " + itinerary.Legs[i].BusStop.Street + ", Quận " + itinerary.Legs[i].BusStop.Ward;
var detailmarker = new google.maps.Marker({
position: position,
map: map,
title: title,
icon: "/Content/img/customized_marker/" + "blue" + "/" + "bus-stop2" + ".png"
});
google.maps.event.addListener(detailmarker, 'click', function () {
stepDisplay.setContent(title);
stepDisplay.open(map, detailmarker);
});
markers[i-1] = detailmarker;
}
}
编辑:Google maps infowindow showing on wrong marker 可能重复。我已经尝试了在这里找到的所有解决方案,但没有一个有效。
【问题讨论】:
标签: javascript google-maps google-maps-markers