gmaps4rails 1.5.8 → 2.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. data/.gitignore +12 -0
  2. data/.travis.yml +9 -0
  3. data/Gemfile +7 -0
  4. data/Gemfile.lock +149 -0
  5. data/Guardfile.old +24 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.rdoc +129 -0
  8. data/Rakefile +4 -0
  9. data/app/views/gmaps4rails/_gmaps4rails.html.erb +20 -0
  10. data/gmaps4rails.gemspec +38 -0
  11. data/lib/generators/gmaps4rails/install_generator.rb +43 -0
  12. data/lib/generators/templates/README +2 -0
  13. data/lib/gmaps4rails.rb +26 -0
  14. data/lib/gmaps4rails/acts_as_gmappable.rb +54 -0
  15. data/lib/gmaps4rails/api_wrappers/base_net_methods.rb +40 -0
  16. data/lib/gmaps4rails/api_wrappers/direction.rb +87 -0
  17. data/lib/gmaps4rails/api_wrappers/geocoder.rb +54 -0
  18. data/lib/gmaps4rails/api_wrappers/places.rb +74 -0
  19. data/lib/gmaps4rails/base.rb +126 -0
  20. data/lib/gmaps4rails/extensions/enumerable.rb +14 -0
  21. data/lib/gmaps4rails/extensions/hash.rb +9 -0
  22. data/lib/gmaps4rails/helper/gmaps4rails_helper.rb +33 -0
  23. data/lib/gmaps4rails/js_builder.rb +154 -0
  24. data/lib/gmaps4rails/json_builder.rb +140 -0
  25. data/lib/gmaps4rails/model_handler.rb +101 -0
  26. data/lib/gmaps4rails/version.rb +3 -0
  27. data/lib/gmaps4rails/view_helper.rb +172 -0
  28. data/lib/tasks/jasmine.rake +8 -0
  29. data/public/javascripts/gmaps4rails/all.js +2144 -0
  30. data/public/javascripts/gmaps4rails/base.js +792 -0
  31. data/public/javascripts/gmaps4rails/google.js +556 -0
  32. data/public/javascripts/gmaps4rails/openlayers.js +377 -0
  33. data/public/stylesheets/gmaps4rails.css +24 -0
  34. data/spec/dummy/.gitignore +3 -0
  35. data/spec/dummy/.rspec +1 -0
  36. data/spec/dummy/README.rdoc +261 -0
  37. data/spec/dummy/Rakefile +7 -0
  38. data/spec/dummy/app/assets/javascripts/application.js +18 -0
  39. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  40. data/spec/dummy/app/assets/stylesheets/gmaps4rails.css +24 -0
  41. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  42. data/spec/dummy/app/controllers/users_controller.rb +105 -0
  43. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  44. data/spec/dummy/app/mailers/.gitkeep +0 -0
  45. data/spec/dummy/app/models/.gitkeep +0 -0
  46. data/spec/dummy/app/models/place.rb +16 -0
  47. data/spec/dummy/app/models/user.rb +12 -0
  48. data/spec/dummy/app/views/layouts/application.html.erb +17 -0
  49. data/spec/dummy/app/views/users/_form.html.erb +37 -0
  50. data/spec/dummy/app/views/users/edit.html.erb +6 -0
  51. data/spec/dummy/app/views/users/index.html.erb +268 -0
  52. data/spec/dummy/app/views/users/new.html.erb +5 -0
  53. data/spec/dummy/app/views/users/show.html.erb +30 -0
  54. data/spec/dummy/config.ru +4 -0
  55. data/spec/dummy/config/application.rb +62 -0
  56. data/spec/dummy/config/boot.rb +10 -0
  57. data/spec/dummy/config/database.yml +25 -0
  58. data/spec/dummy/config/environment.rb +5 -0
  59. data/spec/dummy/config/environments/development.rb +37 -0
  60. data/spec/dummy/config/environments/production.rb +67 -0
  61. data/spec/dummy/config/environments/test.rb +37 -0
  62. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  63. data/spec/dummy/config/initializers/gmaps4rails.rb +1 -0
  64. data/spec/dummy/config/initializers/inflections.rb +15 -0
  65. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  66. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  67. data/spec/dummy/config/initializers/session_store.rb +8 -0
  68. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  69. data/spec/dummy/config/locales/en.yml +5 -0
  70. data/spec/dummy/config/routes.rb +60 -0
  71. data/spec/dummy/db/migrate/20120408170155_create_users.rb +16 -0
  72. data/spec/dummy/db/schema.rb +29 -0
  73. data/spec/dummy/lib/assets/.gitkeep +0 -0
  74. data/spec/dummy/log/.gitkeep +0 -0
  75. data/spec/dummy/public/404.html +26 -0
  76. data/spec/dummy/public/422.html +26 -0
  77. data/spec/dummy/public/500.html +25 -0
  78. data/spec/dummy/public/favicon.ico +0 -0
  79. data/spec/dummy/public/javascripts/Player.js +22 -0
  80. data/spec/dummy/public/javascripts/Song.js +7 -0
  81. data/spec/dummy/public/logo.png +0 -0
  82. data/spec/dummy/script/rails +6 -0
  83. data/spec/factories/place_factory.rb +16 -0
  84. data/spec/factories/user_factory.rb +23 -0
  85. data/spec/fixtures/google_direction_valid.json +65 -0
  86. data/spec/fixtures/google_geocoding_toulon_france.json +58 -0
  87. data/spec/fixtures/google_places_valid.json +45 -0
  88. data/spec/fixtures/google_wrong_geocoding.json +4 -0
  89. data/spec/launchers/all_but_requests.rb +0 -0
  90. data/spec/launchers/all_specs.rb +0 -0
  91. data/spec/launchers/requests.rb +0 -0
  92. data/spec/lib/base_spec.rb +59 -0
  93. data/spec/lib/direction_spec.rb +53 -0
  94. data/spec/lib/geocoder_spec.rb +46 -0
  95. data/spec/lib/js_builder_spec.rb +134 -0
  96. data/spec/lib/json_builder_spec.rb +232 -0
  97. data/spec/lib/places_spec.rb +25 -0
  98. data/spec/models/place_spec.rb +39 -0
  99. data/spec/models/user_spec.rb +187 -0
  100. data/spec/spec_helper.rb +38 -0
  101. data/spec/support/geocoding.rb +40 -0
  102. data/spec/support/matchers.rb +73 -0
  103. data/todo +0 -0
  104. data/vendor/assets/javascripts/gmaps4rails/all.js +1 -0
  105. data/vendor/assets/javascripts/gmaps4rails/base.coffee +1 -0
  106. data/vendor/assets/javascripts/gmaps4rails/base/common.coffee +43 -0
  107. data/vendor/assets/javascripts/gmaps4rails/base/configuration.coffee +7 -0
  108. data/vendor/assets/javascripts/gmaps4rails/base/gmaps.coffee +13 -0
  109. data/vendor/assets/javascripts/gmaps4rails/base/interfaces/basic_interface.coffee +15 -0
  110. data/vendor/assets/javascripts/gmaps4rails/base/interfaces/controller_interface.coffee +15 -0
  111. data/vendor/assets/javascripts/gmaps4rails/base/interfaces/map_interface.coffee +27 -0
  112. data/vendor/assets/javascripts/gmaps4rails/base/interfaces/marker_interface.coffee +15 -0
  113. data/vendor/assets/javascripts/gmaps4rails/base/main.coffee +124 -0
  114. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/circle_controller.coffee +29 -0
  115. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/kml_controller.coffee +5 -0
  116. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/marker_controller.coffee +76 -0
  117. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/polygon_controller.coffee +29 -0
  118. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/polyline_controller.coffee +29 -0
  119. data/vendor/assets/javascripts/gmaps4rails/base/objects/circle.coffee +12 -0
  120. data/vendor/assets/javascripts/gmaps4rails/base/objects/kml.coffee +8 -0
  121. data/vendor/assets/javascripts/gmaps4rails/base/objects/map.coffee +62 -0
  122. data/vendor/assets/javascripts/gmaps4rails/base/objects/marker.coffee +24 -0
  123. data/vendor/assets/javascripts/gmaps4rails/base/objects/polygon.coffee +11 -0
  124. data/vendor/assets/javascripts/gmaps4rails/base/objects/polyline.coffee +11 -0
  125. data/vendor/assets/javascripts/gmaps4rails/bing.coffee +1 -0
  126. data/vendor/assets/javascripts/gmaps4rails/bing/main.coffee +29 -0
  127. data/vendor/assets/javascripts/gmaps4rails/bing/objects/map.coffee +63 -0
  128. data/vendor/assets/javascripts/gmaps4rails/bing/objects/marker.coffee +78 -0
  129. data/vendor/assets/javascripts/gmaps4rails/bing/shared.coffee +20 -0
  130. data/vendor/assets/javascripts/gmaps4rails/google.coffee +1 -0
  131. data/vendor/assets/javascripts/gmaps4rails/google/main.coffee +47 -0
  132. data/vendor/assets/javascripts/gmaps4rails/google/objects/circle.coffee +38 -0
  133. data/vendor/assets/javascripts/gmaps4rails/google/objects/kml.coffee +16 -0
  134. data/vendor/assets/javascripts/gmaps4rails/google/objects/map.coffee +71 -0
  135. data/vendor/assets/javascripts/gmaps4rails/google/objects/marker.coffee +114 -0
  136. data/vendor/assets/javascripts/gmaps4rails/google/objects/polygon.coffee +38 -0
  137. data/vendor/assets/javascripts/gmaps4rails/google/objects/polyline.coffee +49 -0
  138. data/vendor/assets/javascripts/gmaps4rails/google/shared.coffee +27 -0
  139. data/vendor/assets/javascripts/gmaps4rails/openlayers.coffee +1 -0
  140. data/vendor/assets/javascripts/gmaps4rails/openlayers/main.coffee +138 -0
  141. data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/map.coffee +49 -0
  142. data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/marker.coffee +68 -0
  143. data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/polyline.coffee +39 -0
  144. data/vendor/assets/javascripts/gmaps4rails/openlayers/shared.coffee +19 -0
  145. metadata +378 -14
  146. checksums.yaml +0 -7
@@ -0,0 +1,792 @@
1
+ (function() {
2
+ var moduleKeywords,
3
+ __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
4
+
5
+ moduleKeywords = ['extended', 'included'];
6
+
7
+ this.Gmaps4Rails = {};
8
+
9
+ this.Gmaps4Rails.Common = (function() {
10
+
11
+ function Common() {}
12
+
13
+ Common.extend = function(obj) {
14
+ var key, value, _ref;
15
+ for (key in obj) {
16
+ value = obj[key];
17
+ if (__indexOf.call(moduleKeywords, key) < 0) this[key] = value;
18
+ }
19
+ if ((_ref = obj.extended) != null) _ref.apply(this);
20
+ return this;
21
+ };
22
+
23
+ Common.include = function(obj) {
24
+ var key, value, _ref;
25
+ for (key in obj) {
26
+ value = obj[key];
27
+ if (__indexOf.call(moduleKeywords, key) < 0) this.prototype[key] = value;
28
+ }
29
+ if ((_ref = obj.included) != null) _ref.apply(this);
30
+ return this;
31
+ };
32
+
33
+ Common.prototype.exists = function(var_name) {
34
+ return var_name !== "" && typeof var_name !== "undefined";
35
+ };
36
+
37
+ Common.prototype.mergeObjects = function(object, defaultObject) {
38
+ return this.constructor.mergeObjects(object, defaultObject);
39
+ };
40
+
41
+ Common.mergeObjects = function(object, defaultObject) {
42
+ var copy_object, key, value;
43
+ copy_object = {};
44
+ for (key in object) {
45
+ value = object[key];
46
+ copy_object[key] = value;
47
+ }
48
+ for (key in defaultObject) {
49
+ value = defaultObject[key];
50
+ if (copy_object[key] == null) copy_object[key] = value;
51
+ }
52
+ return copy_object;
53
+ };
54
+
55
+ Common.mergeWith = function(object) {
56
+ var key, value, _results;
57
+ _results = [];
58
+ for (key in object) {
59
+ value = object[key];
60
+ if (this[key] == null) {
61
+ _results.push(this[key] = value);
62
+ } else {
63
+ _results.push(void 0);
64
+ }
65
+ }
66
+ return _results;
67
+ };
68
+
69
+ Common.prototype.random = function() {
70
+ return Math.random() * 2 - 1;
71
+ };
72
+
73
+ return Common;
74
+
75
+ })();
76
+
77
+ }).call(this);
78
+ (function() {
79
+
80
+ this.Gmaps4Rails.Configuration = {
81
+ setConf: function() {
82
+ if (this.CONF) {
83
+ return this.mergeObjects(this.CONF, this.DEFAULT_CONF);
84
+ } else {
85
+ return this.DEFAULT_CONF;
86
+ }
87
+ }
88
+ };
89
+
90
+ }).call(this);
91
+ (function() {
92
+
93
+ this.Gmaps = {
94
+ triggerOldOnload: function() {
95
+ if (typeof window.Gmaps.oldOnload === 'function') {
96
+ return window.Gmaps.oldOnload();
97
+ }
98
+ },
99
+ loadMaps: function() {
100
+ var key, value, _ref, _results;
101
+ _ref = window.Gmaps;
102
+ _results = [];
103
+ for (key in _ref) {
104
+ value = _ref[key];
105
+ if (/^load_/.test(key)) {
106
+ _results.push(window.Gmaps[key]());
107
+ } else {
108
+ _results.push(void 0);
109
+ }
110
+ }
111
+ return _results;
112
+ }
113
+ };
114
+
115
+ }).call(this);
116
+ (function() {
117
+
118
+ this.Gmaps4Rails.Circle = {};
119
+
120
+ this.Gmaps4Rails.Circle.Class = {
121
+ DEFAULT_CONF: {
122
+ fillColor: "#00AAFF",
123
+ fillOpacity: 0.35,
124
+ strokeColor: "#FFAA00",
125
+ strokeOpacity: 0.8,
126
+ strokeWeight: 2,
127
+ clickable: false,
128
+ zIndex: null
129
+ }
130
+ };
131
+
132
+ }).call(this);
133
+ (function() {
134
+
135
+ this.Gmaps4Rails.Kml = {};
136
+
137
+ this.Gmaps4Rails.Kml.Instance = {
138
+ DEFAULT_CONF: {
139
+ clickable: true,
140
+ preserveViewport: false,
141
+ suppressInfoWindows: false
142
+ }
143
+ };
144
+
145
+ }).call(this);
146
+ (function() {
147
+
148
+ this.Gmaps4Rails.Map = {
149
+ DEFAULT_CONF: {
150
+ id: 'map',
151
+ draggable: true,
152
+ detect_location: false,
153
+ center_on_user: false,
154
+ center_latitude: 0,
155
+ center_longitude: 0,
156
+ zoom: 7,
157
+ maxZoom: null,
158
+ minZoom: null,
159
+ auto_adjust: true,
160
+ auto_zoom: true,
161
+ bounds: [],
162
+ raw: {}
163
+ },
164
+ adjustToBounds: function() {
165
+ this.boundsObject = this.createLatLngBounds();
166
+ this.extendBoundsWithMarkers();
167
+ this.extendBoundsWithPolylines();
168
+ this.extendBoundsWithPolygons();
169
+ this.extendBoundsWithCircles();
170
+ this.extendBoundsWithLatLng();
171
+ return this.adaptToBounds();
172
+ },
173
+ extendBoundsWithMarkers: function() {
174
+ var marker, _i, _len, _ref, _results;
175
+ _ref = this.controller.markers;
176
+ _results = [];
177
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
178
+ marker = _ref[_i];
179
+ if (marker.isVisible()) {
180
+ _results.push(this.extendBoundsWithMarker(marker));
181
+ } else {
182
+ _results.push(void 0);
183
+ }
184
+ }
185
+ return _results;
186
+ },
187
+ extendBoundsWithPolylines: function() {
188
+ var polyline, _i, _len, _ref, _results;
189
+ _ref = this.controller.polylines;
190
+ _results = [];
191
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
192
+ polyline = _ref[_i];
193
+ _results.push(this.extendBoundsWithPolyline(polyline));
194
+ }
195
+ return _results;
196
+ },
197
+ extendBoundsWithPolygons: function() {
198
+ var polygon, _i, _len, _ref, _results;
199
+ _ref = this.controller.polygons;
200
+ _results = [];
201
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
202
+ polygon = _ref[_i];
203
+ _results.push(this.extendBoundsWithPolygon(polygon));
204
+ }
205
+ return _results;
206
+ },
207
+ extendBoundsWithCircles: function() {
208
+ var circle, _i, _len, _ref, _results;
209
+ _ref = this.controller.circles;
210
+ _results = [];
211
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
212
+ circle = _ref[_i];
213
+ _results.push(this.extendBoundsWithCircle(circle));
214
+ }
215
+ return _results;
216
+ },
217
+ extendBoundsWithLatLng: function() {
218
+ var bound, _i, _len, _ref, _results;
219
+ _ref = this.options.bounds;
220
+ _results = [];
221
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
222
+ bound = _ref[_i];
223
+ _results.push(this.extendBound(bound));
224
+ }
225
+ return _results;
226
+ },
227
+ autoAdjustRequested: function() {
228
+ return this.options.auto_adjust || this.options.bounds.length > 0;
229
+ }
230
+ };
231
+
232
+ }).call(this);
233
+ (function() {
234
+
235
+ this.Gmaps4Rails.Marker = {};
236
+
237
+ this.Gmaps4Rails.Marker.Class = {
238
+ DEFAULT_CONF: {
239
+ title: null,
240
+ picture: null,
241
+ width: 22,
242
+ length: 32,
243
+ draggable: false,
244
+ do_clustering: false,
245
+ randomize: false,
246
+ max_random_distance: 100,
247
+ list_container: null,
248
+ offset: 0,
249
+ raw: {}
250
+ }
251
+ };
252
+
253
+ this.Gmaps4Rails.Marker.Instance = {
254
+ getMap: function() {
255
+ return this.controller.getMapObject();
256
+ }
257
+ };
258
+
259
+ }).call(this);
260
+ (function() {
261
+
262
+ this.Gmaps4Rails.Polygon = {};
263
+
264
+ this.Gmaps4Rails.Polygon.Class = {
265
+ DEFAULT_CONF: {
266
+ strokeColor: "#FFAA00",
267
+ strokeOpacity: 0.8,
268
+ strokeWeight: 2,
269
+ fillColor: "#000000",
270
+ fillOpacity: 0.35,
271
+ clickable: false
272
+ }
273
+ };
274
+
275
+ }).call(this);
276
+ (function() {
277
+
278
+ this.Gmaps4Rails.Polyline = {};
279
+
280
+ this.Gmaps4Rails.Polyline.Class = {
281
+ DEFAULT_CONF: {
282
+ strokeColor: "#FF0000",
283
+ strokeOpacity: 1,
284
+ strokeWeight: 2,
285
+ clickable: false,
286
+ zIndex: null
287
+ }
288
+ };
289
+
290
+ }).call(this);
291
+ (function() {
292
+
293
+ this.Gmaps4Rails.CircleController = {
294
+ addCircles: function(circleData) {
295
+ var circleArgs, _i, _len, _results;
296
+ _results = [];
297
+ for (_i = 0, _len = circleData.length; _i < _len; _i++) {
298
+ circleArgs = circleData[_i];
299
+ _results.push(this.circles.push(this.createCircle(circleArgs)));
300
+ }
301
+ return _results;
302
+ },
303
+ replaceCircles: function(circleData) {
304
+ this.clearCircles();
305
+ this.addCircles(circleData);
306
+ return this.adjustMapToBounds();
307
+ },
308
+ clearCircles: function() {
309
+ var circle, _i, _len, _ref;
310
+ _ref = this.circles;
311
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
312
+ circle = _ref[_i];
313
+ circle.clear();
314
+ }
315
+ return this.circles = [];
316
+ },
317
+ showCircles: function() {
318
+ var circle, _i, _len, _ref, _results;
319
+ _ref = this.circles;
320
+ _results = [];
321
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
322
+ circle = _ref[_i];
323
+ _results.push(circle.show());
324
+ }
325
+ return _results;
326
+ },
327
+ hideCircles: function() {
328
+ var circle, _i, _len, _ref, _results;
329
+ _ref = this.circles;
330
+ _results = [];
331
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
332
+ circle = _ref[_i];
333
+ _results.push(circle.hide());
334
+ }
335
+ return _results;
336
+ }
337
+ };
338
+
339
+ }).call(this);
340
+ (function() {
341
+
342
+ this.Gmaps4Rails.KmlController = {
343
+ addKml: function(kmlData) {
344
+ var kml, _i, _len, _results;
345
+ _results = [];
346
+ for (_i = 0, _len = kmlData.length; _i < _len; _i++) {
347
+ kml = kmlData[_i];
348
+ _results.push(this.kmls.push(this.createKml(kml)));
349
+ }
350
+ return _results;
351
+ }
352
+ };
353
+
354
+ }).call(this);
355
+ (function() {
356
+
357
+ this.Gmaps4Rails.MarkerController = {
358
+ addMarkers: function(markersData) {
359
+ var index, lat, latLng, lng, markerData, newMarker, _len;
360
+ if (this.markerClusterer != null) this.clearClusterer();
361
+ for (index = 0, _len = markersData.length; index < _len; index++) {
362
+ markerData = markersData[index];
363
+ lat = markerData.lat;
364
+ lng = markerData.lng;
365
+ if (this.markers_conf.randomize) {
366
+ latLng = this.randomize(lat, lng);
367
+ lat = latLng[0];
368
+ lng = latLng[1];
369
+ }
370
+ newMarker = this.createMarker({
371
+ "marker_picture": markerData.picture ? markerData.picture : this.markers_conf.picture,
372
+ "marker_width": markerData.width ? markerData.width : this.markers_conf.width,
373
+ "marker_height": markerData.height ? markerData.height : this.markers_conf.length,
374
+ "marker_title": markerData.title ? markerData.title : null,
375
+ "marker_anchor": markerData.marker_anchor ? markerData.marker_anchor : null,
376
+ "shadow_anchor": markerData.shadow_anchor ? markerData.shadow_anchor : null,
377
+ "shadow_picture": markerData.shadow_picture ? markerData.shadow_picture : null,
378
+ "shadow_width": markerData.shadow_width ? markerData.shadow_width : null,
379
+ "shadow_height": markerData.shadow_height ? markerData.shadow_height : null,
380
+ "marker_draggable": markerData.draggable ? markerData.draggable : this.markers_conf.draggable,
381
+ "rich_marker": markerData.rich_marker ? markerData.rich_marker : null,
382
+ "zindex": markerData.zindex ? markerData.zindex : null,
383
+ "lat": lat,
384
+ "lng": lng,
385
+ "index": index
386
+ });
387
+ Gmaps4Rails.Common.mergeWith.call(newMarker, markerData);
388
+ newMarker.createInfoWindow();
389
+ this.markers.push(newMarker);
390
+ }
391
+ return this.clusterize();
392
+ },
393
+ replaceMarkers: function(new_markers) {
394
+ this.clearMarkers();
395
+ this.markers = [];
396
+ this.boundsObject = this.createLatLngBounds();
397
+ return this.addMarkers(new_markers);
398
+ },
399
+ clearMarkers: function() {
400
+ var marker, _i, _len, _ref;
401
+ if (this.markerClusterer != null) this.clearClusterer();
402
+ _ref = this.markers;
403
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
404
+ marker = _ref[_i];
405
+ marker.clear();
406
+ }
407
+ return this.markers = [];
408
+ },
409
+ showMarkers: function() {
410
+ var marker, _i, _len, _ref, _results;
411
+ _ref = this.markers;
412
+ _results = [];
413
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
414
+ marker = _ref[_i];
415
+ _results.push(marker.show());
416
+ }
417
+ return _results;
418
+ },
419
+ hideMarkers: function() {
420
+ var marker, _i, _len, _ref, _results;
421
+ _ref = this.markers;
422
+ _results = [];
423
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
424
+ marker = _ref[_i];
425
+ _results.push(marker.hide());
426
+ }
427
+ return _results;
428
+ },
429
+ randomize: function(Lat0, Lng0) {
430
+ var Lat, Lng, dx, dy;
431
+ dx = this.markers_conf.max_random_distance * this.random();
432
+ dy = this.markers_conf.max_random_distance * this.random();
433
+ Lat = parseFloat(Lat0) + (180 / Math.PI) * (dy / 6378137);
434
+ Lng = parseFloat(Lng0) + (90 / Math.PI) * (dx / 6378137) / Math.cos(Lat0);
435
+ return [Lat, Lng];
436
+ }
437
+ };
438
+
439
+ }).call(this);
440
+ (function() {
441
+
442
+ this.Gmaps4Rails.PolygonController = {
443
+ addPolygons: function(polygonData) {
444
+ var polygonArgs, _i, _len, _results;
445
+ _results = [];
446
+ for (_i = 0, _len = polygonData.length; _i < _len; _i++) {
447
+ polygonArgs = polygonData[_i];
448
+ _results.push(this.polygons.push(this.createPolygon(polygonArgs)));
449
+ }
450
+ return _results;
451
+ },
452
+ replacePolygons: function(polylineData) {
453
+ this.clearPolygons();
454
+ this.addPolygons(polylineData);
455
+ return this.adjustMapToBounds();
456
+ },
457
+ clearPolygons: function() {
458
+ var polygon, _i, _len, _ref;
459
+ _ref = this.polygons;
460
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
461
+ polygon = _ref[_i];
462
+ polygon.clear();
463
+ }
464
+ return this.polygons = [];
465
+ },
466
+ showPolygons: function() {
467
+ var polygon, _i, _len, _ref, _results;
468
+ _ref = this.polygons;
469
+ _results = [];
470
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
471
+ polygon = _ref[_i];
472
+ _results.push(polygon.show());
473
+ }
474
+ return _results;
475
+ },
476
+ hidePolygons: function() {
477
+ var polygon, _i, _len, _ref, _results;
478
+ _ref = this.polygons;
479
+ _results = [];
480
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
481
+ polygon = _ref[_i];
482
+ _results.push(polygon.hide());
483
+ }
484
+ return _results;
485
+ }
486
+ };
487
+
488
+ }).call(this);
489
+ (function() {
490
+
491
+ this.Gmaps4Rails.PolylineController = {
492
+ replacePolylines: function(polylineData) {
493
+ this.clearPolylines();
494
+ this.addPolylines(polylineData);
495
+ return this.adjustMapToBounds();
496
+ },
497
+ clearPolylines: function() {
498
+ var polyline, _i, _len, _ref;
499
+ _ref = this.polylines;
500
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
501
+ polyline = _ref[_i];
502
+ polyline.clear();
503
+ }
504
+ return this.polylines = [];
505
+ },
506
+ addPolylines: function(polylineData) {
507
+ var polylineArgs, _i, _len, _results;
508
+ _results = [];
509
+ for (_i = 0, _len = polylineData.length; _i < _len; _i++) {
510
+ polylineArgs = polylineData[_i];
511
+ _results.push(this.polylines.push(this.createPolyline(polylineArgs)));
512
+ }
513
+ return _results;
514
+ },
515
+ showPolylines: function() {
516
+ var polyline, _i, _len, _ref, _results;
517
+ _ref = this.polylines;
518
+ _results = [];
519
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
520
+ polyline = _ref[_i];
521
+ _results.push(polyline.show());
522
+ }
523
+ return _results;
524
+ },
525
+ hidePolylines: function() {
526
+ var polyline, _i, _len, _ref, _results;
527
+ _ref = this.polylines;
528
+ _results = [];
529
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
530
+ polyline = _ref[_i];
531
+ _results.push(polyline.hide());
532
+ }
533
+ return _results;
534
+ }
535
+ };
536
+
537
+ }).call(this);
538
+ (function() {
539
+
540
+ Gmaps4Rails.Interfaces || (Gmaps4Rails.Interfaces = {});
541
+
542
+ Gmaps4Rails.Interfaces.Basic = {
543
+ clear: function() {
544
+ throw "clear should be implemented";
545
+ },
546
+ show: function() {
547
+ throw "show should be implemented";
548
+ },
549
+ hide: function() {
550
+ throw "hide should be implemented";
551
+ },
552
+ isVisible: function() {
553
+ throw "hide should be implemented";
554
+ }
555
+ };
556
+
557
+ }).call(this);
558
+ (function() {
559
+
560
+ Gmaps4Rails.Interfaces || (Gmaps4Rails.Interfaces = {});
561
+
562
+ Gmaps4Rails.Interfaces.Controller = {
563
+ getModule: function() {
564
+ throw "getModule should be implemented in controller";
565
+ },
566
+ createClusterer: function(markers_array) {
567
+ throw "createClusterer should be implemented in controller";
568
+ },
569
+ clearClusterer: function() {
570
+ throw "clearClusterer should be implemented in controller";
571
+ }
572
+ };
573
+
574
+ }).call(this);
575
+ (function() {
576
+
577
+ Gmaps4Rails.Interfaces || (Gmaps4Rails.Interfaces = {});
578
+
579
+ Gmaps4Rails.Interfaces.Map = {
580
+ extendBoundsWithMarker: function(marker) {
581
+ throw "extendBoundsWithMarker should be implemented in controller";
582
+ },
583
+ extendBoundsWithPolyline: function(polyline) {
584
+ throw "extendBoundsWithPolyline should be implemented in controller";
585
+ },
586
+ extendBoundsWithPolygon: function(polygon) {
587
+ throw "extendBoundsWithPolygon should be implemented in controller";
588
+ },
589
+ extendBoundsWithCircle: function(circle) {
590
+ throw "extendBoundsWithCircle should be implemented in controller";
591
+ },
592
+ extendBound: function(bound) {
593
+ throw "extendBound should be implemented in controller";
594
+ },
595
+ adaptToBounds: function() {
596
+ throw "adaptToBounds should be implemented in controller";
597
+ },
598
+ fitBounds: function() {
599
+ throw "fitBounds should be implemented in controller";
600
+ },
601
+ centerMapOnUser: function(position) {
602
+ throw "centerMapOnUser should be implemented in controller";
603
+ }
604
+ };
605
+
606
+ }).call(this);
607
+ (function() {
608
+
609
+ Gmaps4Rails.Interfaces || (Gmaps4Rails.Interfaces = {});
610
+
611
+ Gmaps4Rails.Interfaces.Marker = {
612
+ createInfoWindow: function() {
613
+ throw "createInfoWindow should be implemented in marker";
614
+ },
615
+ clear: function() {
616
+ throw "clear should be implemented in marker";
617
+ },
618
+ show: function() {
619
+ throw "show should be implemented in marker";
620
+ },
621
+ hide: function() {
622
+ throw "hide should be implemented in marker";
623
+ }
624
+ };
625
+
626
+ }).call(this);
627
+ (function() {
628
+ var __hasProp = Object.prototype.hasOwnProperty,
629
+ __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; };
630
+
631
+ this.Gmaps4Rails.BaseController = (function(_super) {
632
+
633
+ __extends(BaseController, _super);
634
+
635
+ BaseController.include(Gmaps4Rails.MarkerController);
636
+
637
+ BaseController.include(Gmaps4Rails.PolylineController);
638
+
639
+ BaseController.include(Gmaps4Rails.PolygonController);
640
+
641
+ BaseController.include(Gmaps4Rails.CircleController);
642
+
643
+ BaseController.include(Gmaps4Rails.KmlController);
644
+
645
+ BaseController.include(Gmaps4Rails.Interfaces.Controller);
646
+
647
+ BaseController.prototype.visibleInfoWindow = null;
648
+
649
+ BaseController.prototype.userLocation = null;
650
+
651
+ BaseController.prototype.afterMapInitialization = function() {
652
+ return false;
653
+ };
654
+
655
+ BaseController.prototype.geolocationSuccess = function() {
656
+ return false;
657
+ };
658
+
659
+ BaseController.prototype.geolocationFailure = function() {
660
+ return false;
661
+ };
662
+
663
+ BaseController.prototype.callback = function() {
664
+ return false;
665
+ };
666
+
667
+ BaseController.prototype.customClusterer = function() {
668
+ return false;
669
+ };
670
+
671
+ BaseController.prototype.infobox = function() {
672
+ return false;
673
+ };
674
+
675
+ BaseController.prototype.jsTemplate = false;
676
+
677
+ BaseController.prototype.map_options = {};
678
+
679
+ BaseController.prototype.markers = [];
680
+
681
+ BaseController.prototype.boundsObject = null;
682
+
683
+ BaseController.prototype.polygons = [];
684
+
685
+ BaseController.prototype.polylines = [];
686
+
687
+ BaseController.prototype.circles = [];
688
+
689
+ BaseController.prototype.markerClusterer = null;
690
+
691
+ BaseController.prototype.markerImages = [];
692
+
693
+ BaseController.prototype.kmls = [];
694
+
695
+ BaseController.prototype.rootModule = null;
696
+
697
+ function BaseController() {
698
+ this.rootModule = this.getModule();
699
+ if (this.rootModule.Marker != null) {
700
+ this.markers_conf = this.rootModule.Marker.setConf();
701
+ }
702
+ if (this.rootModule.Polyline != null) {
703
+ this.polylines_conf = this.rootModule.Polyline.setConf();
704
+ }
705
+ if (this.rootModule.Polygon != null) {
706
+ this.polygons_conf = this.rootModule.Polygon.setConf();
707
+ }
708
+ if (this.rootModule.Circle != null) {
709
+ this.circles_conf = this.rootModule.Circle.setConf();
710
+ }
711
+ }
712
+
713
+ BaseController.prototype.createMap = function() {
714
+ return new this.rootModule.Map(this.map_options, this);
715
+ };
716
+
717
+ BaseController.prototype.createMarker = function(args) {
718
+ return new this.rootModule.Marker(args, this);
719
+ };
720
+
721
+ BaseController.prototype.createPolyline = function(args) {
722
+ return new this.rootModule.Polyline(args, this);
723
+ };
724
+
725
+ BaseController.prototype.createPolygon = function(args) {
726
+ return new this.rootModule.Polygon(args, this);
727
+ };
728
+
729
+ BaseController.prototype.createCircle = function(args) {
730
+ return new this.rootModule.Circle(args, this);
731
+ };
732
+
733
+ BaseController.prototype.createKml = function(args) {
734
+ return new this.rootModule.Kml(args, this);
735
+ };
736
+
737
+ BaseController.prototype.initialize = function() {
738
+ var center_on_user, detectUserLocation;
739
+ detectUserLocation = this.map_options.detect_location || this.map_options.center_on_user;
740
+ center_on_user = this.map_options.center_on_user;
741
+ this.map = this.createMap();
742
+ this.afterMapInitialization();
743
+ delete this.map_options;
744
+ if (detectUserLocation) return this.findUserLocation(this, center_on_user);
745
+ };
746
+
747
+ BaseController.prototype.getMapObject = function() {
748
+ return this.map.serviceObject;
749
+ };
750
+
751
+ BaseController.prototype.adjustMapToBounds = function() {
752
+ if (this.map.autoAdjustRequested()) return this.map.adjustToBounds();
753
+ };
754
+
755
+ BaseController.prototype.clusterize = function() {
756
+ var marker, markers_array, _i, _len, _ref;
757
+ if (this.markers_conf.do_clustering) {
758
+ if (this.markerClusterer != null) this.clearClusterer();
759
+ markers_array = [];
760
+ _ref = this.markers;
761
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
762
+ marker = _ref[_i];
763
+ markers_array.push(marker.serviceObject);
764
+ }
765
+ return this.markerClusterer = this.createClusterer(markers_array);
766
+ }
767
+ };
768
+
769
+ BaseController.prototype.findUserLocation = function(controller, center_on_user) {
770
+ var positionFailure, positionSuccessful;
771
+ if (navigator.geolocation) {
772
+ positionSuccessful = function(position) {
773
+ controller.userLocation = controller.createLatLng(position.coords.latitude, position.coords.longitude);
774
+ controller.geolocationSuccess();
775
+ if (center_on_user) {
776
+ return controller.map.centerMapOnUser(controller.userLocation);
777
+ }
778
+ };
779
+ positionFailure = function(error) {
780
+ return controller.geolocationFailure(true);
781
+ };
782
+ return navigator.geolocation.getCurrentPosition(positionSuccessful, positionFailure);
783
+ } else {
784
+ return controller.geolocationFailure(false);
785
+ }
786
+ };
787
+
788
+ return BaseController;
789
+
790
+ })(Gmaps4Rails.Common);
791
+
792
+ }).call(this);