Module: Geos::GoogleMaps::Api2::Geometry

Includes:
Geos::GoogleMaps::ApiCommon::Geometry
Defined in:
lib/geos/google_maps/api_2.rb

Instance Method Summary collapse

Methods included from Geos::GoogleMaps::ApiCommon::Geometry

#to_g_json_point, #to_g_lat_lon_box, #to_g_url_value, #to_g_url_value_bounds

Instance Method Details

#to_g_lat_lng_bounds_api2(options = {}) ⇒ Object

Returns a new GLatLngBounds object with the proper GLatLngs in place for determining the geometry bounds.



8
9
10
11
12
13
14
15
16
# File 'lib/geos/google_maps/api_2.rb', line 8

def to_g_lat_lng_bounds_api2(options = {})
  klass = if options[:short_class]
    'GLatLngBounds'
  else
    'google.maps.LatLngBounds'
  end

  "new #{klass}(#{self.lower_left.to_g_lat_lng_api2(options)}, #{self.upper_right.to_g_lat_lng_api2(options)})"
end

#to_g_lat_lng_bounds_string_api2(precision = 10) ⇒ Object

Returns a String in Google Maps’ GLatLngBounds#toString() format.



19
20
21
# File 'lib/geos/google_maps/api_2.rb', line 19

def to_g_lat_lng_bounds_string_api2(precision = 10)
  "((#{self.lower_left.to_g_url_value(precision)}), (#{self.upper_right.to_g_url_value(precision)}))"
end

#to_g_marker_api2(marker_options = {}, options = {}) ⇒ Object

Returns a new GMarker at the centroid of the geometry. The options Hash works the same as the Google Maps API GMarkerOptions class does, but allows for underscored Ruby-like options which are then converted to the appropriate camel-cased Javascript options.



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/geos/google_maps/api_2.rb', line 37

def to_g_marker_api2(marker_options = {}, options = {})
  klass = if options[:short_class]
    'GMarker'
  else
    'google.maps.Marker'
  end

  opts = Geos::Helper.camelize_keys(marker_options)

  "new #{klass}(#{self.centroid.to_g_lat_lng(options)}, #{opts.to_json})"
end

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

Returns a new GPolygon.



29
30
31
# File 'lib/geos/google_maps/api_2.rb', line 29

def to_g_polygon_api2(polygon_options = {}, options = {})
  self.coord_seq.to_g_polygon_api2(polygon_options, options)
end

#to_g_polyline_api2(polyline_options = {}, options = {}) ⇒ Object

Returns a new GPolyline.



24
25
26
# File 'lib/geos/google_maps/api_2.rb', line 24

def to_g_polyline_api2(polyline_options = {}, options = {})
  self.coord_seq.to_g_polyline_api2(polyline_options, options)
end