gmaps4rails 0.0.14 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +61 -15
- metadata +5 -5
data/README.rdoc
CHANGED
@@ -1,22 +1,20 @@
|
|
1
1
|
== Gmaps4rails
|
2
2
|
|
3
|
-
|
4
|
-
It's
|
5
|
-
|
6
|
-
Gmaps4rails is developed to simply create a map with model instances (say Users).
|
7
|
-
|
3
|
+
Gmaps4rails is developped to simply create a map with model instances (say Users).
|
4
|
+
It's based on Rails 3 Engines.
|
5
|
+
It works properly but I still have something to correct: making it work without resorting to the serve_static_assets to true in production.
|
8
6
|
|
9
7
|
== Installation
|
10
8
|
|
11
9
|
gem install gmaps4rails
|
12
10
|
|
13
11
|
== Requirements
|
14
|
-
- jQuery (for ajax json)
|
12
|
+
- jQuery (used for ajax json)
|
15
13
|
- <%= yield :head %> in your header
|
14
|
+
- config.serve_static_assets = true (in your production.rb)
|
16
15
|
|
17
|
-
==
|
18
|
-
|
19
|
-
=== In your model
|
16
|
+
== Quickstart
|
17
|
+
In your model
|
20
18
|
acts_as_gmappable
|
21
19
|
|
22
20
|
def gmaps4rails_address
|
@@ -28,23 +26,71 @@ Gmaps4rails is developed to simply create a map with model instances (say Users)
|
|
28
26
|
end
|
29
27
|
|
30
28
|
def gmaps4rails_description
|
31
|
-
self.name #could be html
|
29
|
+
self.name #could be html it's rendered when user clicks on the markers on the map
|
32
30
|
end
|
33
31
|
|
34
|
-
|
32
|
+
Create a migration and add the following fields to your table:
|
35
33
|
t.string "gmaps4rails_latitude"
|
36
34
|
t.string "gmaps4rails_longitude"
|
37
35
|
t.boolean "gmaps"
|
38
36
|
|
39
|
-
|
37
|
+
In your view
|
40
38
|
<%= render :partial => 'gmaps4rails/gmaps4rails', :locals => { :model => "User"} %>
|
41
39
|
|
40
|
+
|
41
|
+
== Options
|
42
|
+
|
43
|
+
=== Setting Map Center
|
44
|
+
<%= render :partial => 'gmaps4rails/gmaps4rails', :locals => { :model => "User", :ref_latitude => 0 , :ref_longitude => 0 } %>
|
45
|
+
|
46
|
+
=== Scopes (displays a dropdown list enabling you to filter the map content)
|
47
|
+
In your model:
|
48
|
+
# Whatever scope you want
|
49
|
+
scope :low_height, lambda {|height|
|
50
|
+
where("users.height <= ?", height)
|
51
|
+
}
|
52
|
+
scope :high_height, lambda {|height|
|
53
|
+
where("users.height >= ?", height)
|
54
|
+
}
|
55
|
+
|
56
|
+
# method to fill in the dropdown list: provide scope argument, variable to pass to it, and text you want to display
|
57
|
+
def self.gmaps4rails_filters
|
58
|
+
[
|
59
|
+
{"filter" => "All", "options" => "", "display" => "All"},
|
60
|
+
{"filter" => "low", "options" => "130", "display" => "People Under 130cm"},
|
61
|
+
{"filter" => "low", "options" => "100", "display" => "People Under 100cm"},
|
62
|
+
{"filter" => "high", "options" =>"190", "display" => "People Above 190cm"},
|
63
|
+
{"filter" => "high", "options" =>"200", "display" => "People Above 200cm"}
|
64
|
+
]
|
65
|
+
end
|
66
|
+
|
67
|
+
# method to filter your requests given the parameters you provided above
|
68
|
+
def self.gmaps4rails_filter(filter, options)
|
69
|
+
case filter
|
70
|
+
when 'low' then self.low_height(options)
|
71
|
+
when 'high' then self.high_height(options)
|
72
|
+
else self.all
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
In your view:
|
77
|
+
<%=raw gmaps4rails_filters_display("User") %>
|
78
|
+
|
79
|
+
=== Styling your Marker
|
80
|
+
In your model, add the following:
|
81
|
+
|
82
|
+
def self.gmaps4rails_markers_pic
|
83
|
+
{ "picture" => "http://www.ci.burlington.vt.us/planning/images/google_maps_marker.png",
|
84
|
+
"width" => 22,
|
85
|
+
"length" => 32 }
|
86
|
+
end
|
87
|
+
|
42
88
|
== Todo
|
43
|
-
|
44
|
-
-
|
45
|
-
- integration of scopes to decide what you want to display precisely
|
89
|
+
Still much more customization to provide, some ideas:
|
90
|
+
- direct integration of scopes to decide what you want to display precisely
|
46
91
|
- distance filter
|
47
92
|
|
93
|
+
Feel free ton contact me, you have your say. I hope I'll have time enough to improve it.
|
48
94
|
== Copyright
|
49
95
|
|
50
96
|
Copyright (c) 2010 apneadiving. See LICENSE for details.
|
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: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.14
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Benjamin Roth
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: "0"
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
|
-
description:
|
35
|
+
description: Enables easy display of items (taken from a model) on a Google Map. Uses Javascript API V3.
|
36
36
|
email: apnea.diving.deep@gmail.com
|
37
37
|
executables: []
|
38
38
|
|
@@ -94,7 +94,7 @@ rubyforge_project:
|
|
94
94
|
rubygems_version: 1.3.7
|
95
95
|
signing_key:
|
96
96
|
specification_version: 3
|
97
|
-
summary:
|
97
|
+
summary: Enables easy display of items (taken from a model) on a Google Map. Uses Javascript API V3.
|
98
98
|
test_files:
|
99
99
|
- test/test_helper.rb
|
100
100
|
- test/unit/gmaps4rails_widget_test.rb
|