每次点击一个标记时,我都会尝试更改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);
});
有没有办法实现这一目标。关闭这应该是可能的。直接?