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) {
if ( state == true ) {
clickListener = google.maps.event.addListener(map, 'click', function(event) {
$("#error_window").fadeOut();
setFormLatLon(event.latLng);
});
// check this listener doesn't already exist
if (!clickListener) {
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");
} else if ( state == false ) {
google.maps.event.removeListener(clickListener);
clickListener = null;
} else {
appendDebug("Unrecognised state for setLatLonByClick");
}