fix google map shift problem, using _.defer

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

Branch: refs/heads/0.5.0
Commit: badb594bd5a67167d4eedadbcfd51d8b2f330c68
Parents: 7405405
Author: Alex Heneveld <[email protected]>
Authored: Wed Mar 13 23:30:30 2013 +0000
Committer: Alex Heneveld <[email protected]>
Committed: Wed Mar 13 23:30:30 2013 +0000

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


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/badb594b/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 3b43ec8..5f94678 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/googlemaps.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/googlemaps.js
@@ -13,8 +13,7 @@ define(
                             mapTypeId: google.maps.MapTypeId.SATELLITE
                     };
 
-                    var map = new google.maps.Map( mapCanvas, myOptions );
-                    return map;
+                    return new google.maps.Map(mapCanvas, myOptions);
                 },
 
                 // TODO info window; massive code tidy

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/badb594b/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 8ba2664..9c4314a 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/home.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/home.js
@@ -39,11 +39,14 @@ define([
                id.find("#circles-map-message").html("(map off in offline 
mode)");
             } else {
                requirejs(["googlemaps"], function (GoogleMaps) {
+                   _.defer( function() {
+                       log("loading google maps")
                                var map = GoogleMaps.addMapToCanvas(id[0],
                                        // brooklyn bridge
 //                                     40.7063, -73.9971, 14
                                        // edinburgh + atlantic
 //                                     55.6, -2.5, 2
+                                       // center
                                        0, 0, 1
                                        )
                                var locatedLocations = new 
Location.UsageLocated()
@@ -51,7 +54,8 @@ define([
                                that.callPeriodically("circles", function() {
                                    that.updateCircles(that, locatedLocations, 
GoogleMaps, map)
                                }, 10000)
-                       }, function (error) {
+                   })
+               }, function (error) {
                                id.find("#circles-map-message").html("(map not 
available)"); 
                });
             }

Reply via email to