aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage-google/map.reel
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/montage-google/map.reel')
-rw-r--r--node_modules/montage-google/map.reel/map.css9
-rw-r--r--node_modules/montage-google/map.reel/map.html46
-rw-r--r--node_modules/montage-google/map.reel/map.js289
3 files changed, 344 insertions, 0 deletions
diff --git a/node_modules/montage-google/map.reel/map.css b/node_modules/montage-google/map.reel/map.css
new file mode 100644
index 00000000..45307593
--- /dev/null
+++ b/node_modules/montage-google/map.reel/map.css
@@ -0,0 +1,9 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6.montage-google-map {
7 width: 100%;
8 height: 100%;
9} \ No newline at end of file
diff --git a/node_modules/montage-google/map.reel/map.html b/node_modules/montage-google/map.reel/map.html
new file mode 100644
index 00000000..fee3a38e
--- /dev/null
+++ b/node_modules/montage-google/map.reel/map.html
@@ -0,0 +1,46 @@
1<!DOCTYPE html>
2<!-- <copyright>
3 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
4 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
5 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
6 </copyright> -->
7<html>
8<head>
9 <title></title>
10 <link rel="stylesheet" type="text/css" href="map.css">
11 <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&callback=initialize&libraries=places"></script>
12
13
14 <script type="text/montage-serialization">
15 {
16
17 "owner": {
18 "prototype": "montage-google/map.reel",
19 "properties": {
20 "element": {"#": "map-container"},
21 "mapEl": {"#": "map"}
22 }
23 }
24 }
25 </script>
26
27 <style>
28
29 .montage-google-map {
30 margin: 0;
31 padding: 0;
32 width: 100%;
33 height: 100%;
34 }
35
36 </style>
37
38</head>
39<body>
40
41 <div data-montage-id="map-container">
42 <div data-montage-id="map" id="map" class="montage-google-map">MAP</div>
43 </div>
44
45</body>
46</html>
diff --git a/node_modules/montage-google/map.reel/map.js b/node_modules/montage-google/map.reel/map.js
new file mode 100644
index 00000000..3ba7fff7
--- /dev/null
+++ b/node_modules/montage-google/map.reel/map.js
@@ -0,0 +1,289 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6/**
7
8 @requires montage/core/core
9 @requires montage/ui/component
10*/
11var Montage = require("montage").Montage,
12 Component = require("montage/ui/component").Component;
13
14/**
15 @class module:"montage/ui/google/map.reel".Map
16 @extends module:montage/ui/component.Component
17 */
18var Map = exports.Map = Montage.create(Component, /** @lends module:"montage/ui/toggle-switch.reel".ToggleSwitch# */ {
19
20 didCreate: {
21 value: function() {
22 var self = this;
23 window.initialize = function initialize() {
24 console.log('google maps api loaded');
25 self._mapLoaded = true;
26 self._geoCoder = new google.maps.Geocoder();
27 self.needsDraw = true;
28 };
29 }
30 },
31
32 _geoCoder: {value: null},
33
34 // HTMLElement to load the Map into
35 mapEl: {value: null},
36
37 _mapLoaded: {
38 enumerable: false,
39 value: false
40 },
41 _map: {
42 enumerable: false,
43 value: false
44 },
45
46 // Sunnyvale, CA
47 defaultLatLng: {
48 value: {lat: 37.37, lng: -122.03}
49 },
50
51 _latLng: {
52 value: this.defaultLatLng,
53 distinct: true
54 },
55 latLng: {
56 get: function() {
57 return this._latLng;
58 },
59 set: function(value) {
60 if(value) {
61 this._latLng = value;
62 // refresh the map
63 this.needsDraw = true;
64 }
65 }
66 },
67
68 // {lat, lon} Or a String representing the location (eg: Paris, France)
69 center: {
70 get: function() {
71 return this._center;
72 },
73 set: function(value) {
74 if(value) {
75 var self = this, geocoder = this._geoCoder;
76 this._center = value;
77 if(this._mapLoaded) {
78
79 if(String.isString(value)) {
80 // geocode
81 geocoder.geocode( { 'address': value}, function(results, status) {
82 if (status == google.maps.GeocoderStatus.OK) {
83 var loc = results[0].geometry.location;
84 self.latLng = {lat: loc.lat(), lng: loc.lng()};
85 } else {
86 console.log('Geocode was not successful : ' + status);
87 }
88 });
89 } else if(value.lat && value.lng) {
90 this.latLng = value;
91 } else {
92 // default location
93 this.latLng = this.defaultLatLng;
94 }
95
96 }
97
98 }
99
100 }
101 },
102
103 category: {
104 get: function() {
105 return this._category;
106 },
107 set: function(value) {
108 console.log('category set: ' + value);
109 if(value) {
110 this._category = value;
111 this._getPlaces(this._category);
112 this.needsDraw = true;
113 }
114 }
115 },
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
132 zoomValue: {
133 value: 8
134 },
135
136 __places: {value: null},
137 _places: {
138 get: function() {
139 return this.__places;
140 },
141 set: function(value) {
142 if(value) {
143 this.__places = value;
144 this.needsDraw = true;
145 }
146 }
147 },
148
149 _getPlaces: {
150 value: function(type, keyword) {
151 var self = this;
152 var request = {
153 location: new window.google.maps.LatLng(this.latLng.lat, this.latLng.lng),
154 radius: 5000,
155 types: [type]
156 };
157 if(!this._infoWindow) {
158 this._infoWindow = new google.maps.InfoWindow();
159 }
160 var service = new google.maps.places.PlacesService(this._map);
161 service.search(request, function(results, status) {
162 console.log('got places for ', self.category, status, results);
163 if (status == google.maps.places.PlacesServiceStatus.OK) {
164 self._places = results;
165 } else {
166 self._places = [];
167 }
168 });
169 }
170 },
171
<