Skip to content

andre/geocoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Geocoder (in Crystal)

Simplest possible geocoder shard for Crystal.

Geocoder options

  1. Google. Get your API here: https://developers.google.com/maps/documentation/geocoding/get-api-key
  2. Nominatim (OpenStreamMap). Doesn't need a key, but read usage policy carefully here: https://operations.osmfoundation.org/policies/nominatim/

Installation

Add this to your application's shard.yml:

dependencies:
  geocoder:
    github: andre/geocoder

Usage

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

Check the success method (returns true | false)

puts res.success

Multiple results are accessed via the all_results method:

res = g.geocode("100 Main st")
all = res.all_results
puts all[0].address
puts all[1].address

Nominatim / OpenStreetmap:

require "geocoder"

g = Geocoder::NominatimGeocoder.new()
res = g.geocode("100 Main st, Denver, CO")

Contributors

About

Simple Geocoding in Crystal

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published