Class Geokit::LatLng
In: lib/geokit/mappable.rb
Parent: Object

Methods

==   eql?   hash   lat=   ll   lng=   new   normalize   reverse_geocode   to_a   to_s  

Included Modules

Mappable

Attributes

lat  [RW] 
lng  [RW] 

Public Class methods

Accepts latitude and longitude or instantiates an empty instance if lat and lng are not provided. Converted to floats if provided

A class method to take anything which can be inferred as a point and generate a LatLng from it. You should use this anything you‘re not sure what the input is, and want to deal with it as a LatLng if at all possible. Can take:

 1) two arguments (lat,lng)
 2) a string in the format "37.1234,-129.1234" or "37.1234 -129.1234"
 3) a string which can be geocoded on the fly
 4) an array in the format [37.1234,-129.1234]
 5) a LatLng or GeoLoc (which is just passed through as-is)
 6) anything which acts_as_mappable -- a LatLng will be extracted from it

Public Instance methods

Returns true if the candidate object is logically equal. Logical equivalence is true if the lat and lng attributes are the same for both objects.

Latitude attribute setter; stored as a float.

Returns the lat and lng attributes as a comma-separated string.

Longitude attribute setter; stored as a float;

Reverse geocodes a LatLng object using the MultiGeocoder (default), or optionally using a geocoder of your choosing. Returns a new Geokit::GeoLoc object

Options

  • :using - Specifies the geocoder to use for reverse geocoding. Defaults to
              MultiGeocoder. Can be either the geocoder class (or any class that
              implements do_reverse_geocode for that matter), or the name of
              the class without the "Geocoder" part (e.g. :google)
    

Examples

LatLng.new(51.4578329, 7.0166848).reverse_geocode # => #<Geokit::GeoLoc:0x12dac20 @state…> LatLng.new(51.4578329, 7.0166848).reverse_geocode(:using => :google) # => #<Geokit::GeoLoc:0x12dac20 @state…> LatLng.new(51.4578329, 7.0166848).reverse_geocode(:using => Geokit::Geocoders::GoogleGeocoder) # => #<Geokit::GeoLoc:0x12dac20 @state…>

returns a two-element array

returns a string with comma-separated lat,lng values

[Validate]