gmaps4rails 1.4.8 → 1.5.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +11 -0
- data/.travis.yml +10 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +175 -0
- data/Guardfile +38 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +26 -37
- data/Rakefile +4 -0
- data/app/assets/javascripts/gmaps4rails/gmaps4rails.base.js.coffee +40 -34
- data/app/assets/javascripts/gmaps4rails/gmaps4rails.googlemaps.js.coffee +4 -2
- data/app/views/gmaps4rails/_gmaps4rails.html.erb +13 -12
- data/gmaps4rails.gemspec +38 -0
- data/lib/gmaps4rails.rb +0 -8
- data/lib/gmaps4rails/acts_as_gmappable.rb +55 -33
- data/lib/gmaps4rails/base.rb +7 -12
- data/lib/gmaps4rails/helper/gmaps4rails_helper.rb +16 -42
- data/lib/gmaps4rails/js_builder.rb +121 -0
- data/lib/gmaps4rails/json_builder.rb +127 -0
- data/lib/gmaps4rails/version.rb +3 -0
- data/lib/gmaps4rails/view_helper.rb +171 -0
- data/lib/tasks/gmaps4rails_tasks.rake +4 -0
- data/lib/tasks/jasmine.rake +8 -0
- data/public/javascripts/gmaps4rails/gmaps4rails.base.js +81 -30
- data/public/javascripts/gmaps4rails/gmaps4rails.bing.js +34 -11
- data/public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js +45 -21
- data/public/javascripts/gmaps4rails/gmaps4rails.mapquest.js +33 -14
- data/public/javascripts/gmaps4rails/gmaps4rails.openlayers.js +33 -20
- data/spec/base/base_spec.rb +185 -0
- data/spec/base/geocoding_spec.rb +17 -0
- data/spec/dummy/.gitignore +2 -0
- data/spec/dummy/.rspec +1 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/assets/stylesheets/gmaps4rails.css +24 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/users_controller.rb +96 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/user.rb +9 -0
- data/spec/dummy/app/views/layouts/application.html.erb +16 -0
- data/spec/dummy/app/views/users/_form.html.erb +37 -0
- data/spec/dummy/app/views/users/_my_template.html.erb +2 -0
- data/spec/dummy/app/views/users/_my_template2.html.erb +1 -0
- data/spec/dummy/app/views/users/ajax_data.js.erb +2 -0
- data/spec/dummy/app/views/users/ajax_test.html.erb +22 -0
- data/spec/dummy/app/views/users/edit.html.erb +6 -0
- data/spec/dummy/app/views/users/index.html.erb +238 -0
- data/spec/dummy/app/views/users/new.html.erb +5 -0
- data/spec/dummy/app/views/users/show.html.erb +30 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +62 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +60 -0
- data/spec/dummy/db/migrate/20120408170155_create_users.rb +16 -0
- data/spec/dummy/db/schema.rb +29 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/Player.js +22 -0
- data/spec/dummy/public/javascripts/Song.js +7 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/user_factory.rb +23 -0
- data/spec/javascripts/basic_methods_spec.js +103 -0
- data/spec/javascripts/helpers/.gitkeep +0 -0
- data/spec/javascripts/helpers/SpecHelper.js +87 -0
- data/spec/javascripts/map_spec.js +49 -0
- data/spec/javascripts/markers_methods_spec.js +368 -0
- data/spec/javascripts/mocks_spec.js +27 -0
- data/spec/javascripts/support/jasmine.yml +76 -0
- data/spec/javascripts/support/jasmine_config.rb +23 -0
- data/spec/javascripts/support/jasmine_runner.rb +20 -0
- data/spec/launchers/all_but_requests.rb +0 -0
- data/spec/launchers/all_specs.rb +0 -0
- data/spec/launchers/requests.rb +0 -0
- data/spec/models/user_spec.rb +447 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/support/geocoding.rb +14 -0
- data/spec/support/matchers.rb +43 -0
- metadata +364 -31
- data/LICENSE.txt +0 -21
- data/app/assets/javascripts/gmaps4rails/all_apis.js +0 -5
- data/app/assets/javascripts/gmaps4rails/bing.js +0 -2
- data/app/assets/javascripts/gmaps4rails/googlemaps.js +0 -2
- data/app/assets/javascripts/gmaps4rails/mapquest.js +0 -2
- data/app/assets/javascripts/gmaps4rails/openlayers.js +0 -2
- data/app/views/gmaps4rails/_html.html.erb +0 -12
- data/app/views/gmaps4rails/_scripts.html.erb +0 -37
- data/lib/gmaps4rails/js_handler.rb +0 -112
- data/lib/gmaps4rails/json_handler.rb +0 -116
- data/public/images/marker.png +0 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
source "http://rubygems.org"
|
|
2
|
+
|
|
3
|
+
# Declare your gem's dependencies in gmaps4rails.gemspec.
|
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
|
5
|
+
# development dependencies will be added by default to the :development group.
|
|
6
|
+
|
|
7
|
+
gemspec
|
|
8
|
+
|
|
9
|
+
gem 'growl'
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
gmaps4rails (1.5.0.pre)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: http://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
actionmailer (3.2.3)
|
|
10
|
+
actionpack (= 3.2.3)
|
|
11
|
+
mail (~> 2.4.4)
|
|
12
|
+
actionpack (3.2.3)
|
|
13
|
+
activemodel (= 3.2.3)
|
|
14
|
+
activesupport (= 3.2.3)
|
|
15
|
+
builder (~> 3.0.0)
|
|
16
|
+
erubis (~> 2.7.0)
|
|
17
|
+
journey (~> 1.0.1)
|
|
18
|
+
rack (~> 1.4.0)
|
|
19
|
+
rack-cache (~> 1.2)
|
|
20
|
+
rack-test (~> 0.6.1)
|
|
21
|
+
sprockets (~> 2.1.2)
|
|
22
|
+
activemodel (3.2.3)
|
|
23
|
+
activesupport (= 3.2.3)
|
|
24
|
+
builder (~> 3.0.0)
|
|
25
|
+
activerecord (3.2.3)
|
|
26
|
+
activemodel (= 3.2.3)
|
|
27
|
+
activesupport (= 3.2.3)
|
|
28
|
+
arel (~> 3.0.2)
|
|
29
|
+
tzinfo (~> 0.3.29)
|
|
30
|
+
activeresource (3.2.3)
|
|
31
|
+
activemodel (= 3.2.3)
|
|
32
|
+
activesupport (= 3.2.3)
|
|
33
|
+
activesupport (3.2.3)
|
|
34
|
+
i18n (~> 0.6)
|
|
35
|
+
multi_json (~> 1.0)
|
|
36
|
+
arel (3.0.2)
|
|
37
|
+
builder (3.0.0)
|
|
38
|
+
childprocess (0.3.1)
|
|
39
|
+
ffi (~> 1.0.6)
|
|
40
|
+
coderay (1.0.6)
|
|
41
|
+
coffee-script (2.2.0)
|
|
42
|
+
coffee-script-source
|
|
43
|
+
execjs
|
|
44
|
+
coffee-script-source (1.2.0)
|
|
45
|
+
database_cleaner (0.7.2)
|
|
46
|
+
diff-lcs (1.1.3)
|
|
47
|
+
erubis (2.7.0)
|
|
48
|
+
execjs (1.3.0)
|
|
49
|
+
multi_json (~> 1.0)
|
|
50
|
+
factory_girl (2.6.1)
|
|
51
|
+
activesupport (>= 2.3.9)
|
|
52
|
+
factory_girl_rails (1.7.0)
|
|
53
|
+
factory_girl (~> 2.6.0)
|
|
54
|
+
railties (>= 3.0.0)
|
|
55
|
+
ffi (1.0.11)
|
|
56
|
+
growl (1.0.3)
|
|
57
|
+
guard (1.0.1)
|
|
58
|
+
ffi (>= 0.5.0)
|
|
59
|
+
thor (~> 0.14.6)
|
|
60
|
+
guard-coffeescript (0.5.7)
|
|
61
|
+
coffee-script (>= 2.2.0)
|
|
62
|
+
guard (>= 0.8.3)
|
|
63
|
+
guard-jasmine (1.1.0)
|
|
64
|
+
childprocess
|
|
65
|
+
guard (>= 0.8.3)
|
|
66
|
+
multi_json
|
|
67
|
+
thor
|
|
68
|
+
guard-rspec (0.5.11)
|
|
69
|
+
guard (>= 0.8.4)
|
|
70
|
+
guard-spork (0.4.1)
|
|
71
|
+
guard (>= 0.8.4)
|
|
72
|
+
spork (>= 0.8.4)
|
|
73
|
+
hike (1.2.1)
|
|
74
|
+
i18n (0.6.0)
|
|
75
|
+
jasmine (1.1.2)
|
|
76
|
+
jasmine-core (>= 1.1.0)
|
|
77
|
+
rack (>= 1.1)
|
|
78
|
+
rspec (>= 1.3.1)
|
|
79
|
+
selenium-webdriver (>= 0.1.3)
|
|
80
|
+
jasmine-core (1.1.0)
|
|
81
|
+
journey (1.0.3)
|
|
82
|
+
jquery-rails (2.0.2)
|
|
83
|
+
railties (>= 3.2.0, < 5.0)
|
|
84
|
+
thor (~> 0.14)
|
|
85
|
+
json (1.6.6)
|
|
86
|
+
json_pure (1.6.5)
|
|
87
|
+
mail (2.4.4)
|
|
88
|
+
i18n (>= 0.4.0)
|
|
89
|
+
mime-types (~> 1.16)
|
|
90
|
+
treetop (~> 1.4.8)
|
|
91
|
+
method_source (0.7.1)
|
|
92
|
+
mime-types (1.18)
|
|
93
|
+
multi_json (1.2.0)
|
|
94
|
+
polyglot (0.3.3)
|
|
95
|
+
pry (0.9.8.4)
|
|
96
|
+
coderay (~> 1.0.5)
|
|
97
|
+
method_source (~> 0.7.1)
|
|
98
|
+
slop (>= 2.4.4, < 3)
|
|
99
|
+
rack (1.4.1)
|
|
100
|
+
rack-cache (1.2)
|
|
101
|
+
rack (>= 0.4)
|
|
102
|
+
rack-ssl (1.3.2)
|
|
103
|
+
rack
|
|
104
|
+
rack-test (0.6.1)
|
|
105
|
+
rack (>= 1.0)
|
|
106
|
+
rails (3.2.3)
|
|
107
|
+
actionmailer (= 3.2.3)
|
|
108
|
+
actionpack (= 3.2.3)
|
|
109
|
+
activerecord (= 3.2.3)
|
|
110
|
+
activeresource (= 3.2.3)
|
|
111
|
+
activesupport (= 3.2.3)
|
|
112
|
+
bundler (~> 1.0)
|
|
113
|
+
railties (= 3.2.3)
|
|
114
|
+
railties (3.2.3)
|
|
115
|
+
actionpack (= 3.2.3)
|
|
116
|
+
activesupport (= 3.2.3)
|
|
117
|
+
rack-ssl (~> 1.3.2)
|
|
118
|
+
rake (>= 0.8.7)
|
|
119
|
+
rdoc (~> 3.4)
|
|
120
|
+
thor (~> 0.14.6)
|
|
121
|
+
rake (0.9.2.2)
|
|
122
|
+
rdoc (3.12)
|
|
123
|
+
json (~> 1.4)
|
|
124
|
+
rspec (2.8.0)
|
|
125
|
+
rspec-core (~> 2.8.0)
|
|
126
|
+
rspec-expectations (~> 2.8.0)
|
|
127
|
+
rspec-mocks (~> 2.8.0)
|
|
128
|
+
rspec-core (2.8.0)
|
|
129
|
+
rspec-expectations (2.8.0)
|
|
130
|
+
diff-lcs (~> 1.1.2)
|
|
131
|
+
rspec-mocks (2.8.0)
|
|
132
|
+
rspec-rails (2.8.1)
|
|
133
|
+
actionpack (>= 3.0)
|
|
134
|
+
activesupport (>= 3.0)
|
|
135
|
+
railties (>= 3.0)
|
|
136
|
+
rspec (~> 2.8.0)
|
|
137
|
+
rubyzip (0.9.6.1)
|
|
138
|
+
selenium-webdriver (2.5.0)
|
|
139
|
+
childprocess (>= 0.2.1)
|
|
140
|
+
ffi (>= 1.0.7)
|
|
141
|
+
json_pure
|
|
142
|
+
rubyzip
|
|
143
|
+
slop (2.4.4)
|
|
144
|
+
spork (1.0.0rc2)
|
|
145
|
+
sprockets (2.1.2)
|
|
146
|
+
hike (~> 1.2)
|
|
147
|
+
rack (~> 1.0)
|
|
148
|
+
tilt (~> 1.1, != 1.3.0)
|
|
149
|
+
sqlite3 (1.3.5)
|
|
150
|
+
thor (0.14.6)
|
|
151
|
+
tilt (1.3.3)
|
|
152
|
+
treetop (1.4.10)
|
|
153
|
+
polyglot
|
|
154
|
+
polyglot (>= 0.3.1)
|
|
155
|
+
tzinfo (0.3.32)
|
|
156
|
+
|
|
157
|
+
PLATFORMS
|
|
158
|
+
ruby
|
|
159
|
+
|
|
160
|
+
DEPENDENCIES
|
|
161
|
+
database_cleaner
|
|
162
|
+
factory_girl_rails
|
|
163
|
+
gmaps4rails!
|
|
164
|
+
growl
|
|
165
|
+
guard (~> 1.0.1)
|
|
166
|
+
guard-coffeescript
|
|
167
|
+
guard-jasmine
|
|
168
|
+
guard-rspec
|
|
169
|
+
guard-spork
|
|
170
|
+
jasmine
|
|
171
|
+
jquery-rails
|
|
172
|
+
pry
|
|
173
|
+
rails (~> 3.2.1)
|
|
174
|
+
rspec-rails
|
|
175
|
+
sqlite3
|
data/Guardfile
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# A sample Guardfile
|
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
|
3
|
+
|
|
4
|
+
guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' } do
|
|
5
|
+
watch('config/application.rb')
|
|
6
|
+
watch('config/environment.rb')
|
|
7
|
+
watch(%r{^config/environments/.+\.rb$})
|
|
8
|
+
watch(%r{^config/initializers/.+\.rb$})
|
|
9
|
+
watch('Gemfile')
|
|
10
|
+
watch('Gemfile.lock')
|
|
11
|
+
watch('spec/spec_helper.rb') { :rspec }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
guard 'rspec', :cli => "-c -f d", :all_on_start => false, :all_after_pass => false do
|
|
16
|
+
watch(%r{^spec/.+_spec\.rb$})
|
|
17
|
+
watch('spec/launchers/all_specs.rb') { "spec" }
|
|
18
|
+
watch('spec/launchers/all_but_requests.rb') { ["spec/base", "spec/helpers", "spec/models", "spec/views"] }
|
|
19
|
+
watch('spec/launchers/requests.rb') { "spec/requests" }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
guard 'jasmine', :jasmine_url => 'http://localhost:8888/', :all_on_start => false, :all_after_pass => false do
|
|
23
|
+
watch(%r{spec/javascripts/spec\.(js\.coffee|js|coffee)$}) { "spec/javascripts" }
|
|
24
|
+
watch(%r{^spec/javascripts/.+_spec\.(js\.coffee|js|coffee)$}) { "spec/javascripts" }
|
|
25
|
+
watch(%r{^spec/javascripts/.+_spec\.js$}) { "spec/javascripts" }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
#--drb
|
|
30
|
+
|
|
31
|
+
guard 'coffeescript', :input => 'app/assets/javascripts/gmaps4rails', :output => 'public/javascripts/gmaps4rails'
|
|
32
|
+
|
|
33
|
+
#
|
|
34
|
+
#guard 'coffeescript', :input => 'spec/javascripts/coffee', :output => 'spec/javascripts'
|
|
35
|
+
|
|
36
|
+
# do
|
|
37
|
+
# watch(/^app\/assets\/javascripts\/gmaps4rails\/(.*).coffee/)
|
|
38
|
+
# end
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2012 Benjamin Roth
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
== Google Maps for Rails (gmaps4rails)
|
|
1
|
+
== Google Maps for Rails (gmaps4rails) {<img src="https://secure.travis-ci.org/apneadiving/Google-Maps-for-Rails.png?branch=master" alt="Build Status" />}[http://travis-ci.org/apneadiving/Google-Maps-for-Rails]
|
|
2
2
|
|
|
3
3
|
Gmaps4rails is developed to simply create a Google Map:
|
|
4
4
|
|
|
@@ -12,54 +12,43 @@ See (somewhat outdated) screencasts here: http://www.youtube.com/user/TheApneadi
|
|
|
12
12
|
|
|
13
13
|
== When Gmaps4rails finally means Global Maps for Rails
|
|
14
14
|
|
|
15
|
-
I've added support for other map providers:
|
|
16
|
-
|
|
17
|
-
* openlayers
|
|
18
|
-
|
|
19
|
-
* mapquest
|
|
20
|
-
|
|
21
|
-
* bing
|
|
15
|
+
I've added support for other map providers: openlayers, mapquest & bing.
|
|
22
16
|
|
|
23
17
|
See: https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Map-Apis
|
|
24
18
|
|
|
25
19
|
Any help would be appreciated to complete this work.
|
|
26
20
|
|
|
27
|
-
|
|
28
21
|
== Requirements
|
|
29
22
|
|
|
30
|
-
Gemfile
|
|
23
|
+
1) Gemfile
|
|
24
|
+
|
|
31
25
|
gem 'gmaps4rails'
|
|
32
|
-
(followed by 'bundle')
|
|
33
26
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<%= yield :scripts %> (in your footer)
|
|
27
|
+
2) Copy the assets to your app (and be sure to copy the fresh assets when you upgrade the gem):
|
|
37
28
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* //= require gmaps4rails/mapquest.js
|
|
46
|
-
|
|
47
|
-
* //= require gmaps4rails/openlayers.js
|
|
48
|
-
|
|
49
|
-
* //= require gmaps4rails/all_apis.js
|
|
50
|
-
|
|
51
|
-
Stylesheet:
|
|
52
|
-
|
|
53
|
-
* `require gmaps4rails` (if you use the default)
|
|
29
|
+
rails generate gmaps4rails:install
|
|
30
|
+
|
|
31
|
+
This will copy all the coffeescript files if you're running Rails >= 3.1 or all the js files for Rails 3.0.x.
|
|
32
|
+
|
|
33
|
+
Only `gmaps4rails.base` + `gmaps4rails.your_provider` are necessary.
|
|
34
|
+
|
|
35
|
+
3) Javascript
|
|
54
36
|
|
|
55
|
-
|
|
56
|
-
see paragraph below to be sure everything will work in production.
|
|
37
|
+
<%= yield :scripts %> (in your footer)
|
|
57
38
|
|
|
58
|
-
|
|
39
|
+
This container will include the js files from map providers, the custom js to display the map, the gem's js code.
|
|
40
|
+
|
|
41
|
+
4) CSS
|
|
42
|
+
|
|
43
|
+
`gmaps4rails.css` will be copied to your app after you run the Rails generator.
|
|
44
|
+
Be sure to require this file in your view for your first steps.
|
|
45
|
+
|
|
46
|
+
For Rails 3.0.x or without assets pipeline:
|
|
47
|
+
|
|
48
|
+
<%= stylesheet_link_tag 'gmaps4rails' %>
|
|
49
|
+
|
|
50
|
+
For Rails >= 3.1 with assets pipeline, same principle: add the required file to your manifest.
|
|
59
51
|
|
|
60
|
-
rails generate gmaps4rails:install
|
|
61
|
-
|
|
62
|
-
This will copy the coffeescript files if you're running Rails 3.1 or the js files for Rails 3.0.x
|
|
63
52
|
|
|
64
53
|
== Basic configuration
|
|
65
54
|
In your model, add:
|
|
@@ -73,7 +62,7 @@ In your model, add:
|
|
|
73
62
|
|
|
74
63
|
Create a migration and add the following fields to your table (here users):
|
|
75
64
|
|
|
76
|
-
add_column :users, :latitude,
|
|
65
|
+
add_column :users, :latitude, :float #you can change the name, see wiki
|
|
77
66
|
add_column :users, :longitude, :float #you can change the name, see wiki
|
|
78
67
|
add_column :users, :gmaps, :boolean #not mandatory, see wiki
|
|
79
68
|
|
data/Rakefile
ADDED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
Gmaps = {}
|
|
2
2
|
|
|
3
|
+
Gmaps.triggerOldOnload = ->
|
|
4
|
+
Gmaps.oldOnload() if typeof(Gmaps.oldOnload) == 'function'
|
|
5
|
+
|
|
3
6
|
Gmaps.loadMaps = ->
|
|
4
7
|
#loop through all variable names.
|
|
5
8
|
#there should only be maps inside so it trigger their load function
|
|
@@ -207,7 +210,8 @@ class @Gmaps4Rails
|
|
|
207
210
|
strokeWeight = point.strokeWeight || @polygons_conf.strokeWeight
|
|
208
211
|
fillColor = point.fillColor || @polygons_conf.fillColor
|
|
209
212
|
fillOpacity = point.fillOpacity || @polygons_conf.fillOpacity
|
|
210
|
-
|
|
213
|
+
clickable = point.clickable || @polygons_conf.clickable
|
|
214
|
+
|
|
211
215
|
#Construct the polygon
|
|
212
216
|
new_poly = new google.maps.Polygon
|
|
213
217
|
paths: polygon_coordinates
|
|
@@ -216,7 +220,7 @@ class @Gmaps4Rails
|
|
|
216
220
|
strokeWeight: strokeWeight
|
|
217
221
|
fillColor: fillColor
|
|
218
222
|
fillOpacity: fillOpacity
|
|
219
|
-
clickable:
|
|
223
|
+
clickable: clickable
|
|
220
224
|
map: @map
|
|
221
225
|
|
|
222
226
|
#save polygon in list
|
|
@@ -302,38 +306,40 @@ class @Gmaps4Rails
|
|
|
302
306
|
#create google.maps Markers from data provided by user
|
|
303
307
|
createServiceMarkersFromMarkers : ->
|
|
304
308
|
for marker, index in @markers
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
309
|
+
if not @markers[index].serviceObject?
|
|
310
|
+
#extract options, test if value passed or use default
|
|
311
|
+
Lat = @markers[index].lat
|
|
312
|
+
Lng = @markers[index].lng
|
|
313
|
+
|
|
314
|
+
#alter coordinates if randomize is true
|
|
315
|
+
if @markers_conf.randomize
|
|
316
|
+
LatLng = @randomize(Lat, Lng)
|
|
317
|
+
#retrieve coordinates from the array
|
|
318
|
+
Lat = LatLng[0]
|
|
319
|
+
Lng = LatLng[1]
|
|
320
|
+
|
|
321
|
+
#save object
|
|
322
|
+
@markers[index].serviceObject = @createMarker
|
|
323
|
+
"marker_picture": if @markers[index].picture then @markers[index].picture else @markers_conf.picture
|
|
324
|
+
"marker_width": if @markers[index].width then @markers[index].width else @markers_conf.width
|
|
325
|
+
"marker_height": if @markers[index].height then @markers[index].height else @markers_conf.length
|
|
326
|
+
"marker_title": if @markers[index].title then @markers[index].title else null
|
|
327
|
+
"marker_anchor": if @markers[index].marker_anchor then @markers[index].marker_anchor else null
|
|
328
|
+
"shadow_anchor": if @markers[index].shadow_anchor then @markers[index].shadow_anchor else null
|
|
329
|
+
"shadow_picture": if @markers[index].shadow_picture then @markers[index].shadow_picture else null
|
|
330
|
+
"shadow_width": if @markers[index].shadow_width then @markers[index].shadow_width else null
|
|
331
|
+
"shadow_height": if @markers[index].shadow_height then @markers[index].shadow_height else null
|
|
332
|
+
"marker_draggable": if @markers[index].draggable then @markers[index].draggable else @markers_conf.draggable
|
|
333
|
+
"rich_marker": if @markers[index].rich_marker then @markers[index].rich_marker else null
|
|
334
|
+
"zindex": if @markers[index].zindex then @markers[index].zindex else null
|
|
335
|
+
"Lat": Lat
|
|
336
|
+
"Lng": Lng
|
|
337
|
+
"index": index
|
|
338
|
+
|
|
339
|
+
#add infowindowstuff if enabled
|
|
340
|
+
@createInfoWindow(@markers[index])
|
|
341
|
+
#create sidebar if enabled
|
|
342
|
+
@createSidebar(@markers[index])
|
|
337
343
|
|
|
338
344
|
@markers_conf.offset = @markers.length
|
|
339
345
|
|