static-gmaps 0.0.2 → 0.0.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.
Files changed (3) hide show
  1. data/History.txt +6 -0
  2. data/lib/static_gmaps.rb +7 -2
  3. metadata +2 -2
@@ -1,3 +1,9 @@
1
+ === 0.0.3 / 2008-02-26
2
+
3
+ * 2 Minor Enhancement:
4
+ * Now raises exception when there are too many markers.
5
+ * Now raises exception when the url becomes too long.
6
+
1
7
  === 0.0.2 / 2008-02-25
2
8
 
3
9
  * 1 Major Enhancement:
@@ -23,9 +23,11 @@
23
23
  require 'net/http'
24
24
 
25
25
  module StaticGmaps
26
- VERSION = '0.0.2'
26
+ VERSION = '0.0.3'
27
27
 
28
28
  class Map
29
+ MAXIMUM_URL_SIZE = 1978
30
+ MAXIMUM_MARKERS = 50
29
31
  DEFAULT_CENTER = [ 0, 0 ]
30
32
  DEFAULT_ZOOM = 1
31
33
  DEFAULT_SIZE = [ 500, 400 ]
@@ -65,6 +67,7 @@ module StaticGmaps
65
67
  raise MissingArgument.new("Center must be set before a url can be generated for Map (or multiple markers can be specified).") if !center
66
68
  raise MissingArgument.new("Zoom must be set before a url can be generated for Map (or multiple markers can be specified).") if !zoom
67
69
  end
70
+ raise "Google will not display more than #{MAXIMUM_MARKERS} markers." if markers && markers.size > MAXIMUM_MARKERS
68
71
  parameters = {}
69
72
  parameters[:size] = "#{size[0]}x#{size[1]}"
70
73
  parameters[:key] = "#{key}"
@@ -75,7 +78,9 @@ module StaticGmaps
75
78
  parameters = parameters.to_a.sort { |a, b| a[0].to_s <=> b[0].to_s }
76
79
  parameters = parameters.collect { |parameter| "#{parameter[0]}=#{parameter[1]}" }
77
80
  parameters = parameters.join '&'
78
- return "http://maps.google.com/staticmap?#{parameters}"
81
+ x = "http://maps.google.com/staticmap?#{parameters}"
82
+ raise "Google doesn't like the url to be longer than #{MAXIMUM_URL_SIZE} characters. Try fewer or less precise markers." if x.size > MAXIMUM_URL_SIZE
83
+ return x
79
84
  end
80
85
 
81
86
  def markers_url_fragment
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: static-gmaps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wulff
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-02-25 00:00:00 -08:00
12
+ date: 2008-02-26 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency