ym4r 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,15 +1,47 @@
1
1
  =YM4R
2
- This is YM4R 0.1.2. The goal of YM4R (YM4R Maps For Ruby) is to ease the use of the Google Maps and Yahoo! Maps API's (including the Geocoding, Map Image, Traffic and Local Search API's) from Ruby and Rails.
2
+ This is YM4R 0.1.3. The goal of YM4R (which naturally means Yellow Maps For Ruby...) is to ease the use of the Google Maps and Yahoo! Maps API's (including the Geocoding, Map Image, Traffic and Local Search API's) from Ruby and Rails.
3
3
 
4
4
  ===Operations
5
5
  ====Google Maps
6
- You can use the library to display maps easily from your rails application. Update through RJS is possible. Check out the tutorial at http://thepochisuperstarmegashow.com/2006/06/02/ym4r-georuby-spatial-adapter-demo/
6
+ You can use the library to display Google maps easily with any ruby-based web framework. The version of the API used is v2. The library is engineered so updates to the map through Ajax are possible. I have made available 2 in-depth tutorials to show some of the functionalities of the library and how it can be integrated with GeoRuby and the Spatial Adapter for Rails:
7
+ - http://thepochisuperstarmegashow.com/2006/06/02/ym4r-georuby-spatial-adapter-demo/
8
+ - http://thepochisuperstarmegashow.com/2006/06/03/google-maps-yahoo-traffic-mash-up/
9
+ Following is some notes about using the library:
7
10
 
8
- ====Yahoo Maps
9
- There is at the moment preliminary support for the JS-Flash Yahoo! Maps API, although it is not very polished. Check back next version!
11
+ =====Binding JavaScript and Ruby
12
+ Since the Google Maps API uses JavaScript to create and manipulate a map, most of what the library does is outputting JavaScript, although some convenience methods are provided to simplify some common operations at initialization time. When you create a YM4R mapping object (a Ruby object which includes the MappingObject module) and call methods on it, these calls are converted by the library into JavaScript code. At initialization time, you can pass arbitrary JavaScript code to the <tt>GMap#record_init</tt> and <tt>GMap#record_global_init</tt>.Then, at update time, if you use Ruby-on-Rails as your web framework, you can update your map through RJS by passing the result of the method calls to the <tt>page.send :record,...</tt> method to have it then interpreted by the browser.
13
+
14
+ For example, here is a typical initialization sequence for a map
15
+ @map = GMap.new("map_div")
16
+ @map.center_zoom_init([35.12313,-110.567],12)
17
+ @map.record_init @map.add_overlay(GMarker.new([35.12878, -110.578],:title => "Hello!"))
18
+
19
+ While +center_zoom_init+ is one of the rare convenience methods that do not output JavaScript, the +add_overlay+ does. Actually, if you look at the code of the GMap class, you won't find any +add_overlay+ method, although in the documentation of the GMap2 class from the Google Maps API documentation, you will find something about the +addOverlay+ JavaScript method. In fact, when you call on a mapping object an unknow method, it is converted to a javascriptified version of it, along with its arguments, and a string of JavaScript code is output. So the <tt>@map.add_overlay...</tt> above is converted to <tt>"map.addOverlay(new GMarker(GLatLng.new(35.12878, -110.578),{title:\"Hello!\"}))"</tt>, which is then passed to the +record_init+ method of a Ruby GMap object to be later output along with the rest of the initialization code.
20
+
21
+ =====Initialization of the map
22
+ The map is represented by a GMap object. You need to pass to the constructor the id of a DIV that will contain the map. You have to place this DIV yourself in your HTML template. You can also optionnally pass to the constructor the JavaScript name of the variable that will reference the map, which by default will be global in JavaScript. You have convenience methods to setup the controls, the center, the zoom and the icons (which are also global). You can also pass arbitrary JavaScript to +record_init+ and +record_global_init+. Since, by default, the initialization of the map is performed in a callback function, if you want to have a globally accessible variable, you need to use the +global+ version.
23
+
24
+ Then in your template, you have 2 necessary calls:
25
+ - <tt>GMap#header</tt>: Outputs the inclusion of the JavaScript file from Google to make use of the Google Maps API + a style declaration for VML objects, necessary to display polylines under IE.
26
+ - <tt>GMap#to_html</tt>: Outputs the initialization code of the map. By default, it outputs the +script+ tags and initializes the map inside a +load+ function. These settings can however be overridden.
27
+
28
+ You need to have an <tt>onload="load()"</tt> on the body of the HTML document, as well as place a DIV with the chosen ID to have the map correctly displayed.
29
+
30
+ =====Update of the map
31
+ You are able to update the map through Ajax. For example, in Ruby-on-Rails, you have something called RJS, which sends JavaScript created on the server as a response to an action, which is later interpreted by the browser. It is usually used for visual effects and replacing or adding elements. It can also accept arbitrary JavaScript and this is what YM4R uses.
32
+
33
+ For example, if you want to add a marker to the map, you need to do a few things. First, you have to bind a Ruby mapping object to the global JavaScript map variable. By default its name is +map+, but you could have overriden that at initialization time. You need to do something like this:
34
+ @map = Variable.new("map")
35
+ +map+ in the Variable constructor is the name of the global JavaScript map variable. Then any method you call on <tt>@map</tt> will be converted in JavaScript to a method called on +map+. In your RJS code, you would do something like this to add a marker:
36
+ page.send :record, @map.add_overlay(GMarker.new([123123.1,12313.76],:info_window => "Hello again!"))
37
+
38
+ =====Naming conventions
39
+ The names of the Ruby class follow the ones in the JavaScript Google Maps API v2. To know what is possible to do, you should refer to the documentation available on Google website.
40
+
41
+ On top of that, you have some convenience methods for initializing the map (in the GMap class). Also, the constructors of some classes accept different types of arguments to be converted later in the correct JavaScript format. For example, the +GMarker+ aclass accepts an array of 2 floats as parameter, in addition of a GLatLng object, to indicate its position. It also facilitates the attribution of an HTML info window, displayed when the user clicks on it, since you can pass to the constructor an options hash with the <tt>:info_window</tt> key and the text to display as the value.
10
42
 
11
43
  ====Yahoo Maps Building Block API
12
- Building Block API's (Geocoding, Map Image, Traffic and Local Search) are supported. You have to pass to the +get+ method of the module a hash whose keys are a rubyfied version of the request parameters. You get back a ruby object, with accessors that let you get the returned data in a easy way. You get an exception if not all the parameters have been passed, if the connection to the service could not be made or if the parameters you have passed are of the incorrect value.
44
+ Building Block API's (Geocoding, Map Image, Traffic and Local Search) are supported. You have to pass to the +get+ method of the module a hash whose keys are a rubyfied version of the request parameters detailed in the documentation for these API's. You get back a ruby object, with accessors that let you get the returned data in a easy way. You get an exception if not all the parameters have been passed, if the connection to the service could not be made or if the parameters you have passed are of the incorrect value.
13
45
 
14
46
  To know what parameters to pass to the +get+ methods and what results you should expect, you should consult the documentation for the building block API's on Yahoo!'s website : http://developer.yahoo.com/maps/index.html#mapsBuildingBlocks .
15
47
 
@@ -22,7 +54,7 @@ Here is an example of request:
22
54
  :city => "Cupertino",
23
55
  :state => "CA",
24
56
  :zip => "95014")
25
- +results+ is an array of Geocoding::Result objects. The API can return up to 50 results for one request. Read the documentation page of the Geocoding::Result class to know how to access the data.
57
+ +results+ is an array of Geocoding::Result objects. The API can return up to 50 results for one request. You can access the data in the result with attributes which are rubyfied versions of the XML elements forming the answer from the service: See the Yahoo! Geocoding documentation to know what these are and their meanings.
26
58
 
27
59
  =====Map Image
28
60
  Here is an example of request:
@@ -57,6 +89,9 @@ Here is an example of request:
57
89
  :query => "chinese")
58
90
  +results+ is a LocalSearch::ResultSet object (subclass of +Array+), containing LocalSearch::Result objects, each containing information about one hit on the Yahoo! local search.
59
91
 
92
+ ====Yahoo! Maps JS-Flash API
93
+ Preliminary support for this API has been added. It works along the same lines as with the Google Maps API but it is not very polished currently.
94
+
60
95
  ===Changes since last version
61
96
  - Addition of support for the Google Maps API
62
97
  - Addition of preliminary support for the Yahoo! Maps JS-Flash API
@@ -2,6 +2,7 @@ require 'yaml'
2
2
 
3
3
  module Ym4r
4
4
  module GoogleMaps
5
+ #The key to be used by the google maps API. It is valid only for the subdiretories of the URL you applied for on this page : http://www.google.com/apis/maps/
5
6
  API_KEY = YAML::load_file(File.dirname(__FILE__) + '/config/config.yml')
6
7
  end
7
8
  end
@@ -2,36 +2,42 @@ require 'ym4r/google_maps/mapping'
2
2
 
3
3
  module Ym4r
4
4
  module GoogleMaps
5
+ #Small map control. Report to the Google Maps API documentation for details.
5
6
  class GSmallMapControl
6
7
  include MappingObject
7
8
  def create
8
9
  "new GSmallMapControl()"
9
10
  end
10
11
  end
12
+ #Large Map control. Report to the Google Maps API documentation for details.
11
13
  class GLargeMapControl
12
14
  include MappingObject
13
15
  def create
14
16
  "new GLargeMapControl()"
15
17
  end
16
18
  end
19
+ #Small Zoom control. Report to the Google Maps API documentation for details.
17
20
  class GSmallZoomControl
18
21
  include MappingObject
19
22
  def create
20
23
  "new GSmallZoomControl()"
21
24
  end
22
25
  end
26
+ #Scale control. Report to the Google Maps API documentation for details.
23
27
  class GScaleControl
24
28
  include MappingObject
25
29
  def create
26
30
  "new GScaleControl()"
27
31
  end
28
32
  end
33
+ #Map type control. Report to the Google Maps API documentation for details.
29
34
  class GMapTypeControl
30
35
  include MappingObject
31
36
  def create
32
37
  "new GMapTypeControl()"
33
38
  end
34
39
  end
40
+ #Overview map control. Report to the Google Maps API documentation for details.
35
41
  class GOverviewMapControl
36
42
  include MappingObject
37
43
  def create
@@ -39,7 +45,8 @@ module Ym4r
39
45
  end
40
46
  end
41
47
 
42
- #The first argument of the constructor is oneof the following : :top_right, :top_left, :bottom_right, :bottom_left
48
+ #An object representing a position of a control.
49
+ #The first argument of the constructor is one of the following : :top_right, :top_left, :bottom_right, :bottom_left.
43
50
  class GControlPosition < Struct.new(:anchor,:offset)
44
51
  include MappingObject
45
52
  def create
@@ -1,17 +1,20 @@
1
1
 
2
2
  Ym4r::GoogleMaps::GPolyline.class_eval do
3
+ #Creates a GPolyline object from a georuby line string. Assumes the points of the line strings are stored in Longitude(x)/Latitude(y) order.
3
4
  def self.from_georuby(line_string,color = nil,weight = nil,opacity = nil)
4
5
  GPolyline.new(line_string.points.collect { |point| GLatLng.new([point.y,point.x])},color,weight,opacity)
5
6
  end
6
7
  end
7
8
 
8
9
  Ym4r::GoogleMaps::GMarker.class_eval do
10
+ #Creates a GMarker object from a georuby point. Accepts the same options as the GMarker constructor. Assumes the points of the line strings are stored in Longitude(x)/Latitude(y) order.
9
11
  def self.from_georuby(point,options = {})
10
12
  GMarker.new([point.y,point.x],options)
11
13
  end
12
14
  end
13
15
 
14
16
  Ym4r::GoogleMaps::GLatLng.class_eval do
17
+ #Creates a GLatLng object from a georuby point. Assumes the points of the line strings are stored in Longitude(x)/Latitude(y) order.
15
18
  def self.from_georuby(point,unbounded = nil)
16
19
  GLatLng.new([point.y,point.x],unbounded)
17
20
  end
@@ -1,12 +1,16 @@
1
1
  module Ym4r
2
2
  module GoogleMaps
3
+ #The Ruby-space class representing the Google Maps API class GMap2.
3
4
  class GMap
4
5
  include MappingObject
5
6
 
7
+ #A constant containing the declaration of the VML namespace, necessary to display polylines under IE.
6
8
  VML_NAMESPACE = "xmlns:v=\"urn:schemas-microsoft-com:vml\""
7
9
 
10
+ #The id of the DIV that will contain the map in the HTML page.
8
11
  attr_reader :container
9
12
 
13
+ #By default the map in the HTML page will be globally accessible with the name +map+.
10
14
  def initialize(container, variable = "map")
11
15
  @container = container
12
16
  @variable = variable
@@ -14,20 +18,24 @@ module Ym4r
14
18
  @global_init = ""
15
19
  end
16
20
 
21
+ #Outputs the header necessary to use the Google Maps API. By default, it also outputs a style declaration for VML elements.
17
22
  def header(with_vml = true)
18
23
  a = "<script src=\"http://maps.google.com/maps?file=api&v=2&key=#{API_KEY}\" type=\"text/javascript\"></script>\n"
19
24
  a << "<style type=\"text/css\">\n v\:* { behavior:url(#default#VML);}\n</style>" if with_vml
20
25
  a
21
26
  end
22
27
 
28
+ #Outputs a style declaration setting the dimensions of the DIV container of the map. This info can also be set manually in a CSS.
23
29
  def header_width_height(width,height)
24
30
  "<style type=\"text/css\">\n##{@container} { height: #{height}px;\n width: #{width}px;\n}\n</style>"
25
31
  end
26
32
 
33
+ #Records arbitrary JavaScript code and outputs it during initialization inside the +load+ function.
27
34
  def record_init(code)
28
35
  @init << code
29
36
  end
30
37
 
38
+ #Initializes the controls: you can pass a hash with keys <tt>:small_map</tt>, <tt>:large_map</tt>, <tt>:small_zoom</tt>, <tt>:scale</tt>, <tt>:map_type</tt> and <tt>:overview_map</tt> and a boolean value as the value (usually true, since the control is not displayed by default)
31
39
  def control_init(controls = {})
32
40
  @init << add_control(GSmallMapControl.new) if controls[:small_map]
33
41
  @init << add_control(GLargeMapControl.new) if controls[:large_map]
@@ -37,6 +45,7 @@ module Ym4r
37
45
  @init << add_control(GOverviewMapControl.new) if controls[:overview_map]
38
46
  end
39
47
 
48
+ #Initializes the initial center and zoom of the map. +center+ can be both a GLatLng object or a 2-float array.
40
49
  def center_zoom_init(center, zoom)
41
50
  if center.is_a?(GLatLng)
42
51
  @init << set_center(center,zoom)
@@ -45,15 +54,17 @@ module Ym4r
45
54
  end
46
55
  end
47
56
 
57
+ #Records arbitrary JavaScript code and outputs it during initialization outside the +load+ function (ie globally).
48
58
  def record_global_init(code)
49
59
  @global_init << code
50
60
  end
51
61
 
62
+ #Initializes an icon and makes it globally accessible through the JavaScript variable of name +variable+.
52
63
  def icon_init(icon , variable)
53
64
  @global_init << icon.declare(variable)
54
65
  end
55
66
 
56
- #allow :script, :no_script and :load in the method parameter. If the :load parameter has been chose, the load_method parameter must be filled too.
67
+ #Outputs the initialization code for the map. By default, it outputs the script tags, performs the initialization inside a function called +load+ and makes the map globally available.
57
68
  def to_html(options = {})
58
69
  no_load = options[:no_load]
59
70
  load_method = options[:load_method] || "load"
@@ -79,11 +90,13 @@ module Ym4r
79
90
  html
80
91
  end
81
92
 
93
+ #Outputs in JavaScript the creation of a GMap2 object
82
94
  def create
83
95
  "new GMap2(document.getElementById(\"#{@container}\"))"
84
96
  end
85
97
  end
86
98
 
99
+ #Map types of the map
87
100
  module GMapType
88
101
  G_NORMAL_MAP = Variable.new("GMapType.G_NORMAL_MAP")
89
102
  G_SATELLITE_MAP = Variable.new("GMapType.G_SATELLITE_MAP")
@@ -1,9 +1,11 @@
1
1
  module Ym4r
2
2
  module GoogleMaps
3
+ #The module where all the Ruby-to-JavaScript conversion takes place. It is included by all the classes in the YM4R library.
3
4
  module MappingObject
5
+ #The name of the variable in JavaScript space.
4
6
  attr_reader :variable
5
7
 
6
- #creates javascript code for missing methods
8
+ #Creates javascript code for missing methods
7
9
  def method_missing(name,*args)
8
10
  args.collect! do |arg|
9
11
  javascriptify_variable(arg)
@@ -11,6 +13,7 @@ module Ym4r
11
13
  "#{to_javascript}.#{javascriptify_method(name.to_s)}(#{args.join(",")});\n"
12
14
  end
13
15
 
16
+ #Transforms a Ruby object into a JavaScript string
14
17
  def javascriptify_variable(arg)
15
18
  if arg.is_a?(MappingObject)
16
19
  arg.to_javascript
@@ -21,28 +24,29 @@ module Ym4r
21
24
  end
22
25
  end
23
26
 
24
- #lifted from rails
27
+ #Escape string to be used in JavaScript. Lifted from rails.
25
28
  def escape_javascript(javascript)
26
29
  javascript.gsub(/\r\n|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" }
27
30
  end
28
31
 
29
- #transform a ruby-type method name (like qsd_fghj) to a Yahoo! Map style one (like qsdFghj)
32
+ #Transform a ruby-type method name (like add_overlay) to a JavaScript-style one (like addOverlay).
30
33
  def javascriptify_method(method_name)
31
34
  method_name.gsub(/_(\w)/){|s| $1.upcase}
32
35
  end
33
36
 
34
- #Declare Mapping Object (Map, Tool, Marker,...) of name variable
37
+ #Declares a Mapping Object bound to a JavaScript variable of name +variable+.
35
38
  def declare(variable)
36
39
  @variable = variable
37
40
  "var #{variable} = #{create};\n"
38
41
  end
39
42
 
43
+ #Binds a Mapping object to a previously declared JavaScript variable of name +variable+.
40
44
  def assign_to(variable)
41
45
  @variable = variable
42
46
  "#{variable} = #{create};\n"
43
47
  end
44
48
 
45
- #Returns a Javascript script representing the object
49
+ #Returns a Javascript code representing the object
46
50
  def to_javascript
47
51
  unless @variable.nil?
48
52
  @variable
@@ -51,16 +55,15 @@ module Ym4r
51
55
  end
52
56
  end
53
57
 
54
- #Creates a Mapping Object in Javascript
58
+ #Creates a Mapping Object in JavaScript.
55
59
  #To be implemented by subclasses if needed
56
60
  def create
57
61
  end
58
62
  end
59
63
 
60
-
64
+ #Used to bind a ruby variable to an already existing JavaScript one.
61
65
  class Variable
62
66
  include MappingObject
63
-
64
67
  def initialize(variable)
65
68
  @variable = variable
66
69
  end
@@ -2,10 +2,11 @@ require 'ym4r/google_maps/mapping'
2
2
 
3
3
  module Ym4r
4
4
  module GoogleMaps
5
+ #A graphical marker positionned through geographic coordinates (in the WGS84 datum). An HTML info window can be set to be displayed when the marker is clicked on.
5
6
  class GMarker
6
7
  include MappingObject
7
8
  attr_accessor :point, :options, :info_window, :info_window_tabs
8
- #options keys can be : :icon, :clickable and :title: Defaults to G_DEFAULT_ICON, true and empty. :info_window can also be input. However in order to be taken into account, the marker has to be declared at some point
9
+ #The +points+ argument can be either a GLatLng object or an array of 2 floats. The +options+ keys can be: <tt>:icon</tt>, <tt>:clickable</tt>, <tt>:title</tt>, <tt>:info_window</tt> and <tt>info_window_tabs</tt>. The value of the +info_window+ key is a string of HTML code that will be displayed when the markers is clicked on. The value of the +info_window_tabs+ key is an array of GInfoWindowTab objects.
9
10
  def initialize(point, options = {})
10
11
  if point.is_a?(Array)
11
12
  @point = GLatLng.new(point)
@@ -16,6 +17,7 @@ module Ym4r
16
17
  @tab_info_window = options.delete(:info_window_tabs)
17
18
  @options = options
18
19
  end
20
+ #Creates a marker: If an info_window or info_window_tabs is present, the response to the click action from the user is setup here.
19
21
  def create
20
22
  if @options.empty?
21
23
  creation = "new GMarker(#{@point.to_javascript})"
@@ -37,6 +39,7 @@ module Ym4r
37
39
  end
38
40
  end
39
41
 
42
+ #Represents a tab to be displayed in a bubble when a marker is clicked on.
40
43
  class GInfoWindowTab < Struct.new(:tab,:content)
41
44
  include MappingObject
42
45
  def create
@@ -44,17 +47,18 @@ module Ym4r
44
47
  end
45
48
  end
46
49
 
47
- #Icon class. You can pass rubyfied versions of the attributes detailed in the Google Maps API documentation. You can initialize global icons to be used in the application by passing a icon object, along with a variable name, to GMap#icon_init. If you want to declare an icon outside this, you will need to declare it first.
50
+ #Represents a definition of an icon. You can pass rubyfied versions of the attributes detailed in the Google Maps API documentation. You can initialize global icons to be used in the application by passing a icon object, along with a variable name, to GMap#icon_init. If you want to declare an icon outside this, you will need to declare it first, since the JavaScript constructor does not accept any argument.
48
51
  class GIcon
49
52
  include MappingObject
50
53
  DEFAULT = Variable.new("G_DEFAULT_ICON")
51
54
  attr_accessor :options, :copy_base
52
55
 
53
- #Options can contain all the attributes (in rubifiedformat) of an GIconobject (see Google's doc) + :copy_base, which indicates if the icon is copied from another one
56
+ #Options can contain all the attributes (in rubyfied format) of a GIcon object (see Google's doc), as well as <tt>:copy_base</tt>, which indicates if the icon is copied from another one.
54
57
  def initialize(options = {})
55
58
  @copy_base = options.delete(:copy_base)
56
59
  @options = options
57
60
  end
61
+ #Creates a GIcon.
58
62
  def create
59
63
  if @copy_base
60
64
  "new GIcon(#{@copy_base.to_javascript})"
@@ -62,6 +66,7 @@ module Ym4r
62
66
  "new GIcon()"
63
67
  end
64
68
  end
69
+ #Declares a GIcon. It is necessary to declare an icon before using it, since it is the only way to set up its attributes.
65
70
  def declare(variable)
66
71
  decl = super(variable)
67
72
  @options.each do |key,value|
@@ -71,10 +76,11 @@ module Ym4r
71
76
  end
72
77
  end
73
78
 
74
- #A polyline. Can take an array of GLatLng or an array of 2D arrays. A method to build a polyline from a GeoRuby linestring is provided in the helper.rb file.
79
+ #A polyline.
75
80
  class GPolyline
76
81
  include MappingObject
77
82
  attr_accessor :points,:color,:weight,:opacity
83
+ #Can take an array of +GLatLng+ or an array of 2D arrays. A method to directly build a polyline from a GeoRuby linestring is provided in the helper.rb file.
78
84
  def initialize(points,color = nil,weight = nil,opacity = nil)
79
85
  if !points.empty? and points[0].is_a?(Array)
80
86
  @points = points.collect { |pt| GLatLng.new(pt) }
@@ -85,6 +91,7 @@ module Ym4r
85
91
  @weight = weight
86
92
  @opacity = opacity
87
93
  end
94
+ #Creates a new polyline.
88
95
  def create
89
96
  a = "new GPolyline([#{@points.collect{|pt| pt.to_javascript}.join(",")}]"
90
97
  a << ",#{javascriptify_variable(@color)}" if @color
@@ -114,6 +121,7 @@ module Ym4r
114
121
  end
115
122
  end
116
123
 
124
+ #A rectangular bounding box, defined by its south-western and north-eastern corners.
117
125
  class GLatLngBounds < Struct.new(:sw,:ne)
118
126
  include MappingObject
119
127
  def create
@@ -2,16 +2,18 @@ require 'ym4r/google_maps/mapping'
2
2
 
3
3
  module Ym4r
4
4
  module GoogleMaps
5
+ #A point in pixel coordinates
5
6
  class GPoint < Struct.new(:x,:y)
6
7
  include MappingObject
7
8
  def create
8
9
  "new GPoint(#{x},#{y})"
9
10
  end
10
11
  end
12
+ #A rectangular that contains all the pixel points passed as arguments
11
13
  class GBounds
12
14
  include MappingObject
13
15
  attr_accessor :points
14
-
16
+ #Accepts both an array of GPoint and an array of 2-element arrays
15
17
  def initialize(points)
16
18
  if !points.empty? and points[0].is_a?(Array)
17
19
  @points = points.collect { |pt| GPoint.new(pt[0],pt[1]) }
@@ -23,12 +25,12 @@ module Ym4r
23
25
  "new GBounds([#{@points.map { |pt| pt.to_javascript}.join(",")}])"
24
26
  end
25
27
  end
28
+ #A size object, in pixel space
26
29
  class GSize < Struct.new(:width,:height)
27
30
  include MappingObject
28
31
  def create
29
32
  "new GSize(#{width},#{height})"
30
33
  end
31
-
32
34
  end
33
35
  end
34
36
  end
data/rakefile.rb CHANGED
@@ -24,7 +24,7 @@ spec = Gem::Specification::new do |s|
24
24
  s.platform = Gem::Platform::RUBY
25
25
 
26
26
  s.name = 'ym4r'
27
- s.version = "0.1.2"
27
+ s.version = "0.1.3"
28
28
  s.summary = "Using Google Maps and Yahoo! Maps from Ruby and Rails"
29
29
  s.description = <<EOF
30
30
  EOF
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: ym4r
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.2
7
- date: 2006-06-03 00:00:00 +05:00
6
+ version: 0.1.3
7
+ date: 2006-06-04 00:00:00 +05:00
8
8
  summary: Using Google Maps and Yahoo! Maps from Ruby and Rails
9
9
  require_paths:
10
10
  - lib