diff options
Diffstat (limited to 'node_modules/montage/ui/map.reel/map.js')
-rw-r--r-- | node_modules/montage/ui/map.reel/map.js | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/node_modules/montage/ui/map.reel/map.js b/node_modules/montage/ui/map.reel/map.js index c03d51c5..cba08a42 100644 --- a/node_modules/montage/ui/map.reel/map.js +++ b/node_modules/montage/ui/map.reel/map.js | |||
@@ -42,37 +42,10 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ | |||
42 | enumerable: false, | 42 | enumerable: false, |
43 | value: false | 43 | value: false |
44 | }, | 44 | }, |
45 | _latitude: { | 45 | |
46 | enumerable: false, | 46 | // Sunnyvale, CA |
47 | value: -34.397 | ||
48 | }, | ||
49 | latitude: { | ||
50 | enumerable: false, | ||
51 | set: function(value) { | ||
52 | this._latitude = value; | ||
53 | this.needsDraw = true; | ||
54 | }, | ||
55 | get: function() { | ||
56 | return this._latitude; | ||
57 | } | ||
58 | }, | ||
59 | _longitude: { | ||
60 | enumerable: false, | ||
61 | value: -34.397 | ||
62 | }, | ||
63 | longitude: { | ||
64 | enumerable: false, | ||
65 | set: function(value) { | ||
66 | this._longitude = value; | ||
67 | this.needsDraw = true; | ||
68 | }, | ||
69 | get: function() { | ||
70 | return this._longitude; | ||
71 | } | ||
72 | }, | ||
73 | |||
74 | defaultLatLng: { | 47 | defaultLatLng: { |
75 | value: {lat: -34.397, lng: 150.644} | 48 | value: {lat: 37.37, lng: -122.03} |
76 | }, | 49 | }, |
77 | 50 | ||
78 | _latLng: { | 51 | _latLng: { |
@@ -132,6 +105,7 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ | |||
132 | return this._category; | 105 | return this._category; |
133 | }, | 106 | }, |
134 | set: function(value) { | 107 | set: function(value) { |
108 | console.log('category set: ' + value); | ||
135 | if(value) { | 109 | if(value) { |
136 | this._category = value; | 110 | this._category = value; |
137 | this._getPlaces(this._category); | 111 | this._getPlaces(this._category); |
@@ -140,6 +114,21 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ | |||
140 | } | 114 | } |
141 | }, | 115 | }, |
142 | 116 | ||
117 | trafficLayer: {value: null}, | ||
118 | _traffic: {value: null}, | ||
119 | traffic: { | ||
120 | get: function() { | ||
121 | return this._traffic; | ||
122 | }, | ||
123 | set: function(value) { | ||
124 | if(value !== this._traffic) { | ||
125 | this._traffic = value; | ||
126 | this.needsDraw = true; | ||
127 | } | ||
128 | } | ||
129 | }, | ||
130 | |||
131 | |||
143 | zoomValue: { | 132 | zoomValue: { |
144 | value: 8 | 133 | value: 8 |
145 | }, | 134 | }, |
@@ -170,6 +159,7 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ | |||
170 | } | 159 | } |
171 | var service = new google.maps.places.PlacesService(this._map); | 160 | var service = new google.maps.places.PlacesService(this._map); |
172 | service.search(request, function(results, status) { | 161 | service.search(request, function(results, status) { |
162 | console.log('got places for ', self.category, status, results); | ||
173 | if (status == google.maps.places.PlacesServiceStatus.OK) { | 163 | if (status == google.maps.places.PlacesServiceStatus.OK) { |
174 | self._places = results; | 164 | self._places = results; |
175 | } else { | 165 | } else { |
@@ -192,12 +182,18 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ | |||
192 | case 'hospital': | 182 | case 'hospital': |
193 | icon = '10-medical.png'; | 183 | icon = '10-medical.png'; |
194 | break; | 184 | break; |
195 | case 'cafe': | 185 | case 'bar': |
196 | icon = '34-coffee.png'; | 186 | icon = '88-beer-mug.png'; |
187 | break; | ||
188 | case 'grocery_or_supermarket': | ||
189 | icon = '80-shopping-cart.png'; | ||
197 | break; | 190 | break; |
198 | case 'museum': | 191 | case 'museum': |
199 | icon = '41-picture-frame.png'; | 192 | icon = '41-picture-frame.png'; |
200 | break; | 193 | break; |
194 | case 'gas_station': | ||
195 | icon = '47-fuel.png'; | ||
196 | break; | ||
201 | }; | 197 | }; |
202 | if(icon) { | 198 | if(icon) { |
203 | image = new google.maps.MarkerImage('images/' + icon); | 199 | image = new google.maps.MarkerImage('images/' + icon); |
@@ -258,7 +254,7 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ | |||
258 | this._map = new window.google.maps.Map(this.mapEl, myOptions); | 254 | this._map = new window.google.maps.Map(this.mapEl, myOptions); |
259 | } else { | 255 | } else { |
260 | var map = this._map; | 256 | var map = this._map; |
261 | map.setZoom(12); | 257 | map.setZoom(10); |
262 | var latLng = new window.google.maps.LatLng(latLng.lat, latLng.lng); | 258 | var latLng = new window.google.maps.LatLng(latLng.lat, latLng.lng); |
263 | map.setCenter(latLng); | 259 | map.setCenter(latLng); |
264 | var marker = new google.maps.Marker({ | 260 | var marker = new google.maps.Marker({ |
@@ -268,11 +264,21 @@ var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/ | |||
268 | 264 | ||
269 | var places = this._places; | 265 | var places = this._places; |
270 | if(places && places.length > 0) { | 266 | if(places && places.length > 0) { |
267 | map.setZoom(13); | ||
271 | this._removeAllMarkers(); | 268 | this._removeAllMarkers(); |
272 | for (var i = 0; i < places.length; i++) { | 269 | for (var i = 0; i < places.length; i++) { |
273 | this._createMarker(places[i]); | 270 | this._createMarker(places[i]); |
274 | } | 271 | } |
275 | } | 272 | } |
273 | |||
274 | if(this.traffic === true) { | ||
275 | this.trafficLayer = new google.maps.TrafficLayer(); | ||
276 | this.trafficLayer.setMap(map); | ||
277 | } else { | ||
278 | if(this.trafficLayer) { | ||
279 | this.trafficLayer.setMap(null); | ||
280 | } | ||
281 | } | ||
276 | } | 282 | } |
277 | 283 | ||
278 | } | 284 | } |