Получилось сделать так
var markers =[];
google.maps.event.addListener(map, "click", function(e) {
var infoWindow = new google.maps.InfoWindow({
content: 'Latitude: ' + location.lat() + '<br />Longitude: ' + location.lng()
});
var lat =location.lat();
var lng =location.lng();
for (var i = 0; i < markers.length; i++) {
markers[i].setMap(null);
}
marker = new google.maps.Marker({
position: {lat: lat, lng: lng},
map: map
});
markers.push(marker);
});