Module: Geos::GoogleMaps::Api2::CoordinateSequence
- Defined in:
- lib/geos/google_maps/api_2.rb
Instance Method Summary collapse
-
#to_g_lat_lng_api2(options = {}) ⇒ Object
Returns a Ruby Array of GLatLngs.
-
#to_g_polygon_api2(polygon_options = {}, options = {}) ⇒ Object
Returns a new GPolygon.
-
#to_g_polyline_api2(polyline_options = {}, options = {}) ⇒ Object
Returns a new GPolyline.
Instance Method Details
#to_g_lat_lng_api2(options = {}) ⇒ Object
Returns a Ruby Array of GLatLngs.
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/geos/google_maps/api_2.rb', line 52 def to_g_lat_lng_api2( = {}) klass = if [:short_class] 'GLatLng' else 'google.maps.LatLng' end self.to_a.collect do |p| "new #{klass}(#{p[1]}, #{p[0]})" end end |
#to_g_polygon_api2(polygon_options = {}, options = {}) ⇒ Object
Returns a new GPolygon. Note that this GPolygon just uses whatever coordinates are found in the sequence in order, so it might not make much sense at all.
The options Hash follows the Google Maps API arguments to the GPolygon constructor and include :stroke_color, :stroke_weight, :stroke_opacity, :fill_color, :fill_opacity and :options. ‘null’ is used in place of any unset options.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/geos/google_maps/api_2.rb', line 100 def to_g_polygon_api2( = {}, = {}) klass = if [:short_class] 'GPolygon' else 'google.maps.Polygon' end poly_opts = if [:polygon_options] Geos::Helper.camelize_keys([:polygon_options]) end args = [ ([:stroke_color] ? "'#{Geos::Helper.escape_javascript([:stroke_color])}'" : 'null'), ([:stroke_weight] || 'null'), ([:stroke_opacity] || 'null'), ([:fill_color] ? "'#{Geos::Helper.escape_javascript([:fill_color])}'" : 'null'), ([:fill_opacity] || 'null'), (poly_opts ? poly_opts.to_json : 'null') ].join(', ') "new #{klass}([#{self.to_g_lat_lng_api2().join(', ')}], #{args})" end |
#to_g_polyline_api2(polyline_options = {}, options = {}) ⇒ Object
Returns a new GPolyline. Note that this GPolyline just uses whatever coordinates are found in the sequence in order, so it might not make much sense at all.
The options Hash follows the Google Maps API arguments to the GPolyline constructor and include :color, :weight, :opacity and :options. ‘null’ is used in place of any unset options.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/geos/google_maps/api_2.rb', line 71 def to_g_polyline_api2( = {}, = {}) klass = if [:short_class] 'GPolyline' else 'google.maps.Polyline' end poly_opts = if [:polyline_options] Geos::Helper.camelize_keys([:polyline_options]) end args = [ ([:color] ? "'#{Geos::Helper.escape_javascript([:color])}'" : 'null'), ([:weight] || 'null'), ([:opacity] || 'null'), (poly_opts ? poly_opts.to_json : 'null') ].join(', ') "new #{klass}([#{self.to_g_lat_lng().join(', ')}], #{args})" end |