aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage-google
diff options
context:
space:
mode:
authorAnanya Sen2012-06-07 11:59:32 -0700
committerAnanya Sen2012-06-07 11:59:32 -0700
commit7378b6846f140106490f10c02cd7cec6a19023aa (patch)
tree90b60c007696b4a73c29abbae82562f69f15c11a /node_modules/montage-google
parentaea0e6879abfef02a827ed239ef091c3b96d6eb2 (diff)
parentb75fe9369f7caec0351d298f7106c8d59572b440 (diff)
downloadninja-7378b6846f140106490f10c02cd7cec6a19023aa.tar.gz
Merge branch 'refs/heads/ninja-internal-master' into cut-copy-paste
Diffstat (limited to 'node_modules/montage-google')
-rw-r--r--node_modules/montage-google/feed-reader/feed-entry.reel/feed-entry.html3
-rw-r--r--node_modules/montage-google/feed-reader/feed-reader.reel/feed-reader.js8
-rw-r--r--node_modules/montage-google/map.reel/map.js96
3 files changed, 66 insertions, 41 deletions
diff --git a/node_modules/montage-google/feed-reader/feed-entry.reel/feed-entry.html b/node_modules/montage-google/feed-reader/feed-entry.reel/feed-entry.html
index 8e9b3371..b8b9f39a 100644
--- a/node_modules/montage-google/feed-reader/feed-entry.reel/feed-entry.html
+++ b/node_modules/montage-google/feed-reader/feed-entry.reel/feed-entry.html
@@ -76,8 +76,7 @@
76</head> 76</head>
77<body> 77<body>
78 <div class="feed-entry" data-montage-id="feed-entry"> 78 <div class="feed-entry" data-montage-id="feed-entry">
79 79 <a target="_blank" data-montage-id="entry-url" class="entry-url"><h2 data-montage-id="entry-title" class="entry-title"></h2></a>
80 <a target="_blank" id="entry-url" class="entry-url"><h2 data-montage-id="entry-title" class="entry-title"></h2></a>
81 <p data-montage-id="entry-description" class="entry-description"></p> 80 <p data-montage-id="entry-description" class="entry-description"></p>
82 </div> 81 </div>
83 82
diff --git a/node_modules/montage-google/feed-reader/feed-reader.reel/feed-reader.js b/node_modules/montage-google/feed-reader/feed-reader.reel/feed-reader.js
index c066220e..34533d6d 100644
--- a/node_modules/montage-google/feed-reader/feed-reader.reel/feed-reader.js
+++ b/node_modules/montage-google/feed-reader/feed-reader.reel/feed-reader.js
@@ -184,6 +184,14 @@ exports.FeedReader = Montage.create(Component, {
184 value: function() { 184 value: function() {
185 185
186 } 186 }
187 },
188
189 serializeProperties: {
190 value: function(serializer) {
191 serializer.set("element", this.element);
192 serializer.set("feedURL", this.feedURL);
193 serializer.set("feedDisplayMode", this.feedDisplayMode);
194 }
187 } 195 }
188 196
189}); 197});
diff --git a/node_modules/montage-google/map.reel/map.js b/node_modules/montage-google/map.reel/map.js
index fc104df5..4e3a6d70 100644
--- a/node_modules/montage-google/map.reel/map.js
+++ b/node_modules/montage-google/map.reel/map.js
@@ -20,10 +20,11 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/
20 didCreate: { 20 didCreate: {
21 value: function() { 21 value: function() {
22 var self = this; 22 var self = this;
23
23 window.initialize = function initialize() { 24 window.initialize = function initialize() {
24 console.log('google maps api loaded');
25 self._mapLoaded = true; 25 self._mapLoaded = true;
26 self._geoCoder = new google.maps.Geocoder(); 26 self._geoCoder = new google.maps.Geocoder();
27 self.center = self._center;
27 self.needsDraw = true; 28 self.needsDraw = true;
28 }; 29 };
29 } 30 }
@@ -32,7 +33,10 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/
32 _geoCoder: {value: null}, 33 _geoCoder: {value: null},
33 34
34 // HTMLElement to load the Map into 35 // HTMLElement to load the Map into
35 mapEl: {value: null}, 36 mapEl: {
37 serializable: true,
38 value: null
39 },
36 40
37 _mapLoaded: { 41 _mapLoaded: {
38 enumerable: false, 42 enumerable: false,
@@ -49,9 +53,9 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/
49 }, 53 },
50 54
51 _latLng: { 55 _latLng: {
52 value: this.defaultLatLng, 56 value: null
53 distinct: true
54 }, 57 },
58
55 latLng: { 59 latLng: {
56 get: function() { 60 get: function() {
57 return this._latLng; 61 return this._latLng;
@@ -67,6 +71,7 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/
67 71
68 // {lat, lon} Or a String representing the location (eg: Paris, France) 72 // {lat, lon} Or a String representing the location (eg: Paris, France)
69 center: { 73 center: {
74 serializable: true,
70 get: function() { 75 get: function() {
71 return this._center; 76 return this._center;
72 }, 77 },
@@ -78,10 +83,12 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/
78 83
79 if(String.isString(value)) { 84 if(String.isString(value)) {
80 // geocode 85 // geocode
86 self.LatLng = null;
81 geocoder.geocode( { 'address': value}, function(results, status) { 87 geocoder.geocode( { 'address': value}, function(results, status) {
82 if (status == google.maps.GeocoderStatus.OK) { 88 if (status == google.maps.GeocoderStatus.OK) {
83 var loc = results[0].geometry.location; 89 var loc = results[0].geometry.location;
84 self.latLng = {lat: loc.lat(), lng: loc.lng()}; 90 self.latLng = {lat: loc.lat(), lng: loc.lng()};
91 self.category = self._category;
85 } else { 92 } else {
86 console.log('Geocode was not successful : ' + status); 93 console.log('Geocode was not successful : ' + status);
87 } 94 }
@@ -101,15 +108,17 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/
101 }, 108 },
102 109
103 category: { 110 category: {
111 serializable: true,
104 get: function() { 112 get: function() {
105 return this._category; 113 return this._category;
106 }, 114 },
107 set: function(value) { 115 set: function(value) {
108 console.log('category set: ' + value);
109 if(value) { 116 if(value) {
110 this._category = value; 117 this._category = value;
111 this._getPlaces(this._category); 118 if (this._map && this.latLng) {
112 this.needsDraw = true; 119 this._getPlaces(this._category);
120 this.needsDraw = true;
121 }
113 } 122 }
114 } 123 }
115 }, 124 },
@@ -130,7 +139,7 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/
130 139
131 140
132 zoomValue: { 141 zoomValue: {
133 value: 8 142 value: 13
134 }, 143 },
135 144
136 __places: {value: null}, 145 __places: {value: null},
@@ -159,12 +168,12 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/
159 } 168 }
160 var service = new google.maps.places.PlacesService(this._map); 169 var service = new google.maps.places.PlacesService(this._map);
161 service.search(request, function(results, status) { 170 service.search(request, function(results, status) {
162 console.log('got places for ', self.category, status, results);
163 if (status == google.maps.places.PlacesServiceStatus.OK) { 171 if (status == google.maps.places.PlacesServiceStatus.OK) {
164 self._places = results; 172 self._places = results;
165 } else { 173 } else {
166 self._places = []; 174 self._places = [];
167 } 175 }
176 self.needsDraw = true;
168 }); 177 });
169 } 178 }
170 }, 179 },
@@ -240,9 +249,17 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/
240 draw: { 249 draw: {
241 enumerable: false, 250 enumerable: false,
242 value: function () { 251 value: function () {
243
244 if(this._mapLoaded) { 252 if(this._mapLoaded) {
245 var latLng = this.latLng || this.defaultLatLng; 253 var latLng = this.latLng;
254
255 if (!latLng) {
256 if (this._center) {
257 return;
258 } else {
259 latLng = this.defaultLatLng;
260 }
261 }
262
246 if(!this._map) { 263 if(!this._map) {
247 var map; 264 var map;
248 var myOptions = { 265 var myOptions = {
@@ -252,35 +269,36 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/
252 }; 269 };
253 270
254 this._map = new window.google.maps.Map(this.mapEl, myOptions); 271 this._map = new window.google.maps.Map(this.mapEl, myOptions);
255 } else { 272 this.center = this._center;
256 var map = this._map; 273 this.category = this._category;
257 map.setZoom(10);
258 var latLng = new window.google.maps.LatLng(latLng.lat, latLng.lng);
259 map.setCenter(latLng);
260 var marker = new google.maps.Marker({
261 map: map,
262 position: latLng
263 });
264
265 var places = this._places;
266 if(places && places.length > 0) {
267 map.setZoom(13);
268 this._removeAllMarkers();
269 for (var i = 0; i < places.length; i++) {
270 this._createMarker(places[i]);
271 }