Simplest possible geocoder shard for Crystal.
Geocoder options
- Google. Get your API here: https://developers.google.com/maps/documentation/geocoding/get-api-key
- Nominatim (OpenStreamMap). Doesn't need a key, but read usage policy carefully here: https://operations.osmfoundation.org/policies/nominatim/
Add this to your application's shard.yml
:
dependencies:
geocoder:
github: andre/geocoder
require "geocoder"
g = Geocoder::GoogleGeocoder.new(YOUR_GOOGLE_API_KEY)
res = g.geocode("100 Main st, Denver, CO")
puts res.address
puts res.lat
puts res.lng
puts res.success
res = g.geocode("100 Main st")
all = res.all_results
puts all[0].address
puts all[1].address
require "geocoder"
g = Geocoder::NominatimGeocoder.new()
res = g.geocode("100 Main st, Denver, CO")
- Andre Lewis - creator