gmaps4rails 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -0
- data/public/javascripts/gmaps4rails.js +78 -81
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -8,6 +8,9 @@ Gmaps4rails is developped to simply create a Google Map:
|
|
8
8
|
|
9
9
|
It's based on Ruby on Rails 3 Engines and uses Google Maps API V3.
|
10
10
|
|
11
|
+
See screencasts here: http://www.youtube.com/user/TheApneadiving
|
12
|
+
|
13
|
+
|
11
14
|
== Requirements
|
12
15
|
- gem 'gmaps4rails' (in your gemfile, then bundle)
|
13
16
|
- <%= yield :head %> (in your header)
|
@@ -16,7 +16,7 @@ var Gmaps4Rails = {
|
|
16
16
|
minZoom: null,
|
17
17
|
auto_adjust : false, //adjust the map to the markers if set to true
|
18
18
|
auto_zoom: true, //zoom given by auto-adjust
|
19
|
-
bounds: []
|
19
|
+
bounds: [] //adjust map to these limits. Should be [{"lat": , "lng": }]
|
20
20
|
},
|
21
21
|
|
22
22
|
//markers + info styling
|
@@ -43,10 +43,10 @@ var Gmaps4Rails = {
|
|
43
43
|
|
44
44
|
//Polygon Styling
|
45
45
|
polygons_conf: { //default style for polygons
|
46
|
-
strokeColor: "#
|
46
|
+
strokeColor: "#FFAA00",
|
47
47
|
strokeOpacity: 0.8,
|
48
48
|
strokeWeight: 2,
|
49
|
-
|
49
|
+
fillColor: "#000000",
|
50
50
|
fillOpacity: 0.35
|
51
51
|
},
|
52
52
|
|
@@ -59,9 +59,9 @@ var Gmaps4Rails = {
|
|
59
59
|
|
60
60
|
//Circle Styling
|
61
61
|
circles_conf: { //default style for circles
|
62
|
-
fillColor: "#
|
62
|
+
fillColor: "#00AAFF",
|
63
63
|
fillOpacity: 0.35,
|
64
|
-
strokeColor: "#
|
64
|
+
strokeColor: "#FFAA00",
|
65
65
|
strokeOpacity: 0.8,
|
66
66
|
strokeWeight: 2
|
67
67
|
},
|
@@ -132,7 +132,7 @@ var Gmaps4Rails = {
|
|
132
132
|
create_circles: function(){
|
133
133
|
for (var i = 0; i < this.circles.length; ++i) {
|
134
134
|
//by convention, default style configuration could be integrated in the first element
|
135
|
-
if ( i
|
135
|
+
if ( i === 0 )
|
136
136
|
{
|
137
137
|
if (this.exists(this.circles[i].strokeColor )) { this.circles_conf.strokeColor = this.circles[i].strokeColor; }
|
138
138
|
if (this.exists(this.circles[i].strokeOpacity)) { this.circles_conf.strokeOpacity = this.circles[i].strokeOpacity; }
|
@@ -163,7 +163,7 @@ var Gmaps4Rails = {
|
|
163
163
|
//polygons is an array of arrays. It loops.
|
164
164
|
create_polygons: function(){
|
165
165
|
for (var i = 0; i < this.polygons.length; ++i) {
|
166
|
-
this.create_polygon(i)
|
166
|
+
this.create_polygon(i);
|
167
167
|
}
|
168
168
|
},
|
169
169
|
|
@@ -180,7 +180,7 @@ var Gmaps4Rails = {
|
|
180
180
|
var latlng = new google.maps.LatLng(this.polygons[i][j].latitude, this.polygons[i][j].longitude);
|
181
181
|
polygon_coordinates.push(latlng);
|
182
182
|
//first element of an Array could contain specific configuration for this particular polygon. If no config given, use default
|
183
|
-
if (j
|
183
|
+
if (j===0) {
|
184
184
|
strokeColor = this.polygons[i][j].strokeColor || this.polygons_conf.strokeColor;
|
185
185
|
strokeOpacity = this.polygons[i][j].strokeOpacity || this.polygons_conf.strokeOpacity;
|
186
186
|
strokeWeight = this.polygons[i][j].strokeWeight || this.polygons_conf.strokeWeight;
|
@@ -232,7 +232,7 @@ var Gmaps4Rails = {
|
|
232
232
|
//or we have an array of latlng
|
233
233
|
else{
|
234
234
|
//by convention, a single polyline could be customized in the first array or it uses default values
|
235
|
-
if (j
|
235
|
+
if (j===0){
|
236
236
|
strokeColor = this.polylines[i][0].strokeColor || this.polylines_conf.strokeColor;
|
237
237
|
strokeOpacity = this.polylines[i][0].strokeOpacity || this.polylines_conf.strokeOpacity;
|
238
238
|
strokeWeight = this.polylines[i][0].strokeWeight || this.polylines_conf.strokeWeight;
|
@@ -258,45 +258,6 @@ var Gmaps4Rails = {
|
|
258
258
|
new_poly.setMap(this.map);
|
259
259
|
},
|
260
260
|
|
261
|
-
// clear markers
|
262
|
-
clear_markers: function(){
|
263
|
-
if (this.markerClusterer != null){
|
264
|
-
this.markerClusterer.clearMarkers();
|
265
|
-
}
|
266
|
-
for (var i = 0; i < this.markers.length; ++i) {
|
267
|
-
this.markers[i].google_object.setMap(null);
|
268
|
-
}
|
269
|
-
},
|
270
|
-
|
271
|
-
// replace old markers with new markers on an existing map
|
272
|
-
replace_markers: function(new_markers){
|
273
|
-
//reset previous markers
|
274
|
-
this.markers = new Array;
|
275
|
-
//reset current bounds
|
276
|
-
this.google_bounds = new google.maps.LatLngBounds();
|
277
|
-
//reset sidebar content if exists
|
278
|
-
this.reset_sidebar_content();
|
279
|
-
//add new markers
|
280
|
-
this.add_markers(new_markers);
|
281
|
-
},
|
282
|
-
|
283
|
-
reset_sidebar_content: function(){
|
284
|
-
if (this.markers_conf.list_container != null ){
|
285
|
-
var ul = document.getElementById(this.markers_conf.list_container);
|
286
|
-
ul.innerHTML = "";
|
287
|
-
}
|
288
|
-
},
|
289
|
-
|
290
|
-
//add new markers to on an existing map (beware, it doesn't check duplicates)
|
291
|
-
add_markers: function(new_markers){
|
292
|
-
//clear the whole map
|
293
|
-
this.clear_markers();
|
294
|
-
//update the list of markers to take into account
|
295
|
-
this.markers = this.markers.concat(new_markers);
|
296
|
-
//put markers on the map
|
297
|
-
this.create_markers();
|
298
|
-
},
|
299
|
-
|
300
261
|
//creates, clusterizes and adjusts map
|
301
262
|
create_markers: function() {
|
302
263
|
this.create_google_markers_from_markers();
|
@@ -328,7 +289,7 @@ var Gmaps4Rails = {
|
|
328
289
|
var myLatLng = new google.maps.LatLng(Lat, Lng);
|
329
290
|
|
330
291
|
// Marker sizes are expressed as a Size of X,Y
|
331
|
-
if (marker_picture
|
292
|
+
if (marker_picture === "")
|
332
293
|
{ var ThisMarker = new google.maps.Marker({position: myLatLng, map: this.map, title: marker_title}); }
|
333
294
|
else
|
334
295
|
{
|
@@ -345,6 +306,53 @@ var Gmaps4Rails = {
|
|
345
306
|
}
|
346
307
|
|
347
308
|
},
|
309
|
+
|
310
|
+
// clear markers
|
311
|
+
clear_markers: function(){
|
312
|
+
if (this.markerClusterer !== null){
|
313
|
+
this.markerClusterer.clearMarkers();
|
314
|
+
}
|
315
|
+
for (var i = 0; i < this.markers.length; ++i) {
|
316
|
+
this.markers[i].google_object.setMap(null);
|
317
|
+
}
|
318
|
+
},
|
319
|
+
|
320
|
+
// replace old markers with new markers on an existing map
|
321
|
+
replace_markers: function(new_markers){
|
322
|
+
//reset previous markers
|
323
|
+
this.markers = new Array;
|
324
|
+
//reset current bounds
|
325
|
+
this.google_bounds = new google.maps.LatLngBounds();
|
326
|
+
//reset sidebar content if exists
|
327
|
+
this.reset_sidebar_content();
|
328
|
+
//add new markers
|
329
|
+
this.add_markers(new_markers);
|
330
|
+
},
|
331
|
+
|
332
|
+
//add new markers to on an existing map
|
333
|
+
add_markers: function(new_markers){
|
334
|
+
//clear the whole map
|
335
|
+
this.clear_markers();
|
336
|
+
//update the list of markers to take into account
|
337
|
+
this.markers = this.markers.concat(new_markers);
|
338
|
+
//put markers on the map
|
339
|
+
this.create_markers();
|
340
|
+
},
|
341
|
+
|
342
|
+
//creates clusters
|
343
|
+
clusterize: function()
|
344
|
+
{
|
345
|
+
if (this.markers_conf.do_clustering === true)
|
346
|
+
{
|
347
|
+
var gmarkers_array = new Array;
|
348
|
+
for (var i = 0; i < this.markers.length; ++i) {
|
349
|
+
gmarkers_array.push(this.markers[i].google_object);
|
350
|
+
}
|
351
|
+
|
352
|
+
|
353
|
+
this.markerClusterer = new MarkerClusterer(this.map, gmarkers_array, { maxZoom: this.markers_conf.clusterer_maxZoom, gridSize: this.markers_conf.clusterer_gridSize });
|
354
|
+
}
|
355
|
+
},
|
348
356
|
|
349
357
|
// creates infowindows
|
350
358
|
create_info_window: function(marker_container){
|
@@ -354,7 +362,19 @@ var Gmaps4Rails = {
|
|
354
362
|
google.maps.event.addListener(marker_container.google_object, 'click', this.openInfoWindow(info_window, marker_container.google_object));
|
355
363
|
|
356
364
|
},
|
357
|
-
|
365
|
+
|
366
|
+
openInfoWindow: function(infoWindow, marker) {
|
367
|
+
return function() {
|
368
|
+
// Close the latest selected marker before opening the current one.
|
369
|
+
if (Gmaps4Rails.visibleInfoWindow) {
|
370
|
+
Gmaps4Rails.visibleInfoWindow.close();
|
371
|
+
}
|
372
|
+
|
373
|
+
infoWindow.open(Gmaps4Rails.map, marker);
|
374
|
+
Gmaps4Rails.visibleInfoWindow = infoWindow;
|
375
|
+
};
|
376
|
+
},
|
377
|
+
|
358
378
|
//creates sidebar
|
359
379
|
create_sidebar: function(marker_container){
|
360
380
|
if (this.markers_conf.list_container)
|
@@ -377,36 +397,13 @@ var Gmaps4Rails = {
|
|
377
397
|
Gmaps4Rails.map.panTo(marker.position);
|
378
398
|
google.maps.event.trigger(marker, eventType);
|
379
399
|
};
|
380
|
-
},
|
381
|
-
|
382
|
-
openInfoWindow: function(infoWindow, marker) {
|
383
|
-
return function() {
|
384
|
-
// Close the latest selected marker before opening the current one.
|
385
|
-
if (Gmaps4Rails.visibleInfoWindow) {
|
386
|
-
Gmaps4Rails.visibleInfoWindow.close();
|
387
|
-
}
|
388
|
-
|
389
|
-
infoWindow.open(Gmaps4Rails.map, marker);
|
390
|
-
Gmaps4Rails.visibleInfoWindow = infoWindow;
|
391
|
-
};
|
392
|
-
},
|
400
|
+
},
|
393
401
|
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
var gmarkers_array = new Array;
|
400
|
-
for (var i = 0; i < this.markers.length; ++i) {
|
401
|
-
gmarkers_array.push(this.markers[i].google_object);
|
402
|
-
}
|
403
|
-
|
404
|
-
|
405
|
-
this.markerClusterer = new MarkerClusterer(this.map, gmarkers_array, { maxZoom: this.markers_conf.clusterer_maxZoom,
|
406
|
-
gridSize: this.markers_conf.clusterer_gridSize,
|
407
|
-
//styles: styles TODO: offer clusterer customization
|
408
|
-
});
|
409
|
-
}
|
402
|
+
reset_sidebar_content: function(){
|
403
|
+
if (this.markers_conf.list_container !== null ){
|
404
|
+
var ul = document.getElementById(this.markers_conf.list_container);
|
405
|
+
ul.innerHTML = "";
|
406
|
+
}
|
410
407
|
},
|
411
408
|
|
412
409
|
//to make the map fit the different LatLng points
|
@@ -414,7 +411,7 @@ var Gmaps4Rails = {
|
|
414
411
|
|
415
412
|
//FIRST_STEP: retrieve all bounds
|
416
413
|
//create the bounds object only if necessary
|
417
|
-
if (this.map_options.auto_adjust || this.map_options.bounds
|
414
|
+
if (this.map_options.auto_adjust || this.map_options.bounds !== null) {
|
418
415
|
this.google_bounds = new google.maps.LatLngBounds();
|
419
416
|
}
|
420
417
|
|
@@ -463,7 +460,7 @@ var Gmaps4Rails = {
|
|
463
460
|
|
464
461
|
//basic function to check existence of a variable
|
465
462
|
exists: function(var_name) {
|
466
|
-
return var_name
|
463
|
+
return var_name !== "" && typeof var_name !== "undefined"
|
467
464
|
},
|
468
465
|
|
469
466
|
//randomize
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmaps4rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 6
|
10
|
+
version: 0.7.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Benjamin Roth
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-04-
|
19
|
+
date: 2011-04-16 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|