From 26eac396c0dab6a8ca06563a24fdfacb5851ba3d Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Sun, 3 Apr 2011 22:04:25 -0700 Subject: [PATCH] Prevent new hydrant markers from dropping in while an info window is open --- public/javascripts/application.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 932d82f..ab9e641 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -12,6 +12,7 @@ $(function() { var activeHydrantId; var activeMarker; var activeInfoWindow; + var isWindowOpen = false; var hydrantIds = []; function addMarker(hydrantId, point, color) { if($.inArray(hydrantId, hydrantIds) != -1) { @@ -41,6 +42,9 @@ $(function() { var infoWindow = new google.maps.InfoWindow({ maxWidth: 350 }); + google.maps.event.addListener(infoWindow, 'closeclick', function() { + isWindowOpen = false; + }); activeInfoWindow = infoWindow; activeHydrantId = hydrantId; activeMarker = marker; @@ -55,6 +59,7 @@ $(function() { if(infoWindow == activeInfoWindow) { infoWindow.setContent(data); infoWindow.open(map, marker); + isWindowOpen = true; } } }); @@ -117,6 +122,9 @@ $(function() { }); } google.maps.event.addListener(map, 'dragend', function() { + if(isWindowOpen == true) { + return; + } center = map.getCenter(); addMarkersAround(center.lat(), center.lng()); });