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,556 @@
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);