Checks that clickListener isn't already existent before running setWithMap

pull/73/head
jonsowman 2010-06-04 09:38:06 +01:00
rodzic b8dd855c9e
commit 2db39d1c08
1 zmienionych plików z 10 dodań i 4 usunięć

Wyświetl plik

@ -257,13 +257,19 @@ function setFormLatLon(GLatLng) {
function setLatLonByClick(state) { function setLatLonByClick(state) {
if ( state == true ) { if ( state == true ) {
clickListener = google.maps.event.addListener(map, 'click', function(event) { // check this listener doesn't already exist
$("#error_window").fadeOut(); if (!clickListener) {
setFormLatLon(event.latLng); clickListener = google.maps.event.addListener(map,
}); 'click', function(event) {
$("#error_window").fadeOut();
setFormLatLon(event.latLng);
});
}
// tell the user what to do next
throwError("Now click your desired launch location on the map"); throwError("Now click your desired launch location on the map");
} else if ( state == false ) { } else if ( state == false ) {
google.maps.event.removeListener(clickListener); google.maps.event.removeListener(clickListener);
clickListener = null;
} else { } else {
appendDebug("Unrecognised state for setLatLonByClick"); appendDebug("Unrecognised state for setLatLonByClick");
} }