gmaps4rails 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile.lock +7 -1
  3. data/README.rdoc +2 -2
  4. data/app/assets/javascripts/gmaps4rails/gmaps4rails.base.js.coffee +37 -96
  5. data/app/assets/javascripts/gmaps4rails/gmaps4rails.bing.js.coffee +11 -0
  6. data/app/assets/javascripts/gmaps4rails/gmaps4rails.googlemaps.js.coffee +85 -9
  7. data/app/assets/javascripts/gmaps4rails/gmaps4rails.mapquest.js.coffee +13 -2
  8. data/app/assets/javascripts/gmaps4rails/gmaps4rails.openlayers.js.coffee +54 -2
  9. data/app/views/gmaps4rails/_gmaps4rails.html.erb +1 -1
  10. data/gmaps4rails.gemspec +1 -0
  11. data/lib/generators/gmaps4rails/install_generator.rb +28 -12
  12. data/lib/gmaps4rails/acts_as_gmappable.rb +3 -46
  13. data/lib/gmaps4rails/api_wrappers/base_net_methods.rb +40 -0
  14. data/lib/gmaps4rails/api_wrappers/direction.rb +87 -0
  15. data/lib/gmaps4rails/api_wrappers/geocoder.rb +54 -0
  16. data/lib/gmaps4rails/api_wrappers/places.rb +74 -0
  17. data/lib/gmaps4rails/base.rb +80 -22
  18. data/lib/gmaps4rails/extensions/{array.rb → enumerable.rb} +1 -1
  19. data/lib/gmaps4rails/js_builder.rb +9 -17
  20. data/lib/gmaps4rails/json_builder.rb +1 -7
  21. data/lib/gmaps4rails/model_handler.rb +79 -0
  22. data/lib/gmaps4rails/version.rb +1 -1
  23. data/lib/gmaps4rails/view_helper.rb +4 -6
  24. data/public/javascripts/gmaps4rails/gmaps4rails.base.js +35 -112
  25. data/public/javascripts/gmaps4rails/gmaps4rails.bing.js +12 -0
  26. data/public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js +123 -7
  27. data/public/javascripts/gmaps4rails/gmaps4rails.mapquest.js +12 -0
  28. data/public/javascripts/gmaps4rails/gmaps4rails.openlayers.js +53 -2
  29. data/spec/dummy/app/views/users/index.html.erb +88 -85
  30. data/spec/fixtures/google_direction_valid.json +65 -0
  31. data/spec/fixtures/google_geocoding_toulon_france.json +58 -0
  32. data/spec/fixtures/google_places_valid.json +45 -0
  33. data/spec/fixtures/google_wrong_geocoding.json +4 -0
  34. data/spec/lib/base_spec.rb +59 -0
  35. data/spec/lib/direction_spec.rb +53 -0
  36. data/spec/lib/geocoder_spec.rb +46 -0
  37. data/spec/{base/base_spec.rb → lib/js_builder_spec.rb} +0 -6
  38. data/spec/lib/json_builder_spec.rb +232 -0
  39. data/spec/lib/places_spec.rb +25 -0
  40. data/spec/models/user_spec.rb +75 -357
  41. data/spec/spec_helper.rb +1 -0
  42. data/spec/support/geocoding.rb +27 -1
  43. metadata +47 -12
  44. data/lib/gmaps4rails/geocoding.rb +0 -113
  45. data/lib/gmaps4rails/google_places.rb +0 -76
  46. data/spec/base/geocoding_spec.rb +0 -17
@@ -80,6 +80,13 @@
80
80
  this.circles = [];
81
81
  this.markerClusterer = null;
82
82
  this.markerImages = [];
83
+ this.polylines_conf = {
84
+ strokeColor: "#FF0000",
85
+ strokeOpacity: 1,
86
+ strokeWeight: 2,
87
+ clickable: false,
88
+ zIndex: null
89
+ };
83
90
  }
84
91
 
85
92
  Gmaps4Rails.prototype.initialize = function() {
@@ -273,71 +280,6 @@
273
280
  return polygon.serviceObject = new_poly;
274
281
  };
275
282
 
276
- Gmaps4Rails.prototype.replacePolylines = function(new_polylines) {
277
- this.destroy_polylines();
278
- this.polylines = new_polylines;
279
- this.create_polylines();
280
- return this.adjustMapToBounds();
281
- };
282
-
283
- Gmaps4Rails.prototype.destroy_polylines = function() {
284
- var polyline, _i, _len, _ref;
285
- _ref = this.polylines;
286
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
287
- polyline = _ref[_i];
288
- polyline.serviceObject.setMap(null);
289
- }
290
- return this.polylines = [];
291
- };
292
-
293
- Gmaps4Rails.prototype.create_polylines = function() {
294
- var polyline, _i, _len, _ref, _results;
295
- _ref = this.polylines;
296
- _results = [];
297
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
298
- polyline = _ref[_i];
299
- _results.push(this.create_polyline(polyline));
300
- }
301
- return _results;
302
- };
303
-
304
- Gmaps4Rails.prototype.create_polyline = function(polyline) {
305
- var clickable, decoded_array, element, latlng, new_poly, point, polyline_coordinates, strokeColor, strokeOpacity, strokeWeight, zIndex, _i, _j, _len, _len2;
306
- polyline_coordinates = [];
307
- for (_i = 0, _len = polyline.length; _i < _len; _i++) {
308
- element = polyline[_i];
309
- if (element.coded_array != null) {
310
- decoded_array = new google.maps.geometry.encoding.decodePath(element.coded_array);
311
- for (_j = 0, _len2 = decoded_array.length; _j < _len2; _j++) {
312
- point = decoded_array[_j];
313
- polyline_coordinates.push(point);
314
- }
315
- } else {
316
- if (element === polyline[0]) {
317
- strokeColor = element.strokeColor || this.polylines_conf.strokeColor;
318
- strokeOpacity = element.strokeOpacity || this.polylines_conf.strokeOpacity;
319
- strokeWeight = element.strokeWeight || this.polylines_conf.strokeWeight;
320
- clickable = element.clickable || this.polylines_conf.clickable;
321
- zIndex = element.zIndex || this.polylines_conf.zIndex;
322
- }
323
- if ((element.lat != null) && (element.lng != null)) {
324
- latlng = this.createLatLng(element.lat, element.lng);
325
- polyline_coordinates.push(latlng);
326
- }
327
- }
328
- }
329
- new_poly = new google.maps.Polyline({
330
- path: polyline_coordinates,
331
- strokeColor: strokeColor,
332
- strokeOpacity: strokeOpacity,
333
- strokeWeight: strokeWeight,
334
- clickable: clickable,
335
- zIndex: zIndex
336
- });
337
- polyline.serviceObject = new_poly;
338
- return new_poly.setMap(this.serviceObject);
339
- };
340
-
341
283
  Gmaps4Rails.prototype.create_markers = function() {
342
284
  this.createServiceMarkersFromMarkers();
343
285
  return this.clusterize();
@@ -435,62 +377,43 @@
435
377
  };
436
378
 
437
379
  Gmaps4Rails.prototype.adjustMapToBounds = function() {
438
- var bound, circle, map_center, point, polygon, polygon_points, polyline, polyline_points, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _m, _n, _ref, _ref2, _ref3, _ref4;
439
380
  if (this.map_options.auto_adjust || this.map_options.bounds !== null) {
440
381
  this.boundsObject = this.createLatLngBounds();
441
- }
442
- if (this.map_options.auto_adjust) {
443
- this.extendBoundsWithMarkers();
444
- _ref = this.polylines;
445
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
446
- polyline = _ref[_i];
447
- polyline_points = polyline.serviceObject.latLngs.getArray()[0].getArray();
448
- for (_j = 0, _len2 = polyline_points.length; _j < _len2; _j++) {
449
- point = polyline_points[_j];
450
- this.boundsObject.extend(point);
451
- }
452
- }
453
- _ref2 = this.polygons;
454
- for (_k = 0, _len3 = _ref2.length; _k < _len3; _k++) {
455
- polygon = _ref2[_k];
456
- polygon_points = polygon.serviceObject.latLngs.getArray()[0].getArray();
457
- for (_l = 0, _len4 = polygon_points.length; _l < _len4; _l++) {
458
- point = polygon_points[_l];
459
- this.boundsObject.extend(point);
460
- }
461
- }
462
- _ref3 = this.circles;
463
- for (_m = 0, _len5 = _ref3.length; _m < _len5; _m++) {
464
- circle = _ref3[_m];
465
- this.boundsObject.extend(circle.serviceObject.getBounds().getNorthEast());
466
- this.boundsObject.extend(circle.serviceObject.getBounds().getSouthWest());
382
+ if (this.map_options.auto_adjust) {
383
+ this.extendBoundsWithMarkers();
384
+ this.updateBoundsWithPolylines();
385
+ this.updateBoundsWithPolygons();
386
+ this.updateBoundsWithCircles();
467
387
  }
388
+ this.extendMapBounds();
389
+ return this.adaptMapToBounds();
468
390
  }
469
- _ref4 = this.map_options.bounds;
470
- for (_n = 0, _len6 = _ref4.length; _n < _len6; _n++) {
471
- bound = _ref4[_n];
472
- bound = this.createLatLng(bound.lat, bound.lng);
473
- this.boundsObject.extend(bound);
474
- }
475
- if (this.map_options.auto_adjust || this.map_options.bounds.length > 0) {
476
- if (!this.map_options.auto_zoom) {
477
- map_center = this.boundsObject.getCenter();
478
- this.map_options.center_latitude = map_center.lat();
479
- this.map_options.center_longitude = map_center.lng();
480
- return this.serviceObject.setCenter(map_center);
481
- } else {
482
- return this.fitBounds();
483
- }
391
+ };
392
+
393
+ Gmaps4Rails.prototype.replacePolylines = function(new_polylines) {
394
+ this.destroy_polylines();
395
+ this.polylines = new_polylines;
396
+ this.create_polylines();
397
+ return this.adjustMapToBounds();
398
+ };
399
+
400
+ Gmaps4Rails.prototype.destroy_polylines = function() {
401
+ var polyline, _i, _len, _ref;
402
+ _ref = this.polylines;
403
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
404
+ polyline = _ref[_i];
405
+ polyline.serviceObject.setMap(null);
484
406
  }
407
+ return this.polylines = [];
485
408
  };
486
409
 
487
- Gmaps4Rails.prototype.create_kml = function() {
488
- var kml, _i, _len, _ref, _results;
489
- _ref = this.kml;
410
+ Gmaps4Rails.prototype.create_polylines = function() {
411
+ var polyline, _i, _len, _ref, _results;
412
+ _ref = this.polylines;
490
413
  _results = [];
491
414
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
492
- kml = _ref[_i];
493
- _results.push(kml.serviceObject = this.createKmlLayer(kml));
415
+ polyline = _ref[_i];
416
+ _results.push(this.create_polyline(polyline));
494
417
  }
495
418
  return _results;
496
419
  };
@@ -207,6 +207,18 @@
207
207
  });
208
208
  };
209
209
 
210
+ Gmaps4RailsBing.prototype.updateBoundsWithPolylines = function() {};
211
+
212
+ Gmaps4RailsBing.prototype.updateBoundsWithPolygons = function() {};
213
+
214
+ Gmaps4RailsBing.prototype.updateBoundsWithCircles = function() {};
215
+
216
+ Gmaps4RailsBing.prototype.extendMapBounds = function() {};
217
+
218
+ Gmaps4RailsBing.prototype.adaptMapToBounds = function() {
219
+ return this.fitBounds();
220
+ };
221
+
210
222
  return Gmaps4RailsBing;
211
223
 
212
224
  })(Gmaps4Rails);
@@ -34,13 +34,6 @@
34
34
  fillOpacity: 0.35,
35
35
  clickable: false
36
36
  };
37
- this.polylines_conf = {
38
- strokeColor: "#FF0000",
39
- strokeOpacity: 1,
40
- strokeWeight: 2,
41
- clickable: false,
42
- zIndex: null
43
- };
44
37
  this.circles_conf = {
45
38
  fillColor: "#00AAFF",
46
39
  fillOpacity: 0.35,
@@ -297,6 +290,74 @@
297
290
  return kml;
298
291
  };
299
292
 
293
+ Gmaps4RailsGoogle.prototype.create_polyline = function(polyline) {
294
+ var clickable, decoded_array, element, latlng, new_poly, point, polyline_coordinates, strokeColor, strokeOpacity, strokeWeight, zIndex, _i, _j, _len, _len2;
295
+ polyline_coordinates = [];
296
+ for (_i = 0, _len = polyline.length; _i < _len; _i++) {
297
+ element = polyline[_i];
298
+ if (element.coded_array != null) {
299
+ decoded_array = new google.maps.geometry.encoding.decodePath(element.coded_array);
300
+ for (_j = 0, _len2 = decoded_array.length; _j < _len2; _j++) {
301
+ point = decoded_array[_j];
302
+ polyline_coordinates.push(point);
303
+ }
304
+ } else {
305
+ if (element === polyline[0]) {
306
+ strokeColor = element.strokeColor || this.polylines_conf.strokeColor;
307
+ strokeOpacity = element.strokeOpacity || this.polylines_conf.strokeOpacity;
308
+ strokeWeight = element.strokeWeight || this.polylines_conf.strokeWeight;
309
+ clickable = element.clickable || this.polylines_conf.clickable;
310
+ zIndex = element.zIndex || this.polylines_conf.zIndex;
311
+ }
312
+ if ((element.lat != null) && (element.lng != null)) {
313
+ latlng = this.createLatLng(element.lat, element.lng);
314
+ polyline_coordinates.push(latlng);
315
+ }
316
+ }
317
+ }
318
+ new_poly = new google.maps.Polyline({
319
+ path: polyline_coordinates,
320
+ strokeColor: strokeColor,
321
+ strokeOpacity: strokeOpacity,
322
+ strokeWeight: strokeWeight,
323
+ clickable: clickable,
324
+ zIndex: zIndex
325
+ });
326
+ polyline.serviceObject = new_poly;
327
+ return new_poly.setMap(this.serviceObject);
328
+ };
329
+
330
+ Gmaps4RailsGoogle.prototype.updateBoundsWithPolylines = function() {
331
+ var point, polyline, polyline_points, _i, _len, _ref, _results;
332
+ _ref = this.polylines;
333
+ _results = [];
334
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
335
+ polyline = _ref[_i];
336
+ polyline_points = polyline.serviceObject.latLngs.getArray()[0].getArray();
337
+ _results.push((function() {
338
+ var _j, _len2, _results2;
339
+ _results2 = [];
340
+ for (_j = 0, _len2 = polyline_points.length; _j < _len2; _j++) {
341
+ point = polyline_points[_j];
342
+ _results2.push(this.boundsObject.extend(point));
343
+ }
344
+ return _results2;
345
+ }).call(this));
346
+ }
347
+ return _results;
348
+ };
349
+
350
+ Gmaps4RailsGoogle.prototype.create_kml = function() {
351
+ var kml, _i, _len, _ref, _results;
352
+ _ref = this.kml;
353
+ _results = [];
354
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
355
+ kml = _ref[_i];
356
+ _results.push(kml.serviceObject = this.createKmlLayer(kml));
357
+ }
358
+ return _results;
359
+ };
360
+
300
361
  Gmaps4RailsGoogle.prototype.fitBounds = function() {
301
362
  if (!this.boundsObject.isEmpty()) {
302
363
  return this.serviceObject.fitBounds(this.boundsObject);
@@ -307,6 +368,61 @@
307
368
  return this.serviceObject.setCenter(this.userLocation);
308
369
  };
309
370
 
371
+ Gmaps4RailsGoogle.prototype.updateBoundsWithPolygons = function() {
372
+ var point, polygon, polygon_points, _i, _len, _ref, _results;
373
+ _ref = this.polygons;
374
+ _results = [];
375
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
376
+ polygon = _ref[_i];
377
+ polygon_points = polygon.serviceObject.latLngs.getArray()[0].getArray();
378
+ _results.push((function() {
379
+ var _j, _len2, _results2;
380
+ _results2 = [];
381
+ for (_j = 0, _len2 = polygon_points.length; _j < _len2; _j++) {
382
+ point = polygon_points[_j];
383
+ _results2.push(this.boundsObject.extend(point));
384
+ }
385
+ return _results2;
386
+ }).call(this));
387
+ }
388
+ return _results;
389
+ };
390
+
391
+ Gmaps4RailsGoogle.prototype.updateBoundsWithCircles = function() {
392
+ var circle, _i, _len, _ref, _results;
393
+ _ref = this.circles;
394
+ _results = [];
395
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
396
+ circle = _ref[_i];
397
+ this.boundsObject.extend(circle.serviceObject.getBounds().getNorthEast());
398
+ _results.push(this.boundsObject.extend(circle.serviceObject.getBounds().getSouthWest()));
399
+ }
400
+ return _results;
401
+ };
402
+
403
+ Gmaps4RailsGoogle.prototype.extendMapBounds = function() {
404
+ var bound, _i, _len, _ref, _results;
405
+ _ref = this.map_options.bounds;
406
+ _results = [];
407
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
408
+ bound = _ref[_i];
409
+ _results.push(this.boundsObject.extend(this.createLatLng(bound.lat, bound.lng)));
410
+ }
411
+ return _results;
412
+ };
413
+
414
+ Gmaps4RailsGoogle.prototype.adaptMapToBounds = function() {
415
+ var map_center;
416
+ if (!this.map_options.auto_zoom) {
417
+ map_center = this.boundsObject.getCenter();
418
+ this.map_options.center_latitude = map_center.lat();
419
+ this.map_options.center_longitude = map_center.lng();
420
+ return this.serviceObject.setCenter(map_center);
421
+ } else {
422
+ return this.fitBounds();
423
+ }
424
+ };
425
+
310
426
  return Gmaps4RailsGoogle;
311
427
 
312
428
  })(Gmaps4Rails);
@@ -159,6 +159,18 @@
159
159
  return this.serviceObject.removeShape(object);
160
160
  };
161
161
 
162
+ Gmaps4RailsMapquest.prototype.updateBoundsWithPolylines = function() {};
163
+
164
+ Gmaps4RailsMapquest.prototype.updateBoundsWithPolygons = function() {};
165
+
166
+ Gmaps4RailsMapquest.prototype.updateBoundsWithCircles = function() {};
167
+
168
+ Gmaps4RailsMapquest.prototype.extendMapBounds = function() {};
169
+
170
+ Gmaps4RailsMapquest.prototype.adaptMapToBounds = function() {
171
+ return this.fitBounds();
172
+ };
173
+
162
174
  return Gmaps4RailsMapquest;
163
175
 
164
176
  })(Gmaps4Rails);
@@ -15,6 +15,7 @@
15
15
  this.openMarkers = null;
16
16
  this.markersLayer = null;
17
17
  this.markersControl = null;
18
+ this.polylinesLayer = null;
18
19
  }
19
20
 
20
21
  Gmaps4RailsOpenlayers.prototype.createPoint = function(lat, lng) {};
@@ -99,6 +100,7 @@
99
100
 
100
101
  Gmaps4RailsOpenlayers.prototype.extendBoundsWithMarkers = function() {
101
102
  var marker, _i, _len, _ref, _results;
103
+ console.log("here");
102
104
  _ref = this.markers;
103
105
  _results = [];
104
106
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -186,19 +188,62 @@
186
188
  popup = new OpenLayers.Popup.FramedCloud("featurePopup", feature.geometry.getBounds().getCenterLonLat(), new OpenLayers.Size(300, 200), feature.infoWindow, null, true, this.onPopupClose);
187
189
  feature.popup = popup;
188
190
  popup.feature = feature;
189
- return this.serviceObject.addPopup(popup);
191
+ return this.map.addPopup(popup);
190
192
  };
191
193
 
192
194
  Gmaps4RailsOpenlayers.prototype.onFeatureUnselect = function(evt) {
193
195
  var feature;
194
196
  feature = evt.feature;
195
197
  if (feature.popup) {
196
- this.serviceObject.removePopup(feature.popup);
198
+ this.map.removePopup(feature.popup);
197
199
  feature.popup.destroy();
198
200
  return feature.popup = null;
199
201
  }
200
202
  };
201
203
 
204
+ Gmaps4RailsOpenlayers.prototype.create_polyline = function(polyline) {
205
+ var clickable, element, latlng, line_points, line_style, polyline_coordinates, strokeColor, strokeOpacity, strokeWeight, zIndex, _i, _len;
206
+ if (this.polylinesLayer === null) {
207
+ this.polylinesLayer = new OpenLayers.Layer.Vector("Polylines", null);
208
+ this.serviceObject.addLayer(this.polylinesLayer);
209
+ this.polylinesLayer.events.register("featureselected", this.polylinesLayer, this.onFeatureSelect);
210
+ this.polylinesLayer.events.register("featureunselected", this.polylinesLayer, this.onFeatureUnselect);
211
+ this.polylinesControl = new OpenLayers.Control.DrawFeature(this.polylinesLayer, OpenLayers.Handler.Path);
212
+ this.serviceObject.addControl(this.polylinesControl);
213
+ }
214
+ polyline_coordinates = [];
215
+ for (_i = 0, _len = polyline.length; _i < _len; _i++) {
216
+ element = polyline[_i];
217
+ if (element === polyline[0]) {
218
+ strokeColor = element.strokeColor || this.polylines_conf.strokeColor;
219
+ strokeOpacity = element.strokeOpacity || this.polylines_conf.strokeOpacity;
220
+ strokeWeight = element.strokeWeight || this.polylines_conf.strokeWeight;
221
+ clickable = element.clickable || this.polylines_conf.clickable;
222
+ zIndex = element.zIndex || this.polylines_conf.zIndex;
223
+ }
224
+ if ((element.lat != null) && (element.lng != null)) {
225
+ latlng = new OpenLayers.Geometry.Point(element.lng, element.lat);
226
+ polyline_coordinates.push(latlng);
227
+ }
228
+ }
229
+ line_points = new OpenLayers.Geometry.LineString(polyline_coordinates);
230
+ line_style = {
231
+ strokeColor: strokeColor,
232
+ strokeOpacity: strokeOpacity,
233
+ strokeWidth: strokeWeight
234
+ };
235
+ polyline = new OpenLayers.Feature.Vector(line_points, null, line_style);
236
+ polyline.geometry.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
237
+ this.polylinesLayer.addFeatures([polyline]);
238
+ return polyline;
239
+ };
240
+
241
+ Gmaps4RailsOpenlayers.prototype.updateBoundsWithPolylines = function() {};
242
+
243
+ Gmaps4RailsOpenlayers.prototype.updateBoundsWithPolygons = function() {};
244
+
245
+ Gmaps4RailsOpenlayers.prototype.updateBoundsWithCircles = function() {};
246
+
202
247
  Gmaps4RailsOpenlayers.prototype.fitBounds = function() {
203
248
  return this.serviceObject.zoomToExtent(this.boundsObject, true);
204
249
  };
@@ -207,6 +252,12 @@
207
252
  return this.serviceObject.setCenter(this.userLocation);
208
253
  };
209
254
 
255
+ Gmaps4RailsOpenlayers.prototype.extendMapBounds = function() {};
256
+
257
+ Gmaps4RailsOpenlayers.prototype.adaptMapToBounds = function() {
258
+ return this.fitBounds();
259
+ };
260
+
210
261
  return Gmaps4RailsOpenlayers;
211
262
 
212
263
  })(Gmaps4Rails);
@@ -32,7 +32,7 @@
32
32
  <div id="map" class="gmaps4rails_map"></div>
33
33
  </div> -->
34
34
  <script type="text/javascript" charset="utf-8">
35
- window.onload =alert('ok');
35
+ //window.onload =alert('ok');
36
36
 
37
37
  //
38
38
  // Gmaps.map = new Gmaps4RailsGoogle();
@@ -85,9 +85,10 @@ window.onload =alert('ok');
85
85
  :options => {"list_container" => "markers_list" }
86
86
  })%>
87
87
  <div id="markers_list"></div>
88
- <%= gmaps(:markers => {:data => @json}, :map_options =>
89
- {:auto_adjust => false, :bounds => '[{"lat":42.3124,"lng":-71.1712},{"lat":42.3997,"lng":-71.0531}]', :auto_zoom => false }) %>
90
- <%#= gmaps(:markers => {:data => @json, :options => {:do_clustering => false, "custom_infowindow_class" => "yellow", :raw => "{ flat: true, draggable: true}" } },
88
+ <%#= gmaps(:map_options => { :auto_adjust => true },
89
+ :markers => { :data => '[{"lat":42.3124,"lng":71.1712}]', :options => {:do_clustering => true} }) %>
90
+
91
+ <%= gmaps(:markers => {:data => @json, :options => {:do_clustering => false, "custom_infowindow_class" => "yellow", :raw => "{ flat: true, draggable: true}" } },
91
92
  :polygons => {:data => '[[
92
93
  {"lng": 5.190262, "lat": 25.774252},
93
94
  {"lng": 7.118292, "lat": 45.466465},
@@ -116,7 +117,8 @@ window.onload =alert('ok');
116
117
  <%#= gmaps(:markers => {:data => @json, :options => {:do_clustering => false, :draggable => true } },
117
118
  :map_options => { :auto_adjust => true, :center_on_user => true, :zoom => 5, :provider => "openlayers", :id => "joe" },
118
119
  :scripts => "api",
119
- :last_map => false ) %>
120
+ :last_map => false)
121
+ %>
120
122
  <%#= gmaps(:markers => {:data => @json, :options => {:do_clustering => false, :draggable => true } },
121
123
  :map_options => { :auto_adjust => true, :center_on_user => true, :zoom => 5, :id => "joe3", :provider => "mapquest", :provider_key => MAPQUEST_KEY },
122
124
  :scripts => "api",
@@ -143,87 +145,88 @@ window.onload =alert('ok');
143
145
  // return "ok";
144
146
  // }
145
147
 
146
- function HomeControl(controlDiv, map) {
147
- var chicago = new google.maps.LatLng(41.850033, -87.6500523);
148
-
149
- // Set CSS styles for the DIV containing the control
150
- // Setting padding to 5 px will offset the control
151
- // from the edge of the map.
152
- controlDiv.style.padding = '5px';
153
-
154
- // Set CSS for the control border.
155
- var controlUI = document.createElement('DIV');
156
- controlUI.style.backgroundColor = 'white';
157
- controlUI.style.borderStyle = 'solid';
158
- controlUI.style.borderWidth = '2px';
159
- controlUI.style.cursor = 'pointer';
160
- controlUI.style.textAlign = 'center';
161
- controlUI.title = 'Click to set the map to Home';
162
- controlDiv.appendChild(controlUI);
163
-
164
- // Set CSS for the control interior.
165
- var controlText = document.createElement('DIV');
166
- controlText.style.fontFamily = 'Arial,sans-serif';
167
- controlText.style.fontSize = '12px';
168
- controlText.style.paddingLeft = '4px';
169
- controlText.style.paddingRight = '4px';
170
- controlText.innerHTML = 'Home';
171
- controlUI.appendChild(controlText);
172
-
173
- // Setup the click event listeners: simply set the map to Chicago.
174
- google.maps.event.addDomListener(controlUI, 'click', function() {
175
- map.setCenter(chicago)
176
- });
177
- }
178
-
179
- Gmaps.map.callback = function(){
180
- // Create the DIV to hold the control and call the HomeControl() constructor
181
- // passing in this DIV.
182
- var homeControlDiv = document.createElement('DIV');
183
- var homeControl = new HomeControl(homeControlDiv, Gmaps.map.map);
184
-
185
- homeControlDiv.index = 1;
186
- Gmaps.map.map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);
187
- };
188
-
189
-
190
- var pinkParksStyles = [
191
- {
192
- featureType: "all",
193
- stylers: [
194
- { saturation: -80 }
195
- ]
196
- },
197
- {
198
- featureType: "poi.park",
199
- stylers: [
200
- { hue: "#ff0023" },
201
- { saturation: 40 }
202
- ]
148
+ // function HomeControl(controlDiv, map) {
149
+ // var chicago = new google.maps.LatLng(41.850033, -87.6500523);
150
+ //
151
+ // // Set CSS styles for the DIV containing the control
152
+ // // Setting padding to 5 px will offset the control
153
+ // // from the edge of the map.
154
+ // controlDiv.style.padding = '5px';
155
+ //
156
+ // // Set CSS for the control border.
157
+ // var controlUI = document.createElement('DIV');
158
+ // controlUI.style.backgroundColor = 'white';
159
+ // controlUI.style.borderStyle = 'solid';
160
+ // controlUI.style.borderWidth = '2px';
161
+ // controlUI.style.cursor = 'pointer';
162
+ // controlUI.style.textAlign = 'center';
163
+ // controlUI.title = 'Click to set the map to Home';
164
+ // controlDiv.appendChild(controlUI);
165
+ //
166
+ // // Set CSS for the control interior.
167
+ // var controlText = document.createElement('DIV');
168
+ // controlText.style.fontFamily = 'Arial,sans-serif';
169
+ // controlText.style.fontSize = '12px';
170
+ // controlText.style.paddingLeft = '4px';
171
+ // controlText.style.paddingRight = '4px';
172
+ // controlText.innerHTML = 'Home';
173
+ // controlUI.appendChild(controlText);
174
+ //
175
+ // // Setup the click event listeners: simply set the map to Chicago.
176
+ // google.maps.event.addDomListener(controlUI, 'click', function() {
177
+ // map.setCenter(chicago)
178
+ // });
179
+ // }
180
+ //
181
+ Gmaps.map.callback = function(){
182
+ // Create the DIV to hold the control and call the HomeControl() constructor
183
+ // passing in this DIV.
184
+ // var homeControlDiv = document.createElement('DIV');
185
+ // var homeControl = new HomeControl(homeControlDiv, Gmaps.map.map);
186
+ //
187
+ // homeControlDiv.index = 1;
188
+ // Gmaps.map.map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);
189
+ //Gmaps.map.serviceObject.setZoom(1);
190
+ };
191
+ //
192
+ //
193
+ var pinkParksStyles = [
194
+ {
195
+ featureType: "all",
196
+ stylers: [
197
+ { saturation: -80 }
198
+ ]
199
+ },
200
+ {
201
+ featureType: "poi.park",
202
+ stylers: [
203
+ { hue: "#ff0023" },
204
+ { saturation: 40 }
205
+ ]
206
+ }
207
+ ];
208
+ //
209
+ //
210
+
211
+ Gmaps.map.infobox = function(boxText) {
212
+ return {
213
+ content: boxText
214
+ ,disableAutoPan: false
215
+ ,maxWidth: 0
216
+ ,pixelOffset: new google.maps.Size(-140, 0)
217
+ ,zIndex: null
218
+ ,boxStyle: {
219
+ background: "url('http://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.5/examples/tipbox.gif') no-repeat"
220
+ ,opacity: 0.75
221
+ ,width: "280px"
203
222
  }
204
- ];
205
-
206
-
207
-
208
- Gmaps.map.infobox = function(boxText) {
209
- return {
210
- content: boxText
211
- ,disableAutoPan: false
212
- ,maxWidth: 0
213
- ,pixelOffset: new google.maps.Size(-140, 0)
214
- ,zIndex: null
215
- ,boxStyle: {
216
- background: "url('http://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.5/examples/tipbox.gif') no-repeat"
217
- ,opacity: 0.75
218
- ,width: "280px"
219
- }
220
- ,closeBoxMargin: "10px 2px 2px 2px"
221
- ,closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif"
222
- ,infoBoxClearance: new google.maps.Size(1, 1)
223
- ,isHidden: false
224
- ,pane: "floatPane"
225
- ,enableEventPropagation: false
226
- }};
223
+ ,closeBoxMargin: "10px 2px 2px 2px"
224
+ ,closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif"
225
+ ,infoBoxClearance: new google.maps.Size(1, 1)
226
+ ,isHidden: false
227
+ ,pane: "floatPane"
228
+ ,enableEventPropagation: false
229
+ }};
227
230
 
228
231
  </script>
229
232
  <script type="text/javascript" charset="utf-8">