gmaps4rails 1.3.0 → 1.3.1
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/README.rdoc
CHANGED
@@ -26,64 +26,66 @@ Any help would be appreciated to complete this work.
|
|
26
26
|
|
27
27
|
|
28
28
|
== Requirements
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
|
30
|
+
Gemfile
|
31
|
+
gem 'gmaps4rails'
|
32
|
+
(followed by 'bundle')
|
33
|
+
|
34
|
+
<%= yield :head %> (in your header, Rails 3.0.x only)
|
35
|
+
|
36
|
+
<%= yield :scripts %> (in your footer)
|
32
37
|
|
33
38
|
To make Rails serve the assets (javascripts, stylesheets and marker images) you have several options, depending on your configuration and Rails version:
|
34
39
|
- if you are using Rails 3.1 and have asset pipeline enabled ('config.assets.enabled = true' in config/application.rb), include the appropriate manifest:
|
35
40
|
|
36
|
-
|
41
|
+
* //= require gmaps4rails/bing.js
|
37
42
|
|
38
|
-
|
43
|
+
* //= require gmaps4rails/googlemaps.js
|
39
44
|
|
40
|
-
|
45
|
+
* //= require gmaps4rails/mapquest.js
|
41
46
|
|
42
|
-
|
47
|
+
* //= require gmaps4rails/openlayers.js
|
43
48
|
|
44
|
-
|
49
|
+
* //= require gmaps4rails/all_apis.js
|
45
50
|
|
46
51
|
Stylesheet:
|
47
52
|
|
48
|
-
|
53
|
+
* `require gmaps4rails` (if you use the default)
|
49
54
|
|
50
55
|
- if you are using Rails 3.0:
|
51
|
-
see
|
56
|
+
see paragraph below to be sure everything will work in production.
|
52
57
|
|
53
58
|
- finally you can just copy assets to your application's public/stylesheets, public/javascripts/gmaps4rails and public/images. It's recommended to do this in production so that you can let your webserver serve them rather than go through Rails each time they are requested. There's a generator to help you with that:
|
54
59
|
|
55
|
-
|
60
|
+
rails generate gmaps4rails:install
|
56
61
|
|
57
62
|
This will copy the coffeescript files if you're running Rails 3.1 or the js files for Rails 3.0.x
|
58
63
|
|
59
64
|
== Basic configuration
|
60
65
|
In your model, add:
|
61
66
|
|
67
|
+
acts_as_gmappable
|
62
68
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
"#{self.street}, #{self.city}, #{self.country}"
|
68
|
-
end
|
69
|
+
def gmaps4rails_address
|
70
|
+
#describe how to retrieve the address from your model, if you use directly a db column, you can dry your code, see wiki
|
71
|
+
"#{self.street}, #{self.city}, #{self.country}"
|
72
|
+
end
|
69
73
|
|
70
74
|
Create a migration and add the following fields to your table (here users):
|
71
75
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
add_column :users, :gmaps, :boolean #not mandatory, see wiki
|
76
|
-
|
76
|
+
add_column :users, :latitude, :float #you can change the name, see wiki
|
77
|
+
add_column :users, :longitude, :float #you can change the name, see wiki
|
78
|
+
add_column :users, :gmaps, :boolean #not mandatory, see wiki
|
77
79
|
|
78
80
|
== How to?
|
79
81
|
=== QuickStart!
|
80
82
|
In your controller:
|
81
83
|
|
82
|
-
|
84
|
+
@json = User.all.to_gmaps4rails
|
83
85
|
|
84
86
|
In your view:
|
85
87
|
|
86
|
-
|
88
|
+
<%= gmaps4rails(@json) %>
|
87
89
|
|
88
90
|
Done!
|
89
91
|
|
@@ -35,8 +35,8 @@ module Gmaps4rails
|
|
35
35
|
|
36
36
|
def to_gmaps4rails(&block)
|
37
37
|
json = "["
|
38
|
-
json
|
39
|
-
json
|
38
|
+
json << Gmaps4rails.create_json(self, &block).to_s.chop.chop #removes the extra comma
|
39
|
+
json << "]"
|
40
40
|
end
|
41
41
|
|
42
42
|
end
|
data/lib/gmaps4rails/base.rb
CHANGED
@@ -31,7 +31,7 @@ module Gmaps4rails
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def Gmaps4rails.json(string)
|
34
|
-
@json_from_block
|
34
|
+
@json_from_block << "#{gsub_string(string)}, "
|
35
35
|
return true
|
36
36
|
end
|
37
37
|
|
@@ -43,7 +43,7 @@ module Gmaps4rails
|
|
43
43
|
|
44
44
|
# in use in block
|
45
45
|
def Gmaps4rails.picture(hash)
|
46
|
-
@json_from_block
|
46
|
+
@json_from_block << (create_js_for_picture hash)
|
47
47
|
return true
|
48
48
|
end
|
49
49
|
|
@@ -62,7 +62,7 @@ module Gmaps4rails
|
|
62
62
|
##################################################
|
63
63
|
# in use in block
|
64
64
|
def Gmaps4rails.infowindow(string)
|
65
|
-
@json_from_block
|
65
|
+
@json_from_block << (create_js_for_infowindow string)
|
66
66
|
return true
|
67
67
|
end
|
68
68
|
|
@@ -4,9 +4,9 @@ class Array
|
|
4
4
|
def to_gmaps4rails(&block)
|
5
5
|
json = "["
|
6
6
|
each do |object|
|
7
|
-
json
|
7
|
+
json << Gmaps4rails.create_json(object, &block).to_s
|
8
8
|
end
|
9
9
|
json.chop!.chop! unless json == "["
|
10
|
-
json
|
10
|
+
json << "]"
|
11
11
|
end
|
12
12
|
end
|
@@ -4,8 +4,8 @@ module Gmaps4railsHelper
|
|
4
4
|
|
5
5
|
def gmaps4rails(builder, enable_css = true, enable_js = true )
|
6
6
|
options = {
|
7
|
-
|
8
|
-
|
7
|
+
:map_options => { :auto_adjust => true},
|
8
|
+
:markers => { :data => builder, :options => {:do_clustering => true} }
|
9
9
|
}
|
10
10
|
render :partial => 'gmaps4rails/gmaps4rails', :locals => { :options => options, :enable_css => enable_css, :enable_js => enable_js }
|
11
11
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmaps4rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-10-
|
13
|
+
date: 2011-10-21 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: crack
|
17
|
-
requirement: &
|
17
|
+
requirement: &2152935520 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2152935520
|
26
26
|
description: ! 'Enables easy display of items (taken from a Rails 3 model) on a Google
|
27
27
|
Maps (JS API V3), OpenLayers, Mapquest and Bing. Geocoding + Directions included.
|
28
28
|
Provides much options: markers customization, infowindows, auto-adjusted zoom, polylines,
|