Possible Duplicate:
Remove marker in Google Maps Api v3
I’m trying to give users access to close the infowindow by hitting the “X”, which in turn lets them get rid of the marker as well. I thought the code below would work but it doesn’t. Does anyone have any suggestions.
function addLaunch() {
google.maps.event.addListener(map, "click", function(event) {
marker2 = new google.maps.Marker({
position: event.latLng,
map: map
});
infowindow.open(map, marker);
google.maps.event.addListener(infowindow, "closeclick", function() {
map.removeOverlay(marker2);
});
});
};
the
removeOverlay()method is from the API V2. in V3 you’d use: