static-gmaps-v3 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +26 -0
- data/LICENSE.txt +21 -0
- data/Manifest +8 -0
- data/README +66 -0
- data/Rakefile +49 -0
- data/lib/static_gmaps.rb +187 -0
- data/spec/static_gmaps_spec.rb +82 -0
- data/static-gmaps-v3.gemspec +30 -0
- metadata +77 -0
data/History.txt
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
=== 0.0.4 / 2009-02-18 by daniel.mattes@gmx.de
|
2
|
+
|
3
|
+
* No Map::default_center, because of auto centering through google when markers.count > 1
|
4
|
+
* If no option[:markers] are given, they will be set to []. Otherwise the constant markers array will grow to unlimited.
|
5
|
+
* Setting constants like geokit do it.
|
6
|
+
In initializers you can overwrite it like
|
7
|
+
StaticGmaps::default_size = [ 170, 200 ]
|
8
|
+
* Now on http://github.com/dmattes/static-gmaps/
|
9
|
+
|
10
|
+
=== 0.0.3 / 2008-02-26
|
11
|
+
|
12
|
+
* 2 Minor Enhancement:
|
13
|
+
* Now raises exception when there are too many markers.
|
14
|
+
* Now raises exception when the url becomes too long.
|
15
|
+
|
16
|
+
=== 0.0.2 / 2008-02-25
|
17
|
+
|
18
|
+
* 1 Major Enhancement:
|
19
|
+
* Now supports Markers!
|
20
|
+
* 1 Minor Enhancement:
|
21
|
+
* Removed StaticGmaps::Map.to_blob
|
22
|
+
|
23
|
+
=== 0.0.1 / 2008-02-25
|
24
|
+
|
25
|
+
* 1 major enhancement
|
26
|
+
* Birthday!
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2008 John Wulff <johnwulff@gmail.com>
|
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/Manifest
ADDED
data/README
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
= StaticGmaps
|
2
|
+
|
3
|
+
* http://github.com/dmattes/static-gmaps/
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Provides an interface to the Google Static Maps API v3.
|
8
|
+
Copyright (c) 2010 Sebastian Gräßl <sebastian@validcode.me>
|
9
|
+
Original Version from John Wulff, modified by Daniel Mattes
|
10
|
+
|
11
|
+
== FEATURES/PROBLEMS:
|
12
|
+
|
13
|
+
* Provides an interface to the Google Static Maps API v3.
|
14
|
+
|
15
|
+
== SYNOPSIS:
|
16
|
+
|
17
|
+
# In environment.rb or initializers you can set default values, for example
|
18
|
+
StaticGmaps::default_size = [ 170, 200 ]
|
19
|
+
|
20
|
+
# Get from http://code.google.com/apis/maps/signup.html
|
21
|
+
GOOGLE_MAPS_API_KEY = ''
|
22
|
+
|
23
|
+
map = StaticGmaps::Map.new :center => [ 40.714728, -73.998672 ],
|
24
|
+
:zoom => 5,
|
25
|
+
:size => [ 500, 400 ],
|
26
|
+
:map_type => :roadmap,
|
27
|
+
:key => GOOGLE_MAPS_API_KEY
|
28
|
+
map.markers << StaticGmaps::Marker.new(:latitude => 40,
|
29
|
+
:longitude => -73,
|
30
|
+
:color => :blue,
|
31
|
+
:alpha_character => :b)
|
32
|
+
map.url => 'http://maps.google.com/staticmap?center=40.714728,-73.998672&key=GOOGLE_MAPS_API_KEY&map_type=roadmap&markers=40,-73,blueb&size=500x400&zoom=5'
|
33
|
+
|
34
|
+
== REQUIREMENTS:
|
35
|
+
|
36
|
+
* None.
|
37
|
+
|
38
|
+
== INSTALL:
|
39
|
+
|
40
|
+
* sudo gem install static-gmaps-v3
|
41
|
+
|
42
|
+
== LICENSE:
|
43
|
+
|
44
|
+
(The MIT License)
|
45
|
+
|
46
|
+
Copyright (c) 2010 Sebastian Gräßl <sebastian@validcode.me>
|
47
|
+
Original Version from John Wulff, modified by Daniel Mattes
|
48
|
+
|
49
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
50
|
+
a copy of this software and associated documentation files (the
|
51
|
+
'Software'), to deal in the Software without restriction, including
|
52
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
53
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
54
|
+
permit persons to whom the Software is furnished to do so, subject to
|
55
|
+
the following conditions:
|
56
|
+
|
57
|
+
The above copyright notice and this permission notice shall be
|
58
|
+
included in all copies or substantial portions of the Software.
|
59
|
+
|
60
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
61
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
62
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
63
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
64
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
65
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
66
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Copyright (c) 2010 Sebastian Gräßl <sebastian@validcode.me>
|
4
|
+
# Original Version from John Wulff, modified by Daniel Mattes
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
|
24
|
+
require 'rubygems'
|
25
|
+
require 'echoe'
|
26
|
+
require './lib/static_gmaps.rb'
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'spec/rake/spectask'
|
30
|
+
rescue LoadError
|
31
|
+
puts 'To use rspec for testing you must install rspec gem:'
|
32
|
+
puts '$ sudo gem install rspec'
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
|
36
|
+
Echoe.new('static-gmaps-v3', StaticGmaps::version) do |p|
|
37
|
+
p.author = 'Sebastian Gräßl'
|
38
|
+
p.email = 'sebastian@validcode.me'
|
39
|
+
p.summary = 'Provides an interface to the Google Static Maps API v3.'
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "Run all examples"
|
43
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
44
|
+
t.spec_files = FileList['spec/*.rb']
|
45
|
+
end
|
46
|
+
|
47
|
+
task :default => :spec
|
48
|
+
|
49
|
+
# vim: syntax=Ruby
|
data/lib/static_gmaps.rb
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Copyright (c) 2010 Sebastian Gräßl <sebastian@validcode.me>
|
4
|
+
# Original Version from John Wulff, modified by Daniel Mattes
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
|
24
|
+
require 'net/http'
|
25
|
+
|
26
|
+
module StaticGmaps
|
27
|
+
@@version = '0.0.5'
|
28
|
+
|
29
|
+
#map
|
30
|
+
@@maximum_url_size = 1978
|
31
|
+
@@maximum_markers = 50
|
32
|
+
@@default_center = [ 0, 0 ]
|
33
|
+
@@default_zoom = 1
|
34
|
+
@@default_size = [ 500, 400 ]
|
35
|
+
@@default_map_type = :roadmap
|
36
|
+
@@default_sensor = false
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
#marker
|
41
|
+
@@default_latitude = nil
|
42
|
+
@@default_longitude = nil
|
43
|
+
@@default_color = nil
|
44
|
+
@@default_alpha_character = nil
|
45
|
+
@@valid_colors = [ :red, :green, :blue ]
|
46
|
+
@@valid_alpha_characters = [ :a, :b, :c, :d, :e, :f, :g, :h, :i, :j, :k, :l, :m, :n, :o, :p, :q, :r, :s, :t, :u, :v, :w, :x, :y, :z ]
|
47
|
+
|
48
|
+
[:version, :maximum_url_size, :maximum_markers, :default_center, :default_zoom, :default_size, :default_map_type,
|
49
|
+
:default_latitude, :default_longitude, :default_color, :default_alpha_character, :valid_colors, :valid_alpha_characters, :default_sensor].each do |sym|
|
50
|
+
class_eval <<-EOS
|
51
|
+
def self.#{sym}
|
52
|
+
@@#{sym}
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.#{sym}=(obj)
|
56
|
+
@@#{sym} = obj
|
57
|
+
end
|
58
|
+
EOS
|
59
|
+
end
|
60
|
+
|
61
|
+
class Map
|
62
|
+
|
63
|
+
|
64
|
+
attr_accessor :center,
|
65
|
+
:zoom,
|
66
|
+
:size,
|
67
|
+
:map_type,
|
68
|
+
:markers,
|
69
|
+
:sensor
|
70
|
+
|
71
|
+
def initialize(options = {})
|
72
|
+
self.center = options[:center]
|
73
|
+
self.zoom = options[:zoom] || StaticGmaps::default_zoom
|
74
|
+
self.size = options[:size] || StaticGmaps::default_size
|
75
|
+
self.map_type = options[:map_type] || StaticGmaps::default_map_type
|
76
|
+
self.sensor = options[:sensor] || StaticGmaps::default_sensor
|
77
|
+
self.markers = options[:markers] || [ ]
|
78
|
+
end
|
79
|
+
|
80
|
+
def width
|
81
|
+
size[0]
|
82
|
+
end
|
83
|
+
|
84
|
+
def height
|
85
|
+
size[1]
|
86
|
+
end
|
87
|
+
|
88
|
+
# http://code.google.com/apis/maps/documentation/staticmaps/index.html#URL_Parameters
|
89
|
+
def url
|
90
|
+
raise MissingArgument.new("Size must be set before a url can be generated for Map.") if !size || !size[0] || !size[1]
|
91
|
+
|
92
|
+
if(!self.center && !(markers && markers.size >= 1))
|
93
|
+
self.center = StaticGmaps::default_center
|
94
|
+
end
|
95
|
+
|
96
|
+
if !(markers && markers.size >= 1)
|
97
|
+
raise MissingArgument.new("Center must be set before a url can be generated for Map (or multiple markers can be specified).") if !center
|
98
|
+
raise MissingArgument.new("Zoom must be set before a url can be generated for Map (or multiple markers can be specified).") if !zoom
|
99
|
+
end
|
100
|
+
raise "Google will not display more than #{StaticGmaps::maximum_markers} markers." if markers && markers.size > StaticGmaps::maximum_markers
|
101
|
+
parameters = {}
|
102
|
+
parameters[:size] = "#{size[0]}x#{size[1]}"
|
103
|
+
parameters[:map_type] = "#{map_type}" if map_type
|
104
|
+
parameters[:center] = "#{center[0]},#{center[1]}" if center
|
105
|
+
parameters[:zoom] = "#{zoom}" if zoom
|
106
|
+
parameters[:markers] = "#{markers_url_fragment}" if markers_url_fragment
|
107
|
+
parameters[:sensor] = "#{sensor}"
|
108
|
+
|
109
|
+
parameters = parameters.to_a.sort { |a, b| a[0].to_s <=> b[0].to_s }
|
110
|
+
parameters = parameters.collect { |parameter| "#{parameter[0]}=#{parameter[1]}" }
|
111
|
+
parameters = parameters.join '&'
|
112
|
+
x = "http://maps.google.com/maps/api/staticmap?#{parameters}"
|
113
|
+
raise "Google doesn't like the url to be longer than #{StaticGmaps::maximum_url_size} characters. Try fewer or less precise markers." if x.size > StaticGmaps::maximum_url_size
|
114
|
+
return x
|
115
|
+
end
|
116
|
+
|
117
|
+
def markers_url_fragment
|
118
|
+
if markers && markers.any?
|
119
|
+
return markers.collect{|marker| marker.url_fragment }.join('|')
|
120
|
+
else
|
121
|
+
return nil
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def to_blob
|
126
|
+
fetch
|
127
|
+
return @blob
|
128
|
+
end
|
129
|
+
|
130
|
+
private
|
131
|
+
def fetch
|
132
|
+
if !@last_fetched_url || @last_fetched_url != url || !@blob
|
133
|
+
uri = URI.parse url
|
134
|
+
request = Net::HTTP::Get.new uri.path
|
135
|
+
response = Net::HTTP.start(uri.host, uri.port) { |http| http.request request }
|
136
|
+
@blob = response.body
|
137
|
+
@last_fetched_url = url
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# http://code.google.com/apis/maps/documentation/staticmaps/index.html#Markers
|
143
|
+
class Marker
|
144
|
+
|
145
|
+
attr_accessor :latitude,
|
146
|
+
:longitude,
|
147
|
+
:color,
|
148
|
+
:alpha_character
|
149
|
+
|
150
|
+
def initialize(options = {})
|
151
|
+
self.latitude = options[:latitude] || StaticGmaps::default_latitude
|
152
|
+
self.longitude = options[:longitude] || StaticGmaps::default_longitude
|
153
|
+
self.color = options[:color] || StaticGmaps::default_color
|
154
|
+
self.alpha_character = options[:alpha_character] || StaticGmaps::default_alpha_character
|
155
|
+
end
|
156
|
+
|
157
|
+
def color=(value)
|
158
|
+
if value
|
159
|
+
value = value.to_s.downcase.to_sym
|
160
|
+
if !StaticGmaps::valid_colors.include?(value)
|
161
|
+
raise ArgumentError.new("#{value} is not a supported color. Supported colors are #{StaticGmaps::valid_colors.join(', ')}.")
|
162
|
+
end
|
163
|
+
end
|
164
|
+
@color = value
|
165
|
+
end
|
166
|
+
|
167
|
+
def alpha_character=(value)
|
168
|
+
if value
|
169
|
+
value = value.to_s.downcase.to_sym
|
170
|
+
if !StaticGmaps::valid_alpha_characters.include?(value)
|
171
|
+
raise ArgumentError.new("#{value} is not a supported alpha_character. Supported colors are #{StaticGmaps::valid_alpha_characters.join(', ')}.")
|
172
|
+
end
|
173
|
+
end
|
174
|
+
@alpha_character = value
|
175
|
+
end
|
176
|
+
|
177
|
+
def url_fragment
|
178
|
+
raise MissingArgument.new("Latitude must be set before a url_fragment can be generated for Marker.") if !latitude
|
179
|
+
raise MissingArgument.new("Longitude must be set before a url_fragment can be generated for Marker.") if !longitude
|
180
|
+
x = ""
|
181
|
+
x += "color:#{color}|" if color
|
182
|
+
x += "label:#{alpha_character}|" if alpha_character
|
183
|
+
x += "#{latitude},#{longitude}"
|
184
|
+
return x
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec'
|
3
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'static_gmaps')
|
4
|
+
include StaticGmaps
|
5
|
+
|
6
|
+
STATIC_GOOGLE_MAP_DEFAULT_PARAMETERS_TEST_IMAGE_PATH = File.join File.dirname(__FILE__), 'test_image.gif'
|
7
|
+
|
8
|
+
describe StaticGmaps do
|
9
|
+
describe Map, 'initialize with no attributes' do
|
10
|
+
before(:each) do @map = StaticGmaps::Map.new end
|
11
|
+
|
12
|
+
#it 'should set center to default' do @map.center.should == StaticGmaps::default_center end
|
13
|
+
# no default center, because of auto adjustment
|
14
|
+
it 'should set zoom to default' do @map.zoom.should == StaticGmaps::default_zoom end
|
15
|
+
it 'should set size to default' do @map.size.should == StaticGmaps::default_size end
|
16
|
+
it 'should set map_type to default' do @map.map_type.should == StaticGmaps::default_map_type end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe Map, 'initialize with all attributes' do
|
20
|
+
before(:each) do
|
21
|
+
@marker = StaticGmaps::Marker.new :latitude => 0, :longitude => 0
|
22
|
+
@map = StaticGmaps::Map.new :center => [ 40.714728, -73.998672 ],
|
23
|
+
:zoom => 12,
|
24
|
+
:size => [ 500, 400 ],
|
25
|
+
:map_type => :roadmap,
|
26
|
+
:markers => [ @marker ],
|
27
|
+
:sensor => true
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should have a url' do @map.url.should == 'http://maps.google.com/maps/api/staticmap?center=40.714728,-73.998672&map_type=roadmap&markers=0,0&sensor=true&size=500x400&zoom=12' end
|
31
|
+
it 'should set center' do @map.center.should == [ 40.714728, -73.998672 ] end
|
32
|
+
it 'should set zoom' do @map.zoom.should == 12 end
|
33
|
+
it 'should set size' do @map.size.should == [ 500, 400 ] end
|
34
|
+
it 'should set map_type' do @map.map_type.should == :roadmap end
|
35
|
+
it 'should set markers' do @map.markers.should == [ @marker ] end
|
36
|
+
it 'should set sensor' do @map.sensor.should == true end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe Map, 'with default attributes' do
|
40
|
+
before(:each) do @map = StaticGmaps::Map.new end
|
41
|
+
|
42
|
+
it 'should have a url' do @map.url.should == 'http://maps.google.com/maps/api/staticmap?center=0,0&map_type=roadmap&sensor=false&size=500x400&zoom=1' end
|
43
|
+
it 'should have a width' do @map.width.should == 500 end
|
44
|
+
it 'should have a height' do @map.height.should == 400 end
|
45
|
+
#it 'should respond to to_blob with an image' do @map.to_blob.should == File.read(STATIC_GOOGLE_MAP_DEFAULT_PARAMETERS_TEST_IMAGE_PATH) end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe Map, 'with default attributes and markers' do
|
49
|
+
before(:each) do
|
50
|
+
@marker_1 = StaticGmaps::Marker.new :latitude => 10, :longitude => 20, :color => 'green', :alpha_character => 'A'
|
51
|
+
@marker_2 = StaticGmaps::Marker.new :latitude => 15, :longitude => 25, :color => 'blue', :alpha_character => 'B'
|
52
|
+
@map = StaticGmaps::Map.new :markers => [ @marker_1, @marker_2 ]
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should have a markers_url_fragment' do @map.markers_url_fragment.should == 'color:green|label:a|10,20|color:blue|label:b|15,25' end
|
56
|
+
it 'should include the markers_url_fragment its url' do @map.url.should include(@map.markers_url_fragment) end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe Marker, 'initialize with no attributes' do
|
60
|
+
before(:each) do @marker = StaticGmaps::Marker.new end
|
61
|
+
|
62
|
+
it 'should set latitude to default' do @marker.latitude.should == StaticGmaps::default_latitude end
|
63
|
+
it 'should set longitude to default' do @marker.longitude.should == StaticGmaps::default_longitude end
|
64
|
+
it 'should set color to default' do @marker.color.should == StaticGmaps::default_color end
|
65
|
+
it 'should set alpha_character to default' do @marker.alpha_character.should == StaticGmaps::default_alpha_character end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe Marker, 'initialize with all attributes' do
|
69
|
+
before(:each) do
|
70
|
+
@marker = StaticGmaps::Marker.new :latitude => 12,
|
71
|
+
:longitude => 34,
|
72
|
+
:color => 'red',
|
73
|
+
:alpha_character => 'z',
|
74
|
+
:sensor => true
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should set latitude' do @marker.latitude.should == 12 end
|
78
|
+
it 'should set longitude' do @marker.longitude.should == 34 end
|
79
|
+
it 'should set color' do @marker.color.should == :red end
|
80
|
+
it 'should set alpha_character' do @marker.alpha_character.should == :z end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{static-gmaps-v3}
|
5
|
+
s.version = "0.0.5"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Sebastian Gr\303\244\303\237l"]
|
9
|
+
s.date = %q{2010-05-02}
|
10
|
+
s.description = %q{Provides an interface to the Google Static Maps API v3.}
|
11
|
+
s.email = %q{sebastian@validcode.me}
|
12
|
+
s.extra_rdoc_files = ["LICENSE.txt", "README", "lib/static_gmaps.rb"]
|
13
|
+
s.files = ["History.txt", "LICENSE.txt", "Manifest", "README", "Rakefile", "lib/static_gmaps.rb", "spec/static_gmaps_spec.rb", "static-gmaps-v3.gemspec"]
|
14
|
+
s.homepage = %q{}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Static-gmaps-v3", "--main", "README"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{static-gmaps-v3}
|
18
|
+
s.rubygems_version = %q{1.3.6}
|
19
|
+
s.summary = %q{Provides an interface to the Google Static Maps API v3.}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
+
else
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: static-gmaps-v3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- "Sebastian Gr\xC3\xA4\xC3\x9Fl"
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-05-02 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Provides an interface to the Google Static Maps API v3.
|
22
|
+
email: sebastian@validcode.me
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- LICENSE.txt
|
29
|
+
- README
|
30
|
+
- lib/static_gmaps.rb
|
31
|
+
files:
|
32
|
+
- History.txt
|
33
|
+
- LICENSE.txt
|
34
|
+
- Manifest
|
35
|
+
- README
|
36
|
+
- Rakefile
|
37
|
+
- lib/static_gmaps.rb
|
38
|
+
- spec/static_gmaps_spec.rb
|
39
|
+
- static-gmaps-v3.gemspec
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: ""
|
42
|
+
licenses: []
|
43
|
+
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options:
|
46
|
+
- --line-numbers
|
47
|
+
- --inline-source
|
48
|
+
- --title
|
49
|
+
- Static-gmaps-v3
|
50
|
+
- --main
|
51
|
+
- README
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 1
|
67
|
+
- 2
|
68
|
+
version: "1.2"
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
rubyforge_project: static-gmaps-v3
|
72
|
+
rubygems_version: 1.3.6
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Provides an interface to the Google Static Maps API v3.
|
76
|
+
test_files: []
|
77
|
+
|