I notice that the closeeclick event in InfoWindow is fired before InfoWindow is displayed in Google Maps V3. Has anyone else seen this? Error? My misunderstanding of the design?
Consider a simple example:
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#map_canvas {
}
</style>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false"
>
</script>
<script type="text/javascript">
function initialize()
{
var newLatLng = new google.maps.LatLng(47.620513,-122.33963);
var myOptions = { zoom: 12,
center: newLatLng,
draggingCursor: 'pointer',
draggableCursor: 'default',
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map( document.getElementById("map_canvas"),
myOptions);
google.maps.event.addListener(map, 'click', function(event) {
placeMarker(event.latLng);
});
}
function placeMarker(location)
{
var marker = new google.maps.Marker({
position: location,
map: map
});
map.panTo(location);
markerWindow(marker);
}
function markerWindow(marker)
{
var infoHtml = "testing";
var infoW = new google.maps.InfoWindow({});
infoW.setContent(infoHtml);
google.maps.event.addListener(infoW, 'closeclick', closeMarker());
infoW.open(map, marker);
}
function closeMarker()
{
window.alert("closeclick fired");
}
</script>
</head>
<body onload='initialize()'>
<div id="map_canvas" style=" position:absolute;
width:400px;
height:400px;"
>
</div>
</body>
</html>
If you run this example, closeclick will be called before InfoWindow is displayed, and not after it is created and after clicking the "x" button in the upper right corner of the InfoWindow bubble. Is this a mistake (theirs or mine), or am I misunderstanding the design / use?
Environment: Windows Vista (32-bit), Firefox 3.6.10
source
share