Module: Geos::GoogleMaps::Api3::GeometryCollection

Includes:
Geos::GoogleMaps::ApiCommon::UrlValueBounds
Defined in:
lib/geos/google_maps/api_3.rb

Instance Method Summary collapse

Methods included from Geos::GoogleMaps::ApiCommon::UrlValueBounds

#to_g_url_value, #to_g_url_value_point

Instance Method Details

#to_g_polygon_api3(polygon_options = {}, options = {}) ⇒ Object

Returns a Ruby Array of Polygons for each geometry in the collection. If the :single option is set, a single Polygon object will be returned with all of the geometries set in the Polygon’s “path” attribute. You can also use to_g_polygon_single for the same effect.



190
191
192
193
194
195
196
197
198
# File 'lib/geos/google_maps/api_3.rb', line 190

def to_g_polygon_api3(polygon_options = {}, options = {})
  if options[:single]
    self.to_g_polygon_single_api3(polygon_options, options)
  else
    self.collect do |p|
      p.to_g_polygon_api3(polygon_options, options)
    end
  end
end

#to_g_polygon_single_api3(polygon_options = {}, options = {}) ⇒ Object

Behaves the same as to_g_polygon_api3 with the :single option set, where a single Google Maps Polygon will be returned with all of the Polygons set in the Polygon’s “path” attribute.



203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/geos/google_maps/api_3.rb', line 203

def to_g_polygon_single_api3(polygon_options = {}, options = {})
  options = {
    :escape => [],
    :lat_lng_options => {}
  }.merge(options)

  opts = Geos::Helper.camelize_keys(polygon_options)
  opts[:paths] = %{[#{self.collect { |p|
    "[#{p.exterior_ring.coord_seq.to_g_lat_lng_api3(options[:lat_lng_options]).join(', ')}]"
  }.join(', ')}]}
  json = Geos::Helper.escape_json(opts, Geos::GoogleMaps::Api3Constants::UNESCAPED_POLY_OPTIONS - options[:escape])

  "new google.maps.Polygon(#{json})"
end

#to_g_polyline_api3(polyline_options = {}, options = {}) ⇒ Object Also known as: to_g_polylines_api3

Returns a Ruby Array of Polylines for each geometry in the collection.



179
180
181
182
183
# File 'lib/geos/google_maps/api_3.rb', line 179

def to_g_polyline_api3(polyline_options = {}, options = {})
  self.collect do |p|
    p.to_g_polyline_api3(polyline_options, options)
  end
end