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,792 +0,0 @@
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);