LocationIQClient - the Ruby gem for the LocationIQ
LocationIQ provides flexible enterprise-grade location based solutions. We work with developers, startups and enterprises worldwide serving billions of requests everyday. This page provides an overview of the technical aspects of our API and will help you get started.
This SDK is automatically generated by the OpenAPI Generator project:
- API version: 1.1.0
- Package version: 1.1.0
- Build package: org.openapitools.codegen.languages.RubyClientCodegen
To build the Ruby code into a gem:
gem build locationiq-ruby-client.gemspec
Then either install the gem locally:
gem install ./locationiq-ruby-client-1.1.0.gem
(for development, run gem install --dev ./locationiq-ruby-client-1.1.0.gem
to install the development dependencies)
or publish the gem to a gem hosting service, e.g. RubyGems.
Finally add this to the Gemfile:
gem 'locationiq-ruby-client', '~> 1.1.0'
If the Ruby gem is hosted at a git repository: https://github.com/location-iq/locationiq-ruby-client, then add the following in the Gemfile:
gem 'locationiq-ruby-client', :git => 'https://github.com/location-iq/locationiq-ruby-client.git'
Include the Ruby code directly using -I
as follows:
ruby -Ilib script.rb
Please follow the installation procedure and then run the following code:
# Load the gem
require 'locationiq-ruby-client'
# Setup authorization
LocationIQClient.configure do |config|
# Configure API key authorization: key
config.api_key['key'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
#config.api_key_prefix['key'] = 'Bearer'
end
api_instance = LocationIQClient::AutocompleteApi.new
q = 'Empire state' # String | Address to geocode
normalizecity = 1 # Integer | For responses with no city value in the address section, the next available element in this order - city_district, locality, town, borough, municipality, village, hamlet, quarter, neighbourhood - from the address section will be normalized to city. Defaults to 1 for SDKs.
opts = {
limit: 10, # Integer | Limit the number of returned results. Default is 10.
viewbox: '-132.84908,47.69382,-70.44674,30.82531', # String | The preferred area to find search results. To restrict results to those within the viewbox, use along with the bounded option. Tuple of 4 floats. Any two corner points of the box - `max_lon,max_lat,min_lon,min_lat` or `min_lon,min_lat,max_lon,max_lat` - are accepted in any order as long as they span a real box.
bounded: 1, # Integer | Restrict the results to only items contained with the viewbox
countrycodes: 'us', # String | Limit search to a list of countries.
accept_language: 'en', # String | Preferred language order for showing search results, overrides the value specified in the Accept-Language HTTP header. Defaults to en. To use native language for the response when available, use accept-language=native
tag: 'place' # String | Restricts the autocomplete search results to elements of specific OSM class and type. Example - To restrict results to only class place and type city: tag=place:city, To restrict the results to all of OSM class place: tag=place
}
begin
result = api_instance.autocomplete(q, normalizecity, opts)
p result
rescue LocationIQClient::ApiError => e
puts "Exception when calling AutocompleteApi->autocomplete: #{e}"
end
All URIs are relative to https://eu1.locationiq.com/v1
Class | Method | HTTP request | Description |
---|---|---|---|
LocationIQClient::AutocompleteApi | autocomplete | GET /autocomplete.php | |
LocationIQClient::BalanceApi | balance | GET /balance.php | |
LocationIQClient::DirectionsApi | directions | GET /directions/driving/{coordinates} | Directions Service |
LocationIQClient::MatchingApi | matching | GET /matching/driving/{coordinates} | Matching Service |
LocationIQClient::MatrixApi | matrix | GET /matrix/driving/{coordinates} | Matrix Service |
LocationIQClient::NearestApi | nearest | GET /nearest/driving/{coordinates} | Nearest Service |
LocationIQClient::ReverseApi | reverse | GET /reverse.php | Reverse Geocoding |
LocationIQClient::SearchApi | search | GET /search.php | Forward Geocoding |
- LocationIQClient::Address
- LocationIQClient::Balance
- LocationIQClient::Daybalance
- LocationIQClient::DirectionsDirections
- LocationIQClient::DirectionsDirectionsRoutes
- LocationIQClient::DirectionsMatching
- LocationIQClient::DirectionsMatrix
- LocationIQClient::DirectionsMatrixSources
- LocationIQClient::DirectionsNearest
- LocationIQClient::DirectionsNearestWaypoints
- LocationIQClient::Error
- LocationIQClient::Location
- LocationIQClient::Matchquality
- LocationIQClient::Namedetails
- Type: API key
- API key parameter name: key
- Location: URL query string