我不确定为什么这不起作用。我没有任何错误,但发生的情况是,无论我点击哪个标记,它总是点击最后一个标记。我不确定为什么,因为the_marker设置方式相同。我该如何修复它?(使用新的jQuery + XML更新)
$(function(){
var latlng = new google.maps.LatLng(45.522015,-122.683811);
var settings = {
zoom: 15,
center: latlng,
disableDefaultUI:true,
mapTypeId: google.maps.MapTypeId.SATELLITE
};
var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
$.get('mapdata.xml',{},function(xml){
$('location',xml).each(function(i){
the_marker = new google.maps.Marker({
title:$(this).find('name').text(),
map:map,
clickable:true,
position:new google.maps.LatLng(
parseFloat($(this).find('lat').text()),
parseFloat($(this).find('lng').text())
)
});
infowindow = new google.maps.InfoWindow({
content: $(this).find('description').text()
});
new google.maps.event.addListener(the_marker, 'click', function() {
infowindow.open(map,the_marker);
});
});
});
});