geocoder

Version, currently master branch1 version
  • master branchlatestMay 3, 2018

github.com/andre/geocoder

Simple Geocoding in Crystal

8 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  geocoder:
    github: andre/geocoder
    branch: master

master is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
0.24.2
License
MIT
Author
Andre Lewis <andre.lewis@gmail.com>

Dependencies

Development Dependencies

  • webmock*github: manastech/webmock.cr, branch: masterdev

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