ExGoogle
Google Cloud SDK for Elixir
This is a work in progress. Currently, it supports google places and maps API.
Installation
If available in Hex, the package can be installed as:
- Add
ex_google
to your list of dependencies inmix.exs
:
def deps do
[{:ex_google, "~> 0.1.1"}]
end
Or from github (recommended for now):
def deps do
[{:ex_google, github: "techgaun/ex_google"}]
end
- Ensure
ex_google
is started before your application:
def application do
[applications: [:ex_google]]
end
Configuration
Configure
ex_google
using the appropriate api key and output format. Currently, only json output is supported. Other formats parser are more than welcome.- Now, you can use the places and maps api.
config :ex_google, api_key: System.get_env("GOOGLE_API_KEY"),
output: "json"
Usage
You can import and use the google places and maps api as below. Also, note that you can pass any query parameter that google apis support.
Google Maps
alias ExGoogle.Maps.Api, as: Maps
# google maps reverse geocoding
Maps.search(%{latlng: "40.714224,-73.961452"})
# google maps geocoding
Maps.search(%{address: "1600 Amphitheatre Parkway, Mountain View, CA"})
# Advanced parameters
Maps.search(%{latlng: "40.714224,-73.961452", location_type: "ROOFTOP|RANGE_INTERPOLATED|GEOMETRIC_CENTER", result_type: "street_address"})
Google Places
alias ExGoogle.Places.Api, as: Places
# place detail search
Places.search(%{placeid: "ChIJL_zTW3FdvIcR2qmNStcaCdA"})
# text search
Places.search(%{query: "Restaurant"}, :text)
# nearby search
Places.search(%{location: "38,-94", radius: 1000}, :nearby)