Fixed issue that was preventing map markers from appearing during tab-to-tab 
navigation


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/f6ae752b
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/f6ae752b
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/f6ae752b

Branch: refs/heads/0.6.0
Commit: f6ae752b9c6e58f0a7bec95d275fd0ce6c15ffac
Parents: 10b952f
Author: Martin Harris <[email protected]>
Authored: Fri Nov 15 11:25:14 2013 +0000
Committer: Martin Harris <[email protected]>
Committed: Fri Nov 15 11:25:14 2013 +0000

----------------------------------------------------------------------
 .../jsgui/src/main/webapp/assets/js/view/googlemaps.js | 13 ++++++++-----
 usage/jsgui/src/main/webapp/assets/js/view/home.js     |  3 +++
 2 files changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/f6ae752b/usage/jsgui/src/main/webapp/assets/js/view/googlemaps.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/googlemaps.js 
b/usage/jsgui/src/main/webapp/assets/js/view/googlemaps.js
index 5f94678..1a8a504 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/googlemaps.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/googlemaps.js
@@ -19,9 +19,9 @@ define(
                 // TODO info window; massive code tidy
                 drawCircles: function(map, data) {
                     var newLocs = {};
-                    var id;
                     var lm;
                     _.each(data, function(it) {
+                        var id = it.id;
                         if (it.latitude == null || it.longitude == null || 
(it.latitude == 0 && it.longitude == 0)) {
                             // Suppress circle if not set or at (0,0); 
slightly clumsy, but workable
                         } else if (lm = locationMarkers[id]) {
@@ -56,10 +56,10 @@ define(
                     })
 
                     // TODO yuck, we assume location markers (static field) 
are tied to map (supplied)
-                    for (id in locationMarkers) {
-                        if (! newLocs[id]) {
+                    for (var marker in locationMarkers) {
+                        if (! newLocs[marker]) {
                             // location has been removed
-                            lm = locationMarkers[id];
+                            lm = locationMarkers[marker];
                             lm.circle.setMap(null);
                             lm.marker.setMap(null);
                             lm.infoWindow.getInfoWindow().setMap(null);
@@ -67,7 +67,10 @@ define(
                     }
                     locationMarkers = newLocs;
                 },
-                
+                resetCircles: function() {
+                    locationMarkers = {};
+                },
+
                 drawCircle: function(map, lat, lng, radius) {
                     var circle_latlong = new google.maps.LatLng(lat, lng);
                     var circle_options = {

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/f6ae752b/usage/jsgui/src/main/webapp/assets/js/view/home.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/home.js 
b/usage/jsgui/src/main/webapp/assets/js/view/home.js
index 4845bd4..fc106fd 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/home.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/home.js
@@ -61,6 +61,9 @@ define([
                                        0, 0, 1
                                        )
                                var locatedLocations = new 
Location.UsageLocated()
+                        // googlemaps.js isn't re-loaded during tab-to-tab 
navigation so we need to reset it each time
+                        // the maps is re-drawn to reset the cached set of 
location markers
+                        GoogleMaps.resetCircles()
                                that.updateCircles(that, locatedLocations, 
GoogleMaps, map)
                                that.callPeriodically("circles", function() {
                                    that.updateCircles(that, locatedLocations, 
GoogleMaps, map)

Reply via email to