README.markdown in geokit-1.10.0 vs README.markdown in geokit-1.11.0
- old
+ new
@@ -43,17 +43,18 @@
* Geonames - a free geocoder
* Bing
* Yandex
* MapQuest
* Geocod.io
+* OpenStreetMap (Nominatim)
* Mapbox - requires an access token
* [OpenCage](http://geocoder.opencagedata.com) - requires an API key
### address geocoders that also provide reverse geocoding
* Google - Supports multiple results and bounding box/country code biasing. Also supports Maps API for Business keys; see the configuration section below.
* FCC
-* OpenStreetMap
+* OpenStreetMap (Nominatim)
* Mapbox
* OpenCage
### IP address geocoders
* IP - geocodes an IP address using hostip.info's web service.
@@ -119,10 +120,14 @@
# These setting can be nil if not needed, otherwise, a valid URI must be
# filled in at a minimum. If the proxy requires authentication, the username
# and password can be provided as well.
Geokit::Geocoders::proxy = 'https://user:password@host:port'
+ # This setting can be used if a web service blocks requests by certain user agents.
+ # If not set Geokit uses the default useragent header set by the different net adapter libs.
+ Geokit::Geocoders::useragent = 'my agent string'
+
# This is your yahoo application key for the Yahoo Geocoder.
# See http://developer.yahoo.com/faq/index.html#appid
# and http://developer.yahoo.com/maps/rest/V1/geocode.html
Geokit::Geocoders::YahooGeocoder.key = 'REPLACE_WITH_YOUR_YAHOO_KEY'
Geokit::Geocoders::YahooGeocoder.secret = 'REPLACE_WITH_YOUR_YAHOO_SECRET'
@@ -219,11 +224,11 @@
irb> res = Geokit::Geocoders::GoogleGeocoder.geocode('Toledo')
irb> res.full_address
=> "Toledo, OH, USA"
```
-Not exactly what we were looking for. We know that Toledo is in Spain, so we can tell the Google Geocoder to prefer results from Spain first, and then wander the Toledos of the world. To do that, we have to pass Italy's ccTLD (country code top-level domain) to the `:bias` option of the `geocode` method. You can find a comprehensive list of all ccTLDs here: http://en.wikipedia.org/wiki/CcTLD.
+Not exactly what we were looking for. We know that Toledo is in Spain, so we can tell the Google Geocoder to prefer results from Spain first, and then wander the Toledos of the world. To do that, we have to pass Spain's ccTLD (country code top-level domain) to the `:bias` option of the `geocode` method. You can find a comprehensive list of all ccTLDs here: http://en.wikipedia.org/wiki/CcTLD.
```ruby
irb> res = Geokit::Geocoders::GoogleGeocoder.geocode('Toledo', :bias => 'es')
irb> res.full_address
=> "Toledo, Toledo, Spain"
@@ -244,23 +249,33 @@
irb> res = Geokit::Geocoders::GoogleGeocoder.geocode('Winnetka', :bias => la_bounds)
irb> res.full_address
=> "Winnetka, California, USA"
```
+Another option is to use Component Filtering as described at https://developers.google.com/maps/documentation/geocoding/intro#ComponentFiltering. To do that supply the `:components` option to the `geocode` method. This option should be a hash with keys corresponding to desired component names.
+Suppose we'd like to geocode string 'Austin'. Regularly, Google would return 'Austin, TX, USA' for such a query. Not with component filtering:
+
+```ruby
+ irb>res = Geokit::Geocoders::GoogleGeocoder.geocode("austin", components: { administrative_area: 'IL', country: 'US' })
+ irb>res.full_address
+ => "Austin, Chicago, IL, USA"
+```
+
### The Multigeocoder
Multi Geocoder - provides failover for the physical location geocoders, and also IP address geocoders. Its configured by setting Geokit::Geocoders::provider_order, and Geokit::Geocoders::ip_provider_order. You should call the Multi-Geocoder with its :geocode method, supplying one address parameter which is either a real street address, or an ip address. For example:
```ruby
Geokit::Geocoders::MultiGeocoder.geocode("900 Sycamore Drive")
Geokit::Geocoders::MultiGeocoder.geocode("12.12.12.12")
+
+ Geokit::Geocoders::MultiGeocoder.geocode("Hamburg, Germany", :provider_order => [:osm, :mapbox, :google])
```
## MULTIPLE RESULTS
Some geocoding services will return multple results if the there isn't one clear result.
-Geoloc can capture multiple results through its "all" method. Currently only the Google geocoder
-supports multiple results:
+Geoloc can capture multiple results through its "all" method.
```ruby
irb> geo=Geokit::Geocoders::GoogleGeocoder.geocode("900 Sycamore Drive")
irb> geo.full_address
=> "900 Sycamore Dr, Arkadelphia, AR 71923, USA"