Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andre/geocoder
Simple Geocoding in Crystal
https://github.com/andre/geocoder
Last synced: 18 days ago
JSON representation
Simple Geocoding in Crystal
- Host: GitHub
- URL: https://github.com/andre/geocoder
- Owner: andre
- License: mit
- Created: 2018-04-30T14:14:06.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-03T04:18:58.000Z (over 6 years ago)
- Last Synced: 2024-08-01T00:41:15.445Z (3 months ago)
- Language: Crystal
- Size: 11.7 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/andre/geocoder.svg?branch=master)](https://travis-ci.org/andre/geocoder)
# 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`:
```yaml
dependencies:
geocoder:
github: andre/geocoder
```## Usage
```crystal
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)
```crystal
puts res.success
```### Multiple results are accessed via the `all_results` method:
```crystal
res = g.geocode("100 Main st")
all = res.all_results
puts all[0].address
puts all[1].address
```## Nominatim / OpenStreetmap:
```crystal
require "geocoder"g = Geocoder::NominatimGeocoder.new()
res = g.geocode("100 Main st, Denver, CO")
```## Contributors
- [Andre Lewis](https://github.com/andre) - creator