每次单击一个标记时,我都会尝试更改 activeMarker 的值。即使我在我的点击功能中设置了 activeMarker,下次它也是未定义的。
var ib = new InfoBox(getTraceMarkerInfoBoxOptions(content)); // http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/
marker = new google.maps.Marker({
position: new google.maps.LatLng(pos.Y, pos.X),
icon: icon,
visible: true,
title: type,
map: map,
popup: ib
});
var activeMarker;
google.maps.event.addListener(marker, 'click', function () {
if(activeMarker != undefined) {
activeMarker.popup.close(map);
}
activeMarker = marker;
marker.popup.open(map, this);
});
有没有办法做到这一点。关闭这应该是可能的。对吗?