我有InfoWindow的问题。我有一个通过JSON检索数据的ajax函数,但当打开另一个时,我无法自动关闭InfoWindow。 我的代码是这样的:关闭InfoWindow之前打开另一个
var mapOptions = {
center: new google.maps.LatLng(44.49423583832911, 11.346244544982937),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("mappa_locali"),mapOptions);
$.ajax({
type:'GET',
url:"locali_json.php"+urlz,
success:function(data){
var json = JSON.parse(data);
for (var i=0; i<json.length; i++) {
point = new google.maps.LatLng(json[i].latitudine,json[i].longitudine);
var infowindow = new google.maps.InfoWindow;
infowindow.setContent('<a href="./dettaglioLocale.php?id_loc='+json[i].id_locale+'">'+json[i].nome_locale+'</a><br>'+json[i].address);
addMarkerz(point,infowindow);
}
}
})
}
function addMarkerz(point,infowindow) {
position: point,
map: map
});
google.maps.event.addListener(marker,'mouseover',infoCallback(infowindow, marker));
markers.push(marker);
infos.push(infowindow);
}
function infoCallback(infowindow, marker) {
return function() {
infowindow.close();
infowindow.open(map, marker);
};
}
有谁知道哪里错下降?或者你有什么建议吗?
可能重复[更改谷歌地图再使用单一的信息窗口,而不是创建多个](http://stackoverflow.com/questions/11984258/change-google-maps-to-re-use-single -infowindow-rather-creating-multiple) – geocodezip
http://stackoverflow.com/questions/7796318/google-maps-api-opening-a-single-infowindow也可能是http://stackoverflow.com/questions/2223574/google-maps-auto-close-open-infowindows/8126982#8126982 – geocodezip
没有任何建议可以解决我的问题? – Stefania