google_static_maps_helper 1.3.2 → 1.3.3
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 +6 -6
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/changelog.txt +4 -1
- data/google_static_maps_helper.gemspec +7 -7
- data/lib/google_static_maps_helper.rb +1 -0
- data/lib/google_static_maps_helper/location.rb +1 -0
- data/lib/google_static_maps_helper/map.rb +2 -1
- data/lib/google_static_maps_helper/marker.rb +1 -0
- data/lib/google_static_maps_helper/path.rb +1 -0
- data/spec/google_static_maps_helper_spec.rb +1 -0
- data/spec/location_spec.rb +1 -0
- data/spec/map_spec.rb +20 -14
- data/spec/marker_spec.rb +1 -0
- data/spec/path_spec.rb +14 -13
- data/spec/spec_helper.rb +1 -0
- metadata +5 -5
data/README.rdoc
CHANGED
|
@@ -84,7 +84,7 @@ With the map object made, we are ready to add some markers to it:
|
|
|
84
84
|
map << marker
|
|
85
85
|
map << another_marker << yet_another_marker << and_one_more_marker
|
|
86
86
|
|
|
87
|
-
We can now ask the map for it's URL to where we'll get the
|
|
87
|
+
We can now ask the map for it's URL to where we'll get the map from. This URL can be used as source attribute on an image tag.
|
|
88
88
|
map.url
|
|
89
89
|
|
|
90
90
|
Another thing you might want to do is to override the center point and zoom level. This is done during map construction
|
|
@@ -119,10 +119,10 @@ If you feel like it, you can add points at construction time:
|
|
|
119
119
|
|
|
120
120
|
|
|
121
121
|
== Locations
|
|
122
|
-
The location class is what we wrap all our lat- and lng values in. Either it is a Marker, or points for a Path
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
which returns locations that
|
|
122
|
+
The location class is what we wrap all our lat- and lng values in. Either it is a Marker, or points for a Path; it will store it's lng and lat value
|
|
123
|
+
in a Location object. Location objects have a few helper methods which you can use to calculate distance between
|
|
124
|
+
locations (<tt>distance_to(another_location)</tt>) and use to generate new locations based on distance and heading from current location (<tt>endpoint(distance, heading)</tt>).
|
|
125
|
+
It also have a helper method called <tt>endpoints_for_circle_with_radius</tt> which returns locations that makes up a circle around the receiving location. Some examples:
|
|
126
126
|
|
|
127
127
|
# Create a marker object, which it's lng and lat are stored under the hood as a location object.
|
|
128
128
|
# Methods which the marker itself cannot answer, like lat and lng and distance_to is delegated to the location object
|
|
@@ -137,7 +137,7 @@ which returns locations that make up a circle around the receiving location. Som
|
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
== TODO
|
|
140
|
-
*
|
|
140
|
+
* Add support for encoded polylines (http://code.google.com/apis/maps/documentation/staticmaps/#EncodedPolylines).
|
|
141
141
|
|
|
142
142
|
== Copyright
|
|
143
143
|
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.3.
|
|
1
|
+
1.3.3
|
data/changelog.txt
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
= v.1.3.
|
|
1
|
+
= v.1.3.3 (in git)
|
|
2
|
+
* We are now supporting ruby 1.9.1.
|
|
3
|
+
|
|
4
|
+
= v.1.3.2
|
|
2
5
|
* Location will now round and reduce numbers so it doesn't get above a precision of 6.
|
|
3
6
|
* Added two helper methods to Location: distance_to(another_location) and endpoint(distance, heading).
|
|
4
7
|
* a_location.endpoints_for_circle_with_radius(radius) returns an array of end points making a circle around location.
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{google_static_maps_helper}
|
|
8
|
-
s.version = "1.3.
|
|
8
|
+
s.version = "1.3.3"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Thorbj\303\270rn Hermansen"]
|
|
12
|
-
s.date = %q{2009-
|
|
12
|
+
s.date = %q{2009-12-01}
|
|
13
13
|
s.description = %q{This gem provides a simple interface to the Google Static Maps V2 API.}
|
|
14
14
|
s.email = %q{thhermansen@gmail.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -43,12 +43,12 @@ Gem::Specification.new do |s|
|
|
|
43
43
|
s.rubygems_version = %q{1.3.5}
|
|
44
44
|
s.summary = %q{This gem provides a simple interface to the Google Static Maps V2 API}
|
|
45
45
|
s.test_files = [
|
|
46
|
-
"spec/
|
|
47
|
-
"spec/marker_spec.rb",
|
|
48
|
-
"spec/google_static_maps_helper_spec.rb",
|
|
49
|
-
"spec/location_spec.rb",
|
|
46
|
+
"spec/marker_spec.rb",
|
|
50
47
|
"spec/map_spec.rb",
|
|
51
|
-
"spec/
|
|
48
|
+
"spec/spec_helper.rb",
|
|
49
|
+
"spec/location_spec.rb",
|
|
50
|
+
"spec/path_spec.rb",
|
|
51
|
+
"spec/google_static_maps_helper_spec.rb"
|
|
52
52
|
]
|
|
53
53
|
|
|
54
54
|
if s.respond_to? :specification_version then
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
1
2
|
module GoogleStaticMapsHelper
|
|
2
3
|
#
|
|
3
4
|
# The Map keeps track of the state of which we want to build a URL for.
|
|
@@ -35,7 +36,7 @@ module GoogleStaticMapsHelper
|
|
|
35
36
|
# <tt>:mobile</tt>:: Returns map tiles better suited for mobile devices with small screens.
|
|
36
37
|
# <tt>:language</tt>:: The language used in the map
|
|
37
38
|
#
|
|
38
|
-
def initialize(options)
|
|
39
|
+
def initialize(options = {})
|
|
39
40
|
inject_defaults_from_module_class_attribute!(options)
|
|
40
41
|
validate_required_options(options)
|
|
41
42
|
validate_options(options)
|
data/spec/location_spec.rb
CHANGED
data/spec/map_spec.rb
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
1
2
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
3
|
|
|
3
4
|
describe GoogleStaticMapsHelper::Map do
|
|
4
|
-
|
|
5
|
+
reguire_options = {
|
|
5
6
|
:size => '600x400',
|
|
6
7
|
:key => 'MY_GOOGLE_KEY',
|
|
7
8
|
:sensor => false
|
|
@@ -9,39 +10,44 @@ describe GoogleStaticMapsHelper::Map do
|
|
|
9
10
|
|
|
10
11
|
describe "initialize" do
|
|
11
12
|
before do
|
|
12
|
-
|
|
13
|
+
reguire_options.each_key {|k| GoogleStaticMapsHelper.send("#{k}=", nil)}
|
|
13
14
|
end
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
reguire_options.each_key do |key|
|
|
16
17
|
it "should raise OptionMissing if #{key} is not given" do
|
|
17
|
-
option_with_missing_option =
|
|
18
|
+
option_with_missing_option = reguire_options.dup
|
|
18
19
|
option_with_missing_option.delete(key)
|
|
19
20
|
lambda {GoogleStaticMapsHelper::Map.new(option_with_missing_option)}.should raise_error(GoogleStaticMapsHelper::OptionMissing)
|
|
20
21
|
end
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
it "should raise OptionNotExist if incomming option doesn't exists" do
|
|
24
|
-
lambda {GoogleStaticMapsHelper::Map.new(
|
|
25
|
+
lambda {GoogleStaticMapsHelper::Map.new(reguire_options.merge(:invalid_option => 'error?'))}.should raise_error(GoogleStaticMapsHelper::OptionNotExist)
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
it "should be able to read initialized key option from object" do
|
|
28
|
-
GoogleStaticMapsHelper::Map.new(
|
|
29
|
+
GoogleStaticMapsHelper::Map.new(reguire_options).key.should == reguire_options[:key]
|
|
29
30
|
end
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
reguire_options.each_key do |key|
|
|
32
33
|
it "should use #{key} from GoogleStaticMapsHelper class attribute if set" do
|
|
33
|
-
option_with_missing_option =
|
|
34
|
+
option_with_missing_option = reguire_options.dup
|
|
34
35
|
GoogleStaticMapsHelper.send("#{key}=", option_with_missing_option.delete(key))
|
|
35
36
|
map = GoogleStaticMapsHelper::Map.new(option_with_missing_option)
|
|
36
37
|
map.send(key).should == GoogleStaticMapsHelper.send(key)
|
|
37
38
|
end
|
|
38
39
|
end
|
|
40
|
+
|
|
41
|
+
it "should be able to call new with no arguments if GoogleStaticMapsHelper class attributes are set" do
|
|
42
|
+
reguire_options.each_pair {|key, value| GoogleStaticMapsHelper.send("#{key}=", value)}
|
|
43
|
+
lambda {GoogleStaticMapsHelper::Map.new}.should_not raise_error
|
|
44
|
+
end
|
|
39
45
|
end
|
|
40
46
|
|
|
41
47
|
describe "markers" do
|
|
42
48
|
before :each do
|
|
43
49
|
@marker = GoogleStaticMapsHelper::Marker.new(:lat => 1, :lng => 2)
|
|
44
|
-
@map = GoogleStaticMapsHelper::Map.new(
|
|
50
|
+
@map = GoogleStaticMapsHelper::Map.new(reguire_options)
|
|
45
51
|
end
|
|
46
52
|
|
|
47
53
|
it "should be empty as default" do
|
|
@@ -100,7 +106,7 @@ describe GoogleStaticMapsHelper::Map do
|
|
|
100
106
|
@point2 = GoogleStaticMapsHelper::Location.new(:lat => 3, :lng => 4)
|
|
101
107
|
@path << @point << @point2
|
|
102
108
|
|
|
103
|
-
@map = GoogleStaticMapsHelper::Map.new(
|
|
109
|
+
@map = GoogleStaticMapsHelper::Map.new(reguire_options)
|
|
104
110
|
end
|
|
105
111
|
|
|
106
112
|
it "should be able to push paths on to map" do
|
|
@@ -119,7 +125,7 @@ describe GoogleStaticMapsHelper::Map do
|
|
|
119
125
|
|
|
120
126
|
describe "size" do
|
|
121
127
|
before do
|
|
122
|
-
@map = GoogleStaticMapsHelper::Map.new(
|
|
128
|
+
@map = GoogleStaticMapsHelper::Map.new(reguire_options)
|
|
123
129
|
@map.size = '300x400'
|
|
124
130
|
end
|
|
125
131
|
|
|
@@ -172,7 +178,7 @@ describe GoogleStaticMapsHelper::Map do
|
|
|
172
178
|
|
|
173
179
|
describe "format" do
|
|
174
180
|
before do
|
|
175
|
-
@map = GoogleStaticMapsHelper::Map.new(
|
|
181
|
+
@map = GoogleStaticMapsHelper::Map.new(reguire_options)
|
|
176
182
|
end
|
|
177
183
|
|
|
178
184
|
%w{png png8 png32 gif jpg jpg-basedline}.each do |format|
|
|
@@ -194,7 +200,7 @@ describe GoogleStaticMapsHelper::Map do
|
|
|
194
200
|
|
|
195
201
|
describe "map type" do
|
|
196
202
|
before do
|
|
197
|
-
@map = GoogleStaticMapsHelper::Map.new(
|
|
203
|
+
@map = GoogleStaticMapsHelper::Map.new(reguire_options)
|
|
198
204
|
end
|
|
199
205
|
|
|
200
206
|
%w{roadmap satellite terrain hybrid}.each do |type|
|
|
@@ -385,7 +391,7 @@ describe GoogleStaticMapsHelper::Map do
|
|
|
385
391
|
end
|
|
386
392
|
|
|
387
393
|
it "should provide a helper method named marker which will create a new marker and add it to the map" do
|
|
388
|
-
map = GoogleStaticMapsHelper::Map.new(
|
|
394
|
+
map = GoogleStaticMapsHelper::Map.new(reguire_options)
|
|
389
395
|
map.marker(:lat => 1, :lng => 2)
|
|
390
396
|
map.length.should eql(1)
|
|
391
397
|
end
|
data/spec/marker_spec.rb
CHANGED
data/spec/path_spec.rb
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
1
2
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
3
|
|
|
3
4
|
describe GoogleStaticMapsHelper::Path do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
5
|
+
options = {
|
|
6
|
+
:weight => 5,
|
|
7
|
+
:color => "0x0000ff",
|
|
8
|
+
:fillcolor => "0x110000ff"
|
|
9
|
+
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
describe "initialize" do
|
|
12
|
+
options.each_key do |attribute|
|
|
12
13
|
it "should be able to set and retreive #{attribute} via initializer" do
|
|
13
|
-
GoogleStaticMapsHelper::Path.new(
|
|
14
|
+
GoogleStaticMapsHelper::Path.new(options).send(attribute).should == options.fetch(attribute)
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
it "should be able to set and retreive #{attribute} via accessor method" do
|
|
17
18
|
path = GoogleStaticMapsHelper::Path.new
|
|
18
|
-
path.send("#{attribute}=",
|
|
19
|
-
path.send(attribute).should ==
|
|
19
|
+
path.send("#{attribute}=", options.fetch(attribute))
|
|
20
|
+
path.send(attribute).should == options.fetch(attribute)
|
|
20
21
|
end
|
|
21
22
|
end
|
|
22
23
|
|
|
@@ -27,12 +28,12 @@ describe GoogleStaticMapsHelper::Path do
|
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
it "should be able to add points via options during initialization" do
|
|
30
|
-
path = GoogleStaticMapsHelper::Path.new(
|
|
31
|
+
path = GoogleStaticMapsHelper::Path.new(options.merge(:points => [@point, @point2]))
|
|
31
32
|
path.points.should == [@point, @point2]
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
it "should be able to add points before option hash" do
|
|
35
|
-
path = GoogleStaticMapsHelper::Path.new(@point, @point2,
|
|
36
|
+
path = GoogleStaticMapsHelper::Path.new(@point, @point2, options)
|
|
36
37
|
path.points.should == [@point, @point2]
|
|
37
38
|
end
|
|
38
39
|
end
|
|
@@ -128,7 +129,7 @@ describe GoogleStaticMapsHelper::Path do
|
|
|
128
129
|
@path.url_params.should include('1,2')
|
|
129
130
|
end
|
|
130
131
|
|
|
131
|
-
|
|
132
|
+
options.each do |attribute, value|
|
|
132
133
|
it "should not include #{attribute} as default in url" do
|
|
133
134
|
@path.url_params.should_not include("#{attribute}=")
|
|
134
135
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: google_static_maps_helper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- "Thorbj\xC3\xB8rn Hermansen"
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-12-01 00:00:00 +01:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -80,9 +80,9 @@ signing_key:
|
|
|
80
80
|
specification_version: 3
|
|
81
81
|
summary: This gem provides a simple interface to the Google Static Maps V2 API
|
|
82
82
|
test_files:
|
|
83
|
-
- spec/spec_helper.rb
|
|
84
83
|
- spec/marker_spec.rb
|
|
85
|
-
- spec/google_static_maps_helper_spec.rb
|
|
86
|
-
- spec/location_spec.rb
|
|
87
84
|
- spec/map_spec.rb
|
|
85
|
+
- spec/spec_helper.rb
|
|
86
|
+
- spec/location_spec.rb
|
|
88
87
|
- spec/path_spec.rb
|
|
88
|
+
- spec/google_static_maps_helper_spec.rb
|