我在google maps api(v3)和InfoWindows上遇到了一些问题,因为它们附加到标记的点击事件上没有打开.当我调试javascript时,Markers和InfoWindows看起来已经正确创建,所以我假设我在添加click事件监听器时做错了.
下面是添加标记等的地方.任何人都可以看到问题可能是什么?
$.post("/Club/SearchClubsByLocation", { latitude: searchLat, longitude: searchLng },
function (clubs) {
$.each(clubs, function (i, club) {
var LL = new google.maps.LatLng(club.Latitude, club.Longitude);
pointArray.push(LL);
var infoWindow = new google.maps.InfoWindow({
content: club.ClubName + " HELLO!!!"
});
var marker = new google.maps.Marker({
map: map,
position: LL
});
google.maps.event.addListener(marker, 'click', function () {
infowindow.open(map, marker);
});
markerArray.push(marker);
});
for (i in pointArray) {
bounds.extend(pointArray[i]);
}
map.fitBounds(bounds);
pointArray = [];
},
"json"
);
Run Code Online (Sandbox Code Playgroud)
谢谢你的任何建议,
丰富