gmaps4rails 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +21 -0
- data/README.rdoc +2 -2
- data/public/javascripts/gmaps4rails.js +35 -5
- metadata +6 -4
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2010 Benjamin Roth
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -64,9 +64,9 @@ Done!
|
|
64
64
|
|
65
65
|
* Marker clusterer customization
|
66
66
|
|
67
|
-
*
|
67
|
+
* Integrate Markers with Label: http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerwithlabel/1.1.2/
|
68
68
|
|
69
|
-
*
|
69
|
+
* Other options from here: http://code.google.com/p/google-maps-utility-library-v3/wiki/Libraries ?
|
70
70
|
|
71
71
|
Feel free ton contact us, you have your say.
|
72
72
|
|
@@ -11,6 +11,8 @@ var Gmaps4Rails = {
|
|
11
11
|
center_latitude : 0,
|
12
12
|
center_longitude : 0,
|
13
13
|
zoom : 1,
|
14
|
+
maxZoom: null,
|
15
|
+
minZoom: null,
|
14
16
|
auto_adjust : false //adjust the map to the markers if set to true
|
15
17
|
},
|
16
18
|
|
@@ -22,7 +24,9 @@ var Gmaps4Rails = {
|
|
22
24
|
//clustering config
|
23
25
|
do_clustering: true, //do clustering if set to true
|
24
26
|
clusterer_gridSize: 50, //the more the quicker but the less precise
|
25
|
-
clusterer_maxZoom:
|
27
|
+
clusterer_maxZoom: 5, //removes clusterer at this zoom level
|
28
|
+
randomize: true, //Google maps can't display two markers which have the same coordinates. This randomizer enables to prevent this situation to happen.
|
29
|
+
max_random_distance: 100 //in meters. Each marker coordinate could be altered by this distance in a random direction
|
26
30
|
},
|
27
31
|
|
28
32
|
//Stored variables
|
@@ -80,6 +84,8 @@ var Gmaps4Rails = {
|
|
80
84
|
//initializes the map
|
81
85
|
initialize: function(){
|
82
86
|
this.map = new google.maps.Map(document.getElementById(this.map_options.id), {
|
87
|
+
maxZoom: this.map_options.maxZoom,
|
88
|
+
minZoom: this.map_options.minZoom,
|
83
89
|
zoom: this.map_options.zoom,
|
84
90
|
center: new google.maps.LatLng(this.map_options.center_latitude, this.map_options.center_longitude),
|
85
91
|
mapTypeId: google.maps.MapTypeId[this.map_options.type]
|
@@ -340,8 +346,18 @@ var Gmaps4Rails = {
|
|
340
346
|
var marker_width = this.exists(this.markers[i].width) ? this.markers[i].width : this.markers_conf.width;
|
341
347
|
var marker_height = this.exists(this.markers[i].height) ? this.markers[i].height : this.markers_conf.length;
|
342
348
|
var marker_title = this.exists(this.markers[i].title) ? this.markers[i].title : null;
|
343
|
-
|
344
|
-
var
|
349
|
+
var Lat = this.markers[i].latitude;
|
350
|
+
var Lng = this.markers[i].longitude;
|
351
|
+
|
352
|
+
//alter coordinates if randomize is true
|
353
|
+
if ( this.markers_conf.randomize)
|
354
|
+
{
|
355
|
+
var LatLng = this.randomize(Lat, Lng);
|
356
|
+
//retrieve coordinates from the array
|
357
|
+
Lat = LatLng[0]; Lng = LatLng[1];
|
358
|
+
}
|
359
|
+
|
360
|
+
var myLatLng = new google.maps.LatLng(Lat, Lng);
|
345
361
|
this.extend_bounds(myLatLng);
|
346
362
|
|
347
363
|
// Marker sizes are expressed as a Size of X,Y
|
@@ -354,7 +370,7 @@ var Gmaps4Rails = {
|
|
354
370
|
}
|
355
371
|
//save object for later use, basically, to get back the text to display when clicking it
|
356
372
|
this.markers[i].marker_object = ThisMarker;
|
357
|
-
//save the marker
|
373
|
+
//save the marker in a list
|
358
374
|
marker_objects.push(ThisMarker);
|
359
375
|
//add click listener
|
360
376
|
google.maps.event.addListener(Gmaps4Rails.markers[i].marker_object, 'click', function() { if (Gmaps4Rails.info_window!=null) {Gmaps4Rails.info_window.close();}; Gmaps4Rails.getInfoWindow(this);});
|
@@ -399,7 +415,21 @@ var Gmaps4Rails = {
|
|
399
415
|
//basic function to check existence of a variable
|
400
416
|
exists: function(var_name) {
|
401
417
|
return var_name != "" && typeof var_name !== "undefined"
|
402
|
-
}
|
418
|
+
},
|
419
|
+
|
420
|
+
//randomize
|
421
|
+
randomize: function(Lat0, Lng0) {
|
422
|
+
//distance in meters between 0 and max_random_distance (positive or negative)
|
423
|
+
var dx = this.markers_conf.max_random_distance * this.random();
|
424
|
+
var dy = this.markers_conf.max_random_distance * this.random();
|
425
|
+
var Lat = parseFloat(Lat0) + (180/Math.PI)*(dy/6378137);
|
426
|
+
var Lng = parseFloat(Lng0) + ( 90/Math.PI)*(dx/6378137)/Math.cos(Lat0);
|
427
|
+
return [Lat, Lng];
|
428
|
+
},
|
429
|
+
|
430
|
+
//retrives a value between -1 and 1
|
431
|
+
random: function() { return ( Math.random() * 2 -1); }
|
432
|
+
|
403
433
|
};
|
404
434
|
|
405
435
|
//marker_clusterer styles
|
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: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 2
|
10
|
+
version: 0.6.2
|
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-03-
|
19
|
+
date: 2011-03-19 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -40,6 +40,7 @@ executables: []
|
|
40
40
|
extensions: []
|
41
41
|
|
42
42
|
extra_rdoc_files:
|
43
|
+
- LICENSE.txt
|
43
44
|
- README.rdoc
|
44
45
|
files:
|
45
46
|
- app/controllers/gmaps4rails/gmaps_controller.rb
|
@@ -60,6 +61,7 @@ files:
|
|
60
61
|
- public/images/marker.png
|
61
62
|
- public/javascripts/gmaps4rails.js
|
62
63
|
- public/stylesheets/gmaps4rails.css
|
64
|
+
- LICENSE.txt
|
63
65
|
- README.rdoc
|
64
66
|
- test/dummy/app/controllers/application_controller.rb
|
65
67
|
- test/dummy/app/controllers/users_controller.rb
|