Skip to content

liepaja/google-maps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

google-places

Crystal wrapper around the Google Places API

Installation

Add this to your application's shard.yml:

dependencies:
  google-places:
    github: liepaja/google-places

Usage

require "google-places"

Place Autocomplete

https://developers.google.com/places/web-service/autocomplete

Default options

#GooglePlaces::Api::Client.new(api_key : String, @format = Formats::Json, tls = true)
client = GooglePlaces::Api::Client.new("AIzaSyAdutrZU_b83yb4Otn-6yuJ79QvFR9anIM") # Xml currently not supported 

response = client.autocomplete("Riga")
response.status # Ok
response.predictions[0].description # Riga, Latvia

Custom options

client = GooglePlaces::Api::Client.new("AIzaSyAdutrZU_b83yb4Otn-6yuJ79QvFR9anIM")

response = client.autocomplete("Riga", {"types" => "(cities)", "language" => "nl"})
response.status # Ok
response.predictions[0].description # Riga, Letland

OpenSSL workaround

# Some users face OpenSSL issues, in this case tls can be made insecure
client = GooglePlaces::Api::Client.new("AIzaSyAdutrZU_b83yb4Otn-6yuJ79QvFR9anIM", GooglePlaces::Formats::Json, tls = false)

Development

  • Expand api
  • Write tests
  • Solve OpenSSL issues

Contributing

  1. Fork it ( https://github.com/liepaja/google-places/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • liepaja Ernests Elksnis - creator, maintainer

Releases

No releases published

Packages

No packages published