Skip to content
Snippets Groups Projects
Commit a9b9ea0e authored by Alex Reisner's avatar Alex Reisner
Browse files

Add 'Getting More Information' section to README.

Documents Geocoder.search method.
parent 15cdfaa8
No related branches found
No related tags found
No related merge requests found
......@@ -143,6 +143,35 @@ However, there can be only one set of latitude/longitude attributes, and whichev
The reason for this is that we don't want ambiguity when doing distance calculations. We need a single, authoritative source for coordinates!
== Getting More Information
Those familiar with Google's Geocoding API know that it returns much more information than just an address or set of coordinates. If you want access to the entire response you can use the <tt>Geocoder.search</tt> method:
results = Geocoder.search("McCarren Park, Brooklyn, NY")
r = results.first
+r+ is now a Geocoder::Result object which has methods like the following:
r.geometry
=> {
"location"=>{"lng"=>-79.3801601, "lat"=>43.6619568},
"location_type"=>"ROOFTOP",
"viewport"=>{
"northeast"=>{"lng"=>-79.3770125, "lat"=>43.6651044},
"southwest"=>{"lng"=>-79.3833077, "lat"=>43.6588092}
}
}
r.address_components_of_type(:neighborhood)
=> [{
"long_name"=>"Greenpoint",
"short_name"=>"Greenpoint",
"types"=>["neighborhood", "political"]
}]
Please see the Geocoder::Result class for more information, as well as Google's API documentation (http://code.google.com/apis/maps/documentation/geocoding/#JSON).
== SQLite
SQLite's lack of trigonometric functions requires an alternate implementation of the +near+ method (scope). When using SQLite, Geocoder will automatically use a less accurate algorithm for finding objects near a given point. Results of this algorithm should not be trusted too much as it will return objects that are outside the given radius.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment