gmaps4rails 2.0.0.pre → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/.travis.yml +2 -4
  2. data/Gemfile +5 -1
  3. data/Gemfile.lock +31 -113
  4. data/README.rdoc +53 -70
  5. data/Rakefile +21 -1
  6. data/gmaps4rails.gemspec +4 -19
  7. data/js_compilation/gmaps_google.js +961 -0
  8. data/lib/generators/gmaps4rails/copy_coffee_generator.rb +14 -0
  9. data/lib/generators/gmaps4rails/copy_js_generator.rb +15 -0
  10. data/lib/gmaps4rails.rb +12 -22
  11. data/lib/gmaps4rails/markers_builder.rb +74 -0
  12. data/lib/gmaps4rails/rails/engine.rb +6 -0
  13. data/lib/gmaps4rails/rails/railtie.rb +6 -0
  14. data/lib/gmaps4rails/version.rb +2 -2
  15. data/script/compile_coffee_files.rb +19 -0
  16. data/script/gmaps4rails.rake +7 -0
  17. data/spec/javascripts/google/builders/marker_spec.js +96 -0
  18. data/spec/javascripts/helpers/SpecHelper.js +101 -0
  19. data/spec/javascripts/helpers/matchers.js +12 -0
  20. data/spec/javascripts/helpers/underscore.js +6 -0
  21. data/spec/javascripts/objects/handler_spec.js +320 -0
  22. data/spec/javascripts/support/jasmine.yml +86 -0
  23. data/spec/javascripts/support/jasmine_helper.rb +11 -0
  24. data/spec/lib/base_spec.rb +10 -52
  25. data/spec/lib/markers_builder_spec.rb +49 -0
  26. data/spec/spec_helper.rb +1 -25
  27. data/vendor/assets/javascripts/gmaps/base.coffee +16 -0
  28. data/vendor/assets/javascripts/gmaps/base/base.coffee +17 -0
  29. data/vendor/assets/javascripts/gmaps/google.coffee +3 -0
  30. data/vendor/assets/javascripts/gmaps/google/builders/bound.coffee +6 -0
  31. data/vendor/assets/javascripts/gmaps/google/builders/circle.coffee +21 -0
  32. data/vendor/assets/javascripts/gmaps/google/builders/clusterer.coffee +6 -0
  33. data/vendor/assets/javascripts/gmaps/google/builders/kml.coffee +17 -0
  34. data/vendor/assets/javascripts/gmaps/google/builders/map.coffee +27 -0
  35. data/vendor/assets/javascripts/gmaps/google/builders/marker.coffee +100 -0
  36. data/vendor/assets/javascripts/gmaps/google/builders/polygon.coffee +24 -0
  37. data/vendor/assets/javascripts/gmaps/google/builders/polyline.coffee +24 -0
  38. data/vendor/assets/javascripts/gmaps/google/objects/bound.coffee +13 -0
  39. data/vendor/assets/javascripts/gmaps/google/objects/circle.coffee +9 -0
  40. data/vendor/assets/javascripts/gmaps/google/objects/clusterer.coffee +13 -0
  41. data/vendor/assets/javascripts/gmaps/google/objects/common.coffee +23 -0
  42. data/vendor/assets/javascripts/gmaps/google/objects/kml.coffee +15 -0
  43. data/vendor/assets/javascripts/gmaps/google/objects/map.coffee +19 -0
  44. data/vendor/assets/javascripts/gmaps/google/objects/marker.coffee +11 -0
  45. data/vendor/assets/javascripts/gmaps/google/objects/polygon.coffee +8 -0
  46. data/vendor/assets/javascripts/gmaps/google/objects/polyline.coffee +8 -0
  47. data/vendor/assets/javascripts/gmaps/google/primitives.coffee +43 -0
  48. data/vendor/assets/javascripts/gmaps/objects/base_builder.coffee +20 -0
  49. data/vendor/assets/javascripts/gmaps/objects/builder.coffee +12 -0
  50. data/vendor/assets/javascripts/gmaps/objects/handler.coffee +153 -0
  51. data/vendor/assets/javascripts/gmaps/objects/null_clusterer.coffee +4 -0
  52. metadata +66 -299
  53. data/Guardfile.old +0 -24
  54. data/app/views/gmaps4rails/_gmaps4rails.html.erb +0 -20
  55. data/lib/generators/gmaps4rails/install_generator.rb +0 -43
  56. data/lib/generators/templates/README +0 -2
  57. data/lib/gmaps4rails/acts_as_gmappable.rb +0 -54
  58. data/lib/gmaps4rails/api_wrappers/base_net_methods.rb +0 -40
  59. data/lib/gmaps4rails/api_wrappers/direction.rb +0 -87
  60. data/lib/gmaps4rails/api_wrappers/geocoder.rb +0 -54
  61. data/lib/gmaps4rails/api_wrappers/places.rb +0 -74
  62. data/lib/gmaps4rails/base.rb +0 -126
  63. data/lib/gmaps4rails/extensions/enumerable.rb +0 -14
  64. data/lib/gmaps4rails/extensions/hash.rb +0 -9
  65. data/lib/gmaps4rails/helper/gmaps4rails_helper.rb +0 -33
  66. data/lib/gmaps4rails/js_builder.rb +0 -154
  67. data/lib/gmaps4rails/json_builder.rb +0 -140
  68. data/lib/gmaps4rails/model_handler.rb +0 -101
  69. data/lib/gmaps4rails/view_helper.rb +0 -172
  70. data/lib/tasks/jasmine.rake +0 -8
  71. data/public/javascripts/gmaps4rails/all.js +0 -2144
  72. data/public/javascripts/gmaps4rails/base.js +0 -792
  73. data/public/javascripts/gmaps4rails/google.js +0 -556
  74. data/public/javascripts/gmaps4rails/openlayers.js +0 -377
  75. data/public/stylesheets/gmaps4rails.css +0 -24
  76. data/spec/dummy/.gitignore +0 -3
  77. data/spec/dummy/.rspec +0 -1
  78. data/spec/dummy/README.rdoc +0 -261
  79. data/spec/dummy/Rakefile +0 -7
  80. data/spec/dummy/app/assets/javascripts/application.js +0 -18
  81. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  82. data/spec/dummy/app/assets/stylesheets/gmaps4rails.css +0 -24
  83. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  84. data/spec/dummy/app/controllers/users_controller.rb +0 -105
  85. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  86. data/spec/dummy/app/mailers/.gitkeep +0 -0
  87. data/spec/dummy/app/models/.gitkeep +0 -0
  88. data/spec/dummy/app/models/place.rb +0 -16
  89. data/spec/dummy/app/models/user.rb +0 -12
  90. data/spec/dummy/app/views/layouts/application.html.erb +0 -17
  91. data/spec/dummy/app/views/users/_form.html.erb +0 -37
  92. data/spec/dummy/app/views/users/edit.html.erb +0 -6
  93. data/spec/dummy/app/views/users/index.html.erb +0 -268
  94. data/spec/dummy/app/views/users/new.html.erb +0 -5
  95. data/spec/dummy/app/views/users/show.html.erb +0 -30
  96. data/spec/dummy/config.ru +0 -4
  97. data/spec/dummy/config/application.rb +0 -62
  98. data/spec/dummy/config/boot.rb +0 -10
  99. data/spec/dummy/config/database.yml +0 -25
  100. data/spec/dummy/config/environment.rb +0 -5
  101. data/spec/dummy/config/environments/development.rb +0 -37
  102. data/spec/dummy/config/environments/production.rb +0 -67
  103. data/spec/dummy/config/environments/test.rb +0 -37
  104. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  105. data/spec/dummy/config/initializers/gmaps4rails.rb +0 -1
  106. data/spec/dummy/config/initializers/inflections.rb +0 -15
  107. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  108. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  109. data/spec/dummy/config/initializers/session_store.rb +0 -8
  110. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  111. data/spec/dummy/config/locales/en.yml +0 -5
  112. data/spec/dummy/config/routes.rb +0 -60
  113. data/spec/dummy/db/migrate/20120408170155_create_users.rb +0 -16
  114. data/spec/dummy/db/schema.rb +0 -29
  115. data/spec/dummy/lib/assets/.gitkeep +0 -0
  116. data/spec/dummy/log/.gitkeep +0 -0
  117. data/spec/dummy/public/404.html +0 -26
  118. data/spec/dummy/public/422.html +0 -26
  119. data/spec/dummy/public/500.html +0 -25
  120. data/spec/dummy/public/favicon.ico +0 -0
  121. data/spec/dummy/public/javascripts/Player.js +0 -22
  122. data/spec/dummy/public/javascripts/Song.js +0 -7
  123. data/spec/dummy/public/logo.png +0 -0
  124. data/spec/dummy/script/rails +0 -6
  125. data/spec/factories/place_factory.rb +0 -16
  126. data/spec/factories/user_factory.rb +0 -23
  127. data/spec/fixtures/google_direction_valid.json +0 -65
  128. data/spec/fixtures/google_geocoding_toulon_france.json +0 -58
  129. data/spec/fixtures/google_places_valid.json +0 -45
  130. data/spec/fixtures/google_wrong_geocoding.json +0 -4
  131. data/spec/launchers/all_but_requests.rb +0 -0
  132. data/spec/launchers/all_specs.rb +0 -0
  133. data/spec/launchers/requests.rb +0 -0
  134. data/spec/lib/direction_spec.rb +0 -53
  135. data/spec/lib/geocoder_spec.rb +0 -46
  136. data/spec/lib/js_builder_spec.rb +0 -134
  137. data/spec/lib/json_builder_spec.rb +0 -232
  138. data/spec/lib/places_spec.rb +0 -25
  139. data/spec/models/place_spec.rb +0 -39
  140. data/spec/models/user_spec.rb +0 -187
  141. data/spec/support/geocoding.rb +0 -40
  142. data/spec/support/matchers.rb +0 -73
  143. data/todo +0 -0
  144. data/vendor/assets/javascripts/gmaps4rails/all.js +0 -1
  145. data/vendor/assets/javascripts/gmaps4rails/base.coffee +0 -1
  146. data/vendor/assets/javascripts/gmaps4rails/base/common.coffee +0 -43
  147. data/vendor/assets/javascripts/gmaps4rails/base/configuration.coffee +0 -7
  148. data/vendor/assets/javascripts/gmaps4rails/base/gmaps.coffee +0 -13
  149. data/vendor/assets/javascripts/gmaps4rails/base/interfaces/basic_interface.coffee +0 -15
  150. data/vendor/assets/javascripts/gmaps4rails/base/interfaces/controller_interface.coffee +0 -15
  151. data/vendor/assets/javascripts/gmaps4rails/base/interfaces/map_interface.coffee +0 -27
  152. data/vendor/assets/javascripts/gmaps4rails/base/interfaces/marker_interface.coffee +0 -15
  153. data/vendor/assets/javascripts/gmaps4rails/base/main.coffee +0 -124
  154. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/circle_controller.coffee +0 -29
  155. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/kml_controller.coffee +0 -5
  156. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/marker_controller.coffee +0 -76
  157. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/polygon_controller.coffee +0 -29
  158. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/polyline_controller.coffee +0 -29
  159. data/vendor/assets/javascripts/gmaps4rails/base/objects/circle.coffee +0 -12
  160. data/vendor/assets/javascripts/gmaps4rails/base/objects/kml.coffee +0 -8
  161. data/vendor/assets/javascripts/gmaps4rails/base/objects/map.coffee +0 -62
  162. data/vendor/assets/javascripts/gmaps4rails/base/objects/marker.coffee +0 -24
  163. data/vendor/assets/javascripts/gmaps4rails/base/objects/polygon.coffee +0 -11
  164. data/vendor/assets/javascripts/gmaps4rails/base/objects/polyline.coffee +0 -11
  165. data/vendor/assets/javascripts/gmaps4rails/bing.coffee +0 -1
  166. data/vendor/assets/javascripts/gmaps4rails/bing/main.coffee +0 -29
  167. data/vendor/assets/javascripts/gmaps4rails/bing/objects/map.coffee +0 -63
  168. data/vendor/assets/javascripts/gmaps4rails/bing/objects/marker.coffee +0 -78
  169. data/vendor/assets/javascripts/gmaps4rails/bing/shared.coffee +0 -20
  170. data/vendor/assets/javascripts/gmaps4rails/google.coffee +0 -1
  171. data/vendor/assets/javascripts/gmaps4rails/google/main.coffee +0 -47
  172. data/vendor/assets/javascripts/gmaps4rails/google/objects/circle.coffee +0 -38
  173. data/vendor/assets/javascripts/gmaps4rails/google/objects/kml.coffee +0 -16
  174. data/vendor/assets/javascripts/gmaps4rails/google/objects/map.coffee +0 -71
  175. data/vendor/assets/javascripts/gmaps4rails/google/objects/marker.coffee +0 -114
  176. data/vendor/assets/javascripts/gmaps4rails/google/objects/polygon.coffee +0 -38
  177. data/vendor/assets/javascripts/gmaps4rails/google/objects/polyline.coffee +0 -49
  178. data/vendor/assets/javascripts/gmaps4rails/google/shared.coffee +0 -27
  179. data/vendor/assets/javascripts/gmaps4rails/openlayers.coffee +0 -1
  180. data/vendor/assets/javascripts/gmaps4rails/openlayers/main.coffee +0 -138
  181. data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/map.coffee +0 -49
  182. data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/marker.coffee +0 -68
  183. data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/polyline.coffee +0 -39
  184. data/vendor/assets/javascripts/gmaps4rails/openlayers/shared.coffee +0 -19
@@ -1,556 +0,0 @@
1
- (function() {
2
-
3
- Gmaps4Rails.Google = {};
4
-
5
- Gmaps4Rails.Google.Shared = {
6
- createPoint: function(lat, lng) {
7
- return new google.maps.Point(lat, lng);
8
- },
9
- createSize: function(width, height) {
10
- return new google.maps.Size(width, height);
11
- },
12
- createLatLng: function(lat, lng) {
13
- return new google.maps.LatLng(lat, lng);
14
- },
15
- createLatLngBounds: function() {
16
- return new google.maps.LatLngBounds();
17
- },
18
- clear: function() {
19
- return this.serviceObject.setMap(null);
20
- },
21
- show: function() {
22
- return this.serviceObject.setVisible(true);
23
- },
24
- hide: function() {
25
- return this.serviceObject.setVisible(false);
26
- },
27
- isVisible: function() {
28
- return this.serviceObject.getVisible();
29
- }
30
- };
31
-
32
- }).call(this);
33
- (function() {
34
- var __hasProp = Object.prototype.hasOwnProperty,
35
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
36
-
37
- this.Gmaps4Rails.Google.Circle = (function(_super) {
38
-
39
- __extends(Circle, _super);
40
-
41
- Circle.include(Gmaps4Rails.Interfaces.Basic);
42
-
43
- Circle.include(Gmaps4Rails.Google.Shared);
44
-
45
- Circle.extend(Gmaps4Rails.Circle.Class);
46
-
47
- Circle.extend(Gmaps4Rails.Configuration);
48
-
49
- function Circle(circle, controller) {
50
- var circleOptions, mergedOptions;
51
- this.controller = controller;
52
- if (circle === this.controller.circles[0]) {
53
- if (circle.strokeColor != null) {
54
- this.controller.circles_conf.strokeColor = circle.strokeColor;
55
- }
56
- if (circle.strokeOpacity != null) {
57
- this.controller.circles_conf.strokeOpacity = circle.strokeOpacity;
58
- }
59
- if (circle.strokeWeight != null) {
60
- this.controller.circles_conf.strokeWeight = circle.strokeWeight;
61
- }
62
- if (circle.fillColor != null) {
63
- this.controller.circles_conf.fillColor = circle.fillColor;
64
- }
65
- if (circle.fillOpacity != null) {
66
- this.controller.circles_conf.fillOpacity = circle.fillOpacity;
67
- }
68
- }
69
- if ((circle.lat != null) && (circle.lng != null)) {
70
- circleOptions = {
71
- center: this.createLatLng(circle.lat, circle.lng),
72
- strokeColor: circle.strokeColor || this.controller.circles_conf.strokeColor,
73
- strokeOpacity: circle.strokeOpacity || this.controller.circles_conf.strokeOpacity,
74
- strokeWeight: circle.strokeWeight || this.controller.circles_conf.strokeWeight,
75
- fillOpacity: circle.fillOpacity || this.controller.circles_conf.fillOpacity,
76
- fillColor: circle.fillColor || this.controller.circles_conf.fillColor,
77
- clickable: circle.clickable || this.controller.circles_conf.clickable,
78
- zIndex: circle.zIndex || this.controller.circles_conf.zIndex,
79
- radius: circle.radius
80
- };
81
- mergedOptions = this.mergeObjects(this.controller.circles_conf.raw, circleOptions);
82
- this.serviceObject = new google.maps.Circle(mergedOptions);
83
- this.serviceObject.setMap(this.controller.getMapObject());
84
- }
85
- }
86
-
87
- return Circle;
88
-
89
- })(Gmaps4Rails.Common);
90
-
91
- }).call(this);
92
- (function() {
93
- var __hasProp = Object.prototype.hasOwnProperty,
94
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
95
-
96
- this.Gmaps4Rails.Google.Kml = (function(_super) {
97
-
98
- __extends(Kml, _super);
99
-
100
- Kml.include(Gmaps4Rails.Interfaces.Basic);
101
-
102
- Kml.include(Gmaps4Rails.Google.Shared);
103
-
104
- Kml.include(Gmaps4Rails.Kml.Instance);
105
-
106
- function Kml(kmlData, controller) {
107
- var kml;
108
- this.controller = controller;
109
- this.options = kmlData.options || {};
110
- this.options = this.mergeObjects(this.options, this.DEFAULT_CONF);
111
- kml = new google.maps.KmlLayer(kmlData.url, this.options);
112
- kml.setMap(this.controller.getMapObject());
113
- this.serviceObject = kml;
114
- }
115
-
116
- return Kml;
117
-
118
- })(Gmaps4Rails.Common);
119
-
120
- }).call(this);
121
- (function() {
122
- var __hasProp = Object.prototype.hasOwnProperty,
123
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
124
-
125
- Gmaps4Rails.Google.Map = (function(_super) {
126
-
127
- __extends(Map, _super);
128
-
129
- Map.include(Gmaps4Rails.Interfaces.Map);
130
-
131
- Map.include(Gmaps4Rails.Map);
132
-
133
- Map.include(Gmaps4Rails.Google.Shared);
134
-
135
- Map.include(Gmaps4Rails.Configuration);
136
-
137
- Map.prototype.CONF = {
138
- disableDefaultUI: false,
139
- disableDoubleClickZoom: false,
140
- type: "ROADMAP",
141
- mapTypeControl: null
142
- };
143
-
144
- function Map(map_options, controller) {
145
- var defaultOptions, googleOptions, mergedGoogleOptions;
146
- this.controller = controller;
147
- defaultOptions = this.setConf();
148
- this.options = this.mergeObjects(map_options, defaultOptions);
149
- googleOptions = {
150
- maxZoom: this.options.maxZoom,
151
- minZoom: this.options.minZoom,
152
- zoom: this.options.zoom,
153
- center: this.createLatLng(this.options.center_latitude, this.options.center_longitude),
154
- mapTypeId: google.maps.MapTypeId[this.options.type],
155
- mapTypeControl: this.options.mapTypeControl,
156
- disableDefaultUI: this.options.disableDefaultUI,
157
- disableDoubleClickZoom: this.options.disableDoubleClickZoom,
158
- draggable: this.options.draggable
159
- };
160
- mergedGoogleOptions = this.mergeObjects(map_options.raw, googleOptions);
161
- this.serviceObject = new google.maps.Map(document.getElementById(this.options.id), mergedGoogleOptions);
162
- }
163
-
164
- Map.prototype.extendBoundsWithMarker = function(marker) {
165
- return this.boundsObject.extend(marker.serviceObject.position);
166
- };
167
-
168
- Map.prototype.extendBoundsWithPolyline = function(polyline) {
169
- var point, polyline_points, _i, _len, _results;
170
- polyline_points = polyline.serviceObject.latLngs.getArray()[0].getArray();
171
- _results = [];
172
- for (_i = 0, _len = polyline_points.length; _i < _len; _i++) {
173
- point = polyline_points[_i];
174
- _results.push(this.boundsObject.extend(point));
175
- }
176
- return _results;
177
- };
178
-
179
- Map.prototype.extendBoundsWithPolygon = function(polygon) {
180
- var point, polygon_points, _i, _len, _results;
181
- polygon_points = polygon.serviceObject.latLngs.getArray()[0].getArray();
182
- _results = [];
183
- for (_i = 0, _len = polygon_points.length; _i < _len; _i++) {
184
- point = polygon_points[_i];
185
- _results.push(this.boundsObject.extend(point));
186
- }
187
- return _results;
188
- };
189
-
190
- Map.prototype.extendBoundsWithCircle = function(circle) {
191
- this.boundsObject.extend(circle.serviceObject.getBounds().getNorthEast());
192
- return this.boundsObject.extend(circle.serviceObject.getBounds().getSouthWest());
193
- };
194
-
195
- Map.prototype.extendBound = function(bound) {
196
- return this.boundsObject.extend(this.createLatLng(bound.lat, bound.lng));
197
- };
198
-
199
- Map.prototype.adaptToBounds = function() {
200
- var map_center;
201
- if (!this.options.auto_zoom) {
202
- map_center = this.boundsObject.getCenter();
203
- this.options.center_latitude = map_center.lat();
204
- this.options.center_longitude = map_center.lng();
205
- return this.serviceObject.setCenter(map_center);
206
- } else {
207
- return this.fitBounds();
208
- }
209
- };
210
-
211
- Map.prototype.fitBounds = function() {
212
- if (!this.boundsObject.isEmpty()) {
213
- return this.serviceObject.fitBounds(this.boundsObject);
214
- }
215
- };
216
-
217
- Map.prototype.centerMapOnUser = function(position) {
218
- return this.serviceObject.setCenter(position);
219
- };
220
-
221
- return Map;
222
-
223
- })(Gmaps4Rails.Common);
224
-
225
- }).call(this);
226
- (function() {
227
- var __hasProp = Object.prototype.hasOwnProperty,
228
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
229
-
230
- Gmaps4Rails.Google.Marker = (function(_super) {
231
- var CONF;
232
-
233
- __extends(Marker, _super);
234
-
235
- Marker.include(Gmaps4Rails.Interfaces.Marker);
236
-
237
- Marker.include(Gmaps4Rails.Google.Shared);
238
-
239
- Marker.include(Gmaps4Rails.Marker.Instance);
240
-
241
- Marker.extend(Gmaps4Rails.Marker.Class);
242
-
243
- Marker.extend(Gmaps4Rails.Configuration);
244
-
245
- CONF = {
246
- clusterer_gridSize: 50,
247
- clusterer_maxZoom: 5,
248
- custom_cluster_pictures: null,
249
- custom_infowindow_class: null,
250
- raw: {}
251
- };
252
-
253
- function Marker(args, controller) {
254
- var markerLatLng;
255
- this.controller = controller;
256
- markerLatLng = this.createLatLng(args.lat, args.lng);
257
- if (this._isBasicMarker(args)) {
258
- this._createBasicMarker(markerLatLng, args);
259
- } else {
260
- if (args.rich_marker != null) {
261
- this._createRichMarker(markerLatLng, args);
262
- } else {
263
- this._createMarker(markerLatLng, args);
264
- }
265
- }
266
- }
267
-
268
- Marker.prototype.createInfoWindow = function() {
269
- var boxText;
270
- if (typeof this.controller.jsTemplate === "function" || (this.description != null)) {
271
- if (typeof this.controller.jsTemplate === "function") {
272
- this.description = this.controller.jsTemplate(this);
273
- }
274
- if (CONF.custom_infowindow_class != null) {
275
- boxText = document.createElement("div");
276
- boxText.setAttribute("class", CONF.custom_infowindow_class);
277
- boxText.innerHTML = this.description;
278
- this.infowindow = new InfoBox(this.infobox(boxText));
279
- return google.maps.event.addListener(this.serviceObject, 'click', this._openInfowindow());
280
- } else {
281
- this.infowindow = new google.maps.InfoWindow({
282
- content: this.description
283
- });
284
- return google.maps.event.addListener(this.serviceObject, 'click', this._openInfowindow());
285
- }
286
- }
287
- };
288
-
289
- Marker.prototype._createBasicMarker = function(markerLatLng, args) {
290
- var defaultOptions, mergedOptions;
291
- defaultOptions = {
292
- position: markerLatLng,
293
- map: this.getMap(),
294
- title: args.marker_title,
295
- draggable: args.marker_draggable,
296
- zIndex: args.zindex
297
- };
298
- mergedOptions = this.mergeObjects(CONF.raw, defaultOptions);
299
- return this.serviceObject = new google.maps.Marker(defaultOptions);
300
- };
301
-
302
- Marker.prototype._createRichMarker = function(markerLatLng, args) {
303
- return new RichMarker({
304
- position: markerLatLng,
305
- map: this.serviceObject,
306
- draggable: args.marker_draggable,
307
- content: args.rich_marker,
308
- flat: args.marker_anchor === null ? false : args.marker_anchor[1],
309
- anchor: args.marker_anchor === null ? 0 : args.marker_anchor[0],
310
- zIndex: args.zindex
311
- });
312
- };
313
-
314
- Marker.prototype._createMarker = function(markerLatLng, args) {
315
- var defaultOptions, imageAnchorPosition, markerImage, mergedOptions, shadowAnchorPosition, shadowImage;
316
- imageAnchorPosition = this._createImageAnchorPosition(args.marker_anchor);
317
- shadowAnchorPosition = this._createImageAnchorPosition(args.shadow_anchor);
318
- markerImage = this._createOrRetrieveImage(args.marker_picture, args.marker_width, args.marker_height, imageAnchorPosition);
319
- shadowImage = this._createOrRetrieveImage(args.shadow_picture, args.shadow_width, args.shadow_height, shadowAnchorPosition);
320
- defaultOptions = {
321
- position: markerLatLng,
322
- map: this.getMap(),
323
- icon: markerImage,
324
- title: args.marker_title,
325
- draggable: args.marker_draggable,
326
- shadow: shadowImage,
327
- zIndex: args.zindex
328
- };
329
- mergedOptions = this.mergeObjects(CONF.raw, defaultOptions);
330
- return this.serviceObject = new google.maps.Marker(mergedOptions);
331
- };
332
-
333
- Marker.prototype._includeMarkerImage = function(obj) {
334
- var index, object, _len, _ref;
335
- _ref = this.controller.markerImages;
336
- for (index = 0, _len = _ref.length; index < _len; index++) {
337
- object = _ref[index];
338
- if (object.url === obj) return index;
339
- }
340
- return false;
341
- };
342
-
343
- Marker.prototype._createOrRetrieveImage = function(currentMarkerPicture, markerWidth, markerHeight, imageAnchorPosition) {
344
- var markerImage, test_image_index;
345
- if (typeof currentMarkerPicture === "undefined" || currentMarkerPicture === "" || currentMarkerPicture === null) {
346
- return null;
347
- }
348
- if (!(test_image_index = this._includeMarkerImage(currentMarkerPicture))) {
349
- markerImage = this._createMarkerImage(currentMarkerPicture, this.createSize(markerWidth, markerHeight), null, imageAnchorPosition, null);
350
- this.controller.markerImages.push(markerImage);
351
- return markerImage;
352
- } else {
353
- if (typeof test_image_index === 'number') {
354
- return this.controller.markerImages[test_image_index];
355
- }
356
- return false;
357
- }
358
- };
359
-
360
- Marker.prototype._isBasicMarker = function(args) {
361
- return !(args.marker_picture != null) && !(args.rich_marker != null);
362
- };
363
-
364
- Marker.prototype._createMarkerImage = function(markerPicture, markerSize, origin, anchor, scaledSize) {
365
- return new google.maps.MarkerImage(markerPicture, markerSize, origin, anchor, scaledSize);
366
- };
367
-
368
- Marker.prototype._createImageAnchorPosition = function(anchorLocation) {
369
- if (anchorLocation === null) {
370
- return null;
371
- } else {
372
- return this.createPoint(anchorLocation[0], anchorLocation[1]);
373
- }
374
- };
375
-
376
- Marker.prototype._openInfowindow = function() {
377
- var that;
378
- that = this;
379
- return function() {
380
- that.controller._closeVisibleInfoWindow();
381
- that.infowindow.open(that.getMap(), that.serviceObject);
382
- return that.controller._setVisibleInfoWindow(that.infowindow);
383
- };
384
- };
385
-
386
- return Marker;
387
-
388
- })(Gmaps4Rails.Common);
389
-
390
- }).call(this);
391
- (function() {
392
- var __hasProp = Object.prototype.hasOwnProperty,
393
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
394
-
395
- this.Gmaps4Rails.Google.Polygon = (function(_super) {
396
-
397
- __extends(Polygon, _super);
398
-
399
- Polygon.include(Gmaps4Rails.Interfaces.Basic);
400
-
401
- Polygon.include(Gmaps4Rails.Google.Shared);
402
-
403
- Polygon.extend(Gmaps4Rails.Polygon.Class);
404
-
405
- Polygon.extend(Gmaps4Rails.Configuration);
406
-
407
- function Polygon(polygon, controller) {
408
- var clickable, fillColor, fillOpacity, latlng, mergedOptions, point, polyOptions, polygon_coordinates, strokeColor, strokeOpacity, strokeWeight, _i, _len;
409
- this.controller = controller;
410
- polygon_coordinates = [];
411
- for (_i = 0, _len = polygon.length; _i < _len; _i++) {
412
- point = polygon[_i];
413
- latlng = this.createLatLng(point.lat, point.lng);
414
- polygon_coordinates.push(latlng);
415
- if (point === polygon[0]) {
416
- strokeColor = point.strokeColor || this.controller.polygons_conf.strokeColor;
417
- strokeOpacity = point.strokeOpacity || this.controller.polygons_conf.strokeOpacity;
418
- strokeWeight = point.strokeWeight || this.controller.polygons_conf.strokeWeight;
419
- fillColor = point.fillColor || this.controller.polygons_conf.fillColor;
420
- fillOpacity = point.fillOpacity || this.controller.polygons_conf.fillOpacity;
421
- clickable = point.clickable || this.controller.polygons_conf.clickable;
422
- }
423
- }
424
- polyOptions = {
425
- path: polyline_coordinates,
426
- strokeColor: strokeColor,
427
- strokeOpacity: strokeOpacity,
428
- strokeWeight: strokeWeight,
429
- clickable: clickable,
430
- zIndex: zIndex
431
- };
432
- mergedOptions = this.mergeObjects(controller.polygons_conf.raw, polyOptions);
433
- this.serviceObject = new google.maps.Polygon(mergedOptions);
434
- }
435
-
436
- return Polygon;
437
-
438
- })(Gmaps4Rails.Common);
439
-
440
- }).call(this);
441
- (function() {
442
- var __hasProp = Object.prototype.hasOwnProperty,
443
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
444
-
445
- this.Gmaps4Rails.Google.Polyline = (function(_super) {
446
-
447
- __extends(Polyline, _super);
448
-
449
- Polyline.include(Gmaps4Rails.Interfaces.Basic);
450
-
451
- Polyline.include(Gmaps4Rails.Google.Shared);
452
-
453
- Polyline.extend(Gmaps4Rails.Polyline.Class);
454
-
455
- Polyline.extend(Gmaps4Rails.Configuration);
456
-
457
- function Polyline(polyline, controller) {
458
- var clickable, decoded_array, element, mergedOptions, point, polyOptions, polyline_coordinates, strokeColor, strokeOpacity, strokeWeight, zIndex, _i, _j, _len, _len2;
459
- polyline_coordinates = [];
460
- for (_i = 0, _len = polyline.length; _i < _len; _i++) {
461
- element = polyline[_i];
462
- if (element.coded_array != null) {
463
- decoded_array = new google.maps.geometry.encoding.decodePath(element.coded_array);
464
- for (_j = 0, _len2 = decoded_array.length; _j < _len2; _j++) {
465
- point = decoded_array[_j];
466
- polyline_coordinates.push(point);
467
- }
468
- } else {
469
- if (element === polyline[0]) {
470
- strokeColor = element.strokeColor || controller.polylines_conf.strokeColor;
471
- strokeOpacity = element.strokeOpacity || controller.polylines_conf.strokeOpacity;
472
- strokeWeight = element.strokeWeight || controller.polylines_conf.strokeWeight;
473
- clickable = element.clickable || controller.polylines_conf.clickable;
474
- zIndex = element.zIndex || controller.polylines_conf.zIndex;
475
- }
476
- if ((element.lat != null) && (element.lng != null)) {
477
- polyline_coordinates.push(this.createLatLng(element.lat, element.lng));
478
- }
479
- }
480
- }
481
- polyOptions = {
482
- path: polyline_coordinates,
483
- strokeColor: strokeColor,
484
- strokeOpacity: strokeOpacity,
485
- strokeWeight: strokeWeight,
486
- clickable: clickable,
487
- zIndex: zIndex
488
- };
489
- mergedOptions = this.mergeObjects(controller.polylines_conf.raw, polyOptions);
490
- this.serviceObject = new google.maps.Polyline(mergedOptions);
491
- this.serviceObject.setMap(controller.getMapObject());
492
- }
493
-
494
- return Polyline;
495
-
496
- })(Gmaps4Rails.Common);
497
-
498
- }).call(this);
499
- (function() {
500
- var __hasProp = Object.prototype.hasOwnProperty,
501
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
502
-
503
- this.Gmaps4RailsGoogle = (function(_super) {
504
-
505
- __extends(Gmaps4RailsGoogle, _super);
506
-
507
- Gmaps4RailsGoogle.include(Gmaps4Rails.Google.Shared);
508
-
509
- Gmaps4RailsGoogle.prototype.getModule = function() {
510
- return Gmaps4Rails.Google;
511
- };
512
-
513
- function Gmaps4RailsGoogle() {
514
- Gmaps4RailsGoogle.__super__.constructor.apply(this, arguments);
515
- this.markerImages = [];
516
- }
517
-
518
- Gmaps4RailsGoogle.prototype.createClusterer = function(markers_array) {
519
- return new MarkerClusterer(this.getMapObject(), markers_array, {
520
- maxZoom: this.markers_conf.clusterer_maxZoom,
521
- gridSize: this.markers_conf.clusterer_gridSize,
522
- styles: this.customClusterer()
523
- });
524
- };
525
-
526
- Gmaps4RailsGoogle.prototype.clearClusterer = function() {
527
- return this.markerClusterer.clearMarkers();
528
- };
529
-
530
- Gmaps4RailsGoogle.prototype.clusterize = function() {
531
- var marker, markers_array, _i, _len, _ref;
532
- if (this.markers_conf.do_clustering) {
533
- if (this.markerClusterer != null) this.clearClusterer();
534
- markers_array = [];
535
- _ref = this.markers;
536
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
537
- marker = _ref[_i];
538
- markers_array.push(marker.serviceObject);
539
- }
540
- return this.markerClusterer = this.createClusterer(markers_array);
541
- }
542
- };
543
-
544
- Gmaps4RailsGoogle.prototype._closeVisibleInfoWindow = function() {
545
- if (this.visibleInfowindow != null) return this.visibleInfowindow.close();
546
- };
547
-
548
- Gmaps4RailsGoogle.prototype._setVisibleInfoWindow = function(infowindow) {
549
- return this.visibleInfowindow = infowindow;
550
- };
551
-
552
- return Gmaps4RailsGoogle;
553
-
554
- })(Gmaps4Rails.BaseController);
555
-
556
- }).call(this);