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,377 @@
1
+ (function() {
2
+
3
+ Gmaps4Rails.Openlayers = {};
4
+
5
+ Gmaps4Rails.Openlayers.Shared = {
6
+ createPoint: function(lat, lng) {
7
+ return new OpenLayers.Geometry.Point(lng, lat);
8
+ },
9
+ createLatLng: function(lat, lng) {
10
+ return new OpenLayers.LonLat(lng, lat).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
11
+ },
12
+ createAnchor: function(offset) {
13
+ if (offset === null) return null;
14
+ return new OpenLayers.Pixel(offset[0], offset[1]);
15
+ },
16
+ createSize: function(width, height) {
17
+ return new OpenLayers.Size(width, height);
18
+ },
19
+ createLatLngBounds: function() {
20
+ return new OpenLayers.Bounds();
21
+ }
22
+ };
23
+
24
+ }).call(this);
25
+ (function() {
26
+ var __hasProp = Object.prototype.hasOwnProperty,
27
+ __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; };
28
+
29
+ this.Gmaps4Rails.Openlayers.Map = (function(_super) {
30
+
31
+ __extends(Map, _super);
32
+
33
+ Map.include(Gmaps4Rails.Interfaces.Map);
34
+
35
+ Map.include(Gmaps4Rails.Map);
36
+
37
+ Map.include(Gmaps4Rails.Openlayers.Shared);
38
+
39
+ Map.include(Gmaps4Rails.Configuration);
40
+
41
+ Map.prototype.CONF = {
42
+ disableDefaultUI: false,
43
+ disableDoubleClickZoom: false,
44
+ type: "ROADMAP",
45
+ mapTypeControl: null
46
+ };
47
+
48
+ function Map(map_options, controller) {
49
+ var defaultOptions, mergedOpenlayersOptions, openlayersOptions;
50
+ this.controller = controller;
51
+ defaultOptions = this.setConf();
52
+ this.options = this.mergeObjects(map_options, defaultOptions);
53
+ openlayersOptions = {
54
+ center: this.createLatLng(this.options.center_latitude, this.options.center_longitude),
55
+ zoom: this.options.zoom
56
+ };
57
+ mergedOpenlayersOptions = this.mergeObjects(map_options.raw, openlayersOptions);
58
+ this.serviceObject = new OpenLayers.Map(this.options.id, mergedOpenlayersOptions);
59
+ this.serviceObject.addLayer(new OpenLayers.Layer.OSM());
60
+ }
61
+
62
+ Map.prototype.extendBoundsWithMarker = function(marker) {
63
+ return this.boundsObject.extend(this.createLatLng(marker.lat, marker.lng));
64
+ };
65
+
66
+ Map.prototype.extendBoundsWithPolyline = function(polyline) {};
67
+
68
+ Map.prototype.extendBoundsWithPolygon = function(polygon) {};
69
+
70
+ Map.prototype.extendBoundsWithCircle = function(circle) {};
71
+
72
+ Map.prototype.extendBound = function(bound) {};
73
+
74
+ Map.prototype.fitBounds = function() {
75
+ return this.serviceObject.zoomToExtent(this.boundsObject, true);
76
+ };
77
+
78
+ Map.prototype.adaptToBounds = function() {
79
+ return this.fitBounds();
80
+ };
81
+
82
+ Map.prototype.centerMapOnUser = function(position) {
83
+ return this.serviceObject.setCenter(position);
84
+ };
85
+
86
+ return Map;
87
+
88
+ })(Gmaps4Rails.Common);
89
+
90
+ }).call(this);
91
+ (function() {
92
+ var __hasProp = Object.prototype.hasOwnProperty,
93
+ __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; };
94
+
95
+ this.Gmaps4Rails.Openlayers.Marker = (function(_super) {
96
+
97
+ __extends(Marker, _super);
98
+
99
+ Marker.include(Gmaps4Rails.Interfaces.Marker);
100
+
101
+ Marker.include(Gmaps4Rails.Openlayers.Shared);
102
+
103
+ Marker.include(Gmaps4Rails.Marker.Instance);
104
+
105
+ Marker.extend(Gmaps4Rails.Marker.Class);
106
+
107
+ Marker.extend(Gmaps4Rails.Configuration);
108
+
109
+ function Marker(args, controller) {
110
+ this.controller = controller;
111
+ this.controller._createMarkersLayer();
112
+ this._createMarkerStyle(args);
113
+ if (this._isBasicMarker(args)) {
114
+ this._styleForBasicMarker(args);
115
+ } else {
116
+ this._styleForCustomMarker(args);
117
+ }
118
+ this.serviceObject = new OpenLayers.Feature.Vector(this.createPoint(args.lat, args.lng), null, this.style_mark);
119
+ this.serviceObject.geometry.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
120
+ this.controller.markersLayer.addFeatures([this.serviceObject]);
121
+ }
122
+
123
+ Marker.prototype.createInfoWindow = function() {
124
+ if (this.description != null) {
125
+ return this.serviceObject.infoWindow = this.description;
126
+ }
127
+ };
128
+
129
+ Marker.prototype.isVisible = function() {
130
+ return true;
131
+ };
132
+
133
+ Marker.prototype._isBasicMarker = function(args) {
134
+ return !(args.marker_picture != null);
135
+ };
136
+
137
+ Marker.prototype._createMarkerStyle = function(args) {
138
+ this.style_mark = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
139
+ this.style_mark.fillOpacity = 1;
140
+ return this.style_mark.graphicTitle = args.title;
141
+ };
142
+
143
+ Marker.prototype._styleForBasicMarker = function(args) {
144
+ this.style_mark.graphicHeight = 30;
145
+ return this.style_mark.externalGraphic = "http://openlayers.org/dev/img/marker-blue.png";
146
+ };
147
+
148
+ Marker.prototype._styleForCustomMarker = function(args) {
149
+ this.style_mark.graphicWidth = args.marker_width;
150
+ this.style_mark.graphicHeight = args.marker_height;
151
+ this.style_mark.externalGraphic = args.marker_picture;
152
+ if (args.marker_anchor != null) {
153
+ this.style_mark.graphicXOffset = args.marker_anchor[0];
154
+ this.style_mark.graphicYOffset = args.marker_anchor[1];
155
+ }
156
+ if (args.shadow_picture != null) {
157
+ this.style_mark.backgroundGraphic = args.shadow_picture;
158
+ this.style_mark.backgroundWidth = args.shadow_width;
159
+ this.style_mark.backgroundHeight = args.shadow_height;
160
+ if (args.shadow_anchor != null) {
161
+ this.style_mark.backgroundXOffset = args.shadow_anchor[0];
162
+ return this.style_mark.backgroundYOffset = args.shadow_anchor[1];
163
+ }
164
+ }
165
+ };
166
+
167
+ return Marker;
168
+
169
+ })(Gmaps4Rails.Common);
170
+
171
+ }).call(this);
172
+ (function() {
173
+ var __hasProp = Object.prototype.hasOwnProperty,
174
+ __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; };
175
+
176
+ this.Gmaps4Rails.Openlayers.Polyline = (function(_super) {
177
+
178
+ __extends(Polyline, _super);
179
+
180
+ Polyline.include(Gmaps4Rails.Openlayers.Shared);
181
+
182
+ Polyline.extend(Gmaps4Rails.Polyline.Class);
183
+
184
+ Polyline.extend(Gmaps4Rails.Configuration);
185
+
186
+ function Polyline(polyline, controller) {
187
+ var clickable, element, latlng, line_points, line_style, polyline_coordinates, strokeColor, strokeOpacity, strokeWeight, zIndex, _i, _len;
188
+ this.controller = controller;
189
+ this.controller._createPolylinesLayer();
190
+ polyline_coordinates = [];
191
+ for (_i = 0, _len = polyline.length; _i < _len; _i++) {
192
+ element = polyline[_i];
193
+ if (element === polyline[0]) {
194
+ strokeColor = element.strokeColor || this.controller.polylines_conf.strokeColor;
195
+ strokeOpacity = element.strokeOpacity || this.controller.polylines_conf.strokeOpacity;
196
+ strokeWeight = element.strokeWeight || this.controller.polylines_conf.strokeWeight;
197
+ clickable = element.clickable || this.controller.polylines_conf.clickable;
198
+ zIndex = element.zIndex || this.controller.polylines_conf.zIndex;
199
+ }
200
+ if ((element.lat != null) && (element.lng != null)) {
201
+ latlng = new OpenLayers.Geometry.Point(element.lng, element.lat);
202
+ polyline_coordinates.push(latlng);
203
+ }
204
+ }
205
+ line_points = new OpenLayers.Geometry.LineString(polyline_coordinates);
206
+ line_style = {
207
+ strokeColor: strokeColor,
208
+ strokeOpacity: strokeOpacity,
209
+ strokeWidth: strokeWeight
210
+ };
211
+ this.serviceObject = new OpenLayers.Feature.Vector(line_points, null, line_style);
212
+ this.serviceObject.geometry.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
213
+ this.controller.polylinesLayer.addFeatures([this.serviceObject]);
214
+ }
215
+
216
+ Polyline.prototype.isVisible = function() {
217
+ return true;
218
+ };
219
+
220
+ return Polyline;
221
+
222
+ })(Gmaps4Rails.Common);
223
+
224
+ }).call(this);
225
+ (function() {
226
+ var __hasProp = Object.prototype.hasOwnProperty,
227
+ __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; };
228
+
229
+ this.Gmaps4RailsOpenlayers = (function(_super) {
230
+
231
+ __extends(Gmaps4RailsOpenlayers, _super);
232
+
233
+ Gmaps4RailsOpenlayers.include(Gmaps4Rails.Openlayers.Shared);
234
+
235
+ function Gmaps4RailsOpenlayers() {
236
+ Gmaps4RailsOpenlayers.__super__.constructor.apply(this, arguments);
237
+ this.markersControl = null;
238
+ this.markersLayer = null;
239
+ this.polylinesLayer = null;
240
+ }
241
+
242
+ Gmaps4RailsOpenlayers.prototype.getModule = function() {
243
+ return Gmaps4Rails.Openlayers;
244
+ };
245
+
246
+ Gmaps4RailsOpenlayers.prototype.createClusterer = function(marker_serviceObject_array) {
247
+ var strategy, style;
248
+ style = new OpenLayers.Style(this._clustererOptions, this._clustererFunctions);
249
+ strategy = new OpenLayers.Strategy.Cluster;
250
+ this._clearMarkersLayer();
251
+ this.clusterLayer = new OpenLayers.Layer.Vector("Clusters", {
252
+ strategies: [strategy],
253
+ styleMap: new OpenLayers.StyleMap({
254
+ "default": style,
255
+ "select": {
256
+ fillColor: "#8aeeef",
257
+ strokeColor: "#32a8a9"
258
+ }
259
+ })
260
+ });
261
+ this.getMapObject().addLayer(this.clusterLayer);
262
+ this.clusterLayer.addFeatures(marker_serviceObject_array);
263
+ return this.clusterLayer;
264
+ };
265
+
266
+ Gmaps4RailsOpenlayers.prototype.clearClusterer = function() {
267
+ if ((this.clusterLayer != null) && (this.getMapObject().getLayer(this.clusterLayer.id) != null)) {
268
+ this.getMapObject().removeLayer(this.markerClusterer);
269
+ }
270
+ return this.clusterLayer = null;
271
+ };
272
+
273
+ Gmaps4RailsOpenlayers.prototype.clearMarkers = function() {
274
+ this._clearMarkersLayer();
275
+ this.clearClusterer();
276
+ return this.markers = [];
277
+ };
278
+
279
+ Gmaps4RailsOpenlayers.prototype._createPolylinesLayer = function() {
280
+ if (this.polylinesLayer != null) return;
281
+ this.polylinesLayer = new OpenLayers.Layer.Vector("Polylines", null);
282
+ this.polylinesLayer.events.register("featureselected", this.polylinesLayer, this._onFeatureSelect);
283
+ this.polylinesLayer.events.register("featureunselected", this.polylinesLayer, this._onFeatureUnselect);
284
+ this.polylinesControl = new OpenLayers.Control.DrawFeature(this.polylinesLayer, OpenLayers.Handler.Path);
285
+ this.getMapObject().addLayer(this.polylinesLayer);
286
+ return this.getMapObject().addControl(this.polylinesControl);
287
+ };
288
+
289
+ Gmaps4RailsOpenlayers.prototype._createMarkersLayer = function() {
290
+ if (this.markersLayer != null) return;
291
+ this.markersLayer = new OpenLayers.Layer.Vector("Markers", null);
292
+ this.getMapObject().addLayer(this.markersLayer);
293
+ this.markersLayer.events.register("featureselected", this.markersLayer, this._onFeatureSelect());
294
+ this.markersLayer.events.register("featureunselected", this.markersLayer, this._onFeatureUnselect());
295
+ this.markersControl = new OpenLayers.Control.SelectFeature(this.markersLayer);
296
+ this.getMapObject().addControl(this.markersControl);
297
+ return this.markersControl.activate();
298
+ };
299
+
300
+ Gmaps4RailsOpenlayers.prototype._clearMarkersLayer = function() {
301
+ if ((this.markersLayer != null) && (this.getMapObject().getLayer(this.markersLayer.id) != null)) {
302
+ this.getMapObject().removeLayer(this.markersLayer);
303
+ }
304
+ return this.markersLayer = null;
305
+ };
306
+
307
+ Gmaps4RailsOpenlayers.prototype._onFeatureSelect = function() {
308
+ var controller;
309
+ controller = this;
310
+ return function(evt) {
311
+ var feature, popup;
312
+ feature = evt.feature;
313
+ popup = new OpenLayers.Popup.FramedCloud("featurePopup", feature.geometry.getBounds().getCenterLonLat(), new OpenLayers.Size(300, 200), feature.infoWindow, null, true, controller._onPopupClose(controller, feature));
314
+ feature.popup = popup;
315
+ popup.feature = feature;
316
+ return controller.getMapObject().addPopup(popup);
317
+ };
318
+ };
319
+
320
+ Gmaps4RailsOpenlayers.prototype._onFeatureUnselect = function() {
321
+ var controller;
322
+ controller = this;
323
+ return function(evt) {
324
+ var feature;
325
+ feature = evt.feature;
326
+ if (feature.popup != null) {
327
+ controller.getMapObject().removePopup(feature.popup);
328
+ feature.popup.destroy();
329
+ return feature.popup = null;
330
+ }
331
+ };
332
+ };
333
+
334
+ Gmaps4RailsOpenlayers.prototype._onPopupClose = function(controller, feature) {
335
+ return function() {
336
+ return controller.markersControl.unselect(feature);
337
+ };
338
+ };
339
+
340
+ Gmaps4RailsOpenlayers.prototype._clustererFunctions = {
341
+ context: {
342
+ width: function(feature) {
343
+ var _ref;
344
+ return (_ref = feature.cluster) != null ? _ref : {
345
+ 2: 1
346
+ };
347
+ },
348
+ radius: function(feature) {
349
+ var pix;
350
+ pix = 2;
351
+ if (feature.cluster) pix = feature.cluster.length + 10;
352
+ return pix;
353
+ },
354
+ label: function(feature) {
355
+ if (feature.cluster) {
356
+ return feature.cluster.length;
357
+ } else {
358
+ return "";
359
+ }
360
+ }
361
+ }
362
+ };
363
+
364
+ Gmaps4RailsOpenlayers.prototype._clustererOptions = {
365
+ pointRadius: "${radius}",
366
+ fillColor: "#ffcc66",
367
+ fillOpacity: 0.8,
368
+ strokeColor: "#cc6633",
369
+ strokeWidth: "${width}",
370
+ label: "${label}"
371
+ };
372
+
373
+ return Gmaps4RailsOpenlayers;
374
+
375
+ })(Gmaps4Rails.BaseController);
376
+
377
+ }).call(this);
@@ -0,0 +1,24 @@
1
+ .map_container {
2
+ padding: 6px;
3
+ border-width: 1px;
4
+ border-style: solid;
5
+ border-color: #ccc #ccc #999 #ccc;
6
+ -webkit-box-shadow: rgba(64, 64, 64, 0.5) 0 2px 5px;
7
+ -moz-box-shadow: rgba(64, 64, 64, 0.5) 0 2px 5px;
8
+ box-shadow: rgba(64, 64, 64, 0.1) 0 2px 5px;
9
+ width: 800px;
10
+ }
11
+
12
+ .gmaps4rails_map {
13
+ width: 800px;
14
+ height: 400px;
15
+ }
16
+
17
+ .bing_map {
18
+ position: absolute;
19
+ top: 20;
20
+ left: 10;
21
+ width: 400px;
22
+ height: 400px;
23
+ border:#555555 2px solid;
24
+ }
@@ -0,0 +1,3 @@
1
+ tmp
2
+ db/*.sqlite3
3
+ config/initializers/api_keys.rb
data/spec/dummy/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,261 @@
1
+ == Welcome to Rails
2
+
3
+ Rails is a web-application framework that includes everything needed to create
4
+ database-backed web applications according to the Model-View-Control pattern.
5
+
6
+ This pattern splits the view (also called the presentation) into "dumb"
7
+ templates that are primarily responsible for inserting pre-built data in between
8
+ HTML tags. The model contains the "smart" domain objects (such as Account,
9
+ Product, Person, Post) that holds all the business logic and knows how to
10
+ persist themselves to a database. The controller handles the incoming requests
11
+ (such as Save New Account, Update Product, Show Post) by manipulating the model
12
+ and directing data to the view.
13
+
14
+ In Rails, the model is handled by what's called an object-relational mapping
15
+ layer entitled Active Record. This layer allows you to present the data from
16
+ database rows as objects and embellish these data objects with business logic
17
+ methods. You can read more about Active Record in
18
+ link:files/vendor/rails/activerecord/README.html.
19
+
20
+ The controller and view are handled by the Action Pack, which handles both
21
+ layers by its two parts: Action View and Action Controller. These two layers
22
+ are bundled in a single package due to their heavy interdependence. This is
23
+ unlike the relationship between the Active Record and Action Pack that is much
24
+ more separate. Each of these packages can be used independently outside of
25
+ Rails. You can read more about Action Pack in
26
+ link:files/vendor/rails/actionpack/README.html.
27
+
28
+
29
+ == Getting Started
30
+
31
+ 1. At the command prompt, create a new Rails application:
32
+ <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
33
+
34
+ 2. Change directory to <tt>myapp</tt> and start the web server:
35
+ <tt>cd myapp; rails server</tt> (run with --help for options)
36
+
37
+ 3. Go to http://localhost:3000/ and you'll see:
38
+ "Welcome aboard: You're riding Ruby on Rails!"
39
+
40
+ 4. Follow the guidelines to start developing your application. You can find
41
+ the following resources handy:
42
+
43
+ * The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
44
+ * Ruby on Rails Tutorial Book: http://www.railstutorial.org/
45
+
46
+
47
+ == Debugging Rails
48
+
49
+ Sometimes your application goes wrong. Fortunately there are a lot of tools that
50
+ will help you debug it and get it back on the rails.
51
+
52
+ First area to check is the application log files. Have "tail -f" commands
53
+ running on the server.log and development.log. Rails will automatically display
54
+ debugging and runtime information to these files. Debugging info will also be
55
+ shown in the browser on requests from 127.0.0.1.
56
+
57
+ You can also log your own messages directly into the log file from your code
58
+ using the Ruby logger class from inside your controllers. Example:
59
+
60
+ class WeblogController < ActionController::Base
61
+ def destroy
62
+ @weblog = Weblog.find(params[:id])
63
+ @weblog.destroy
64
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
65
+ end
66
+ end
67
+
68
+ The result will be a message in your log file along the lines of:
69
+
70
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
71
+
72
+ More information on how to use the logger is at http://www.ruby-doc.org/core/
73
+
74
+ Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
75
+ several books available online as well:
76
+
77
+ * Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
78
+ * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
79
+
80
+ These two books will bring you up to speed on the Ruby language and also on
81
+ programming in general.
82
+
83
+
84
+ == Debugger
85
+
86
+ Debugger support is available through the debugger command when you start your
87
+ Mongrel or WEBrick server with --debugger. This means that you can break out of
88
+ execution at any point in the code, investigate and change the model, and then,
89
+ resume execution! You need to install ruby-debug to run the server in debugging
90
+ mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
91
+
92
+ class WeblogController < ActionController::Base
93
+ def index
94
+ @posts = Post.all
95
+ debugger
96
+ end
97
+ end
98
+
99
+ So the controller will accept the action, run the first line, then present you
100
+ with a IRB prompt in the server window. Here you can do things like:
101
+
102
+ >> @posts.inspect
103
+ => "[#<Post:0x14a6be8
104
+ @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
105
+ #<Post:0x14a6620
106
+ @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
107
+ >> @posts.first.title = "hello from a debugger"
108
+ => "hello from a debugger"
109
+
110
+ ...and even better, you can examine how your runtime objects actually work:
111
+
112
+ >> f = @posts.first
113
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
114
+ >> f.
115
+ Display all 152 possibilities? (y or n)
116
+
117
+ Finally, when you're ready to resume execution, you can enter "cont".
118
+
119
+
120
+ == Console
121
+
122
+ The console is a Ruby shell, which allows you to interact with your
123
+ application's domain model. Here you'll have all parts of the application
124
+ configured, just like it is when the application is running. You can inspect
125
+ domain models, change values, and save to the database. Starting the script
126
+ without arguments will launch it in the development environment.
127
+
128
+ To start the console, run <tt>rails console</tt> from the application
129
+ directory.
130
+
131
+ Options:
132
+
133
+ * Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
134
+ made to the database.
135
+ * Passing an environment name as an argument will load the corresponding
136
+ environment. Example: <tt>rails console production</tt>.
137
+
138
+ To reload your controllers and models after launching the console run
139
+ <tt>reload!</tt>
140
+
141
+ More information about irb can be found at:
142
+ link:http://www.rubycentral.org/pickaxe/irb.html
143
+
144
+
145
+ == dbconsole
146
+
147
+ You can go to the command line of your database directly through <tt>rails
148
+ dbconsole</tt>. You would be connected to the database with the credentials
149
+ defined in database.yml. Starting the script without arguments will connect you
150
+ to the development database. Passing an argument will connect you to a different
151
+ database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
152
+ PostgreSQL and SQLite 3.
153
+
154
+ == Description of Contents
155
+
156
+ The default directory structure of a generated Ruby on Rails application:
157
+
158
+ |-- app
159
+ | |-- assets
160
+ | |-- images
161
+ | |-- javascripts
162
+ | `-- stylesheets
163
+ | |-- controllers
164
+ | |-- helpers
165
+ | |-- mailers
166
+ | |-- models
167
+ | `-- views
168
+ | `-- layouts
169
+ |-- config
170
+ | |-- environments
171
+ | |-- initializers
172
+ | `-- locales
173
+ |-- db
174
+ |-- doc
175
+ |-- lib
176
+ | `-- tasks
177
+ |-- log
178
+ |-- public
179
+ |-- script
180
+ |-- test
181
+ | |-- fixtures
182
+ | |-- functional
183
+ | |-- integration
184
+ | |-- performance
185
+ | `-- unit
186
+ |-- tmp
187
+ | |-- cache
188
+ | |-- pids
189
+ | |-- sessions
190
+ | `-- sockets
191
+ `-- vendor
192
+ |-- assets
193
+ `-- stylesheets
194
+ `-- plugins
195
+
196
+ app
197
+ Holds all the code that's specific to this particular application.
198
+
199
+ app/assets
200
+ Contains subdirectories for images, stylesheets, and JavaScript files.
201
+
202
+ app/controllers
203
+ Holds controllers that should be named like weblogs_controller.rb for
204
+ automated URL mapping. All controllers should descend from
205
+ ApplicationController which itself descends from ActionController::Base.
206
+
207
+ app/models
208
+ Holds models that should be named like post.rb. Models descend from
209
+ ActiveRecord::Base by default.
210
+
211
+ app/views
212
+ Holds the template files for the view that should be named like
213
+ weblogs/index.html.erb for the WeblogsController#index action. All views use
214
+ eRuby syntax by default.
215
+
216
+ app/views/layouts
217
+ Holds the template files for layouts to be used with views. This models the
218
+ common header/footer method of wrapping views. In your views, define a layout
219
+ using the <tt>layout :default</tt> and create a file named default.html.erb.
220
+ Inside default.html.erb, call <% yield %> to render the view using this
221
+ layout.
222
+
223
+ app/helpers
224
+ Holds view helpers that should be named like weblogs_helper.rb. These are
225
+ generated for you automatically when using generators for controllers.
226
+ Helpers can be used to wrap functionality for your views into methods.
227
+
228
+ config
229
+ Configuration files for the Rails environment, the routing map, the database,
230
+ and other dependencies.
231
+
232
+ db
233
+ Contains the database schema in schema.rb. db/migrate contains all the
234
+ sequence of Migrations for your schema.
235
+
236
+ doc
237
+ This directory is where your application documentation will be stored when
238
+ generated using <tt>rake doc:app</tt>
239
+
240
+ lib
241
+ Application specific libraries. Basically, any kind of custom code that
242
+ doesn't belong under controllers, models, or helpers. This directory is in
243
+ the load path.
244
+
245
+ public
246
+ The directory available for the web server. Also contains the dispatchers and the
247
+ default HTML files. This should be set as the DOCUMENT_ROOT of your web
248
+ server.
249
+
250
+ script
251
+ Helper scripts for automation and generation.
252
+
253
+ test
254
+ Unit and functional tests along with fixtures. When using the rails generate
255
+ command, template test files will be generated for you and placed in this
256
+ directory.
257
+
258
+ vendor
259
+ External libraries that the application depends on. Also includes the plugins
260
+ subdirectory. If the app has frozen rails, those gems also go here, under
261
+ vendor/rails/. This directory is in the load path.