Hi,
In the example given below, I am trying to add an 'closeclick' event
listener to my infowindow. But the result is as follows,
- the closeclickListener() is getting invoked at the point of adding
listener to infowindow (ie from the line,
google.maps.event.addListener(infowindow, 'closeclick',
closeclickListener());)
- but closeclickListener() is not getting invoked when I am click on
the close button, instead giving the following javascript error,
Error: f.e is undefined
Source File:
http://maps.gstatic.com/intl/en_ALL/mapfiles/api-3/3/11/main.js
Line: 17
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script type="text/javascript" src="
http://maps.google.com/maps/
api/js?v=3.3&sensor=false"></script>
<script type="text/javascript">
var map;
var infowindow;
function initMap() {
var latlng = new google.maps.LatLng(25.296854389343867,
51.48811340332031);
var mapOptions = {
zoom : 12,
center : latlng,
mapTypeId : google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
infowindow = new google.maps.InfoWindow({maxWidth: 900});
createMarker(latlng, 'Marker 1');
google.maps.event.addListener(infowindow, 'closeclick',
closeclickListener());
}
function createMarker(position, description) {
var marker = new google.maps.Marker({ position : position, map :
map });
google.maps.event.addListener(marker, 'click', function()
{
infowindow.close();
infowindow.setContent(description);
infowindow.open(map, marker);
});
return marker;
}
function closeclickListener(){
alert('close clicked');
}
</script>
</head>
<body onLoad="initMap();">
<div id="map_canvas" style="width: 100%; height: 100%;"></div>
</body>
</html>