Class | Geokit::LatLng |
In: |
lib/geokit/mappable.rb
|
Parent: | Object |
lat | [RW] | |
lng | [RW] |
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
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.
Reverse geocodes a LatLng object using the MultiGeocoder (default), or optionally using a geocoder of your choosing. Returns a new Geokit::GeoLoc object
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)
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…>