LocationIQ
- API version: 1.1.0
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.
Automatically generated by the OpenAPI Generator
Building the API client library requires:
- Java 1.7+
- Maven/Gradle
To install the API client library to your local Maven repository, simply execute:
mvn clean install
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
mvn clean deploy
Refer to the OSSRH Guide for more information.
Add this dependency to your project's POM:
<dependency>
<groupId>com.locationiq</groupId>
<artifactId>locationiq-java-client</artifactId>
<version>1.1.0</version>
<scope>compile</scope>
</dependency>
Add this dependency to your project's build file:
compile "com.locationiq:locationiq-java-client:1.1.0"
At first generate the JAR by executing:
mvn clean package
Then manually install the following JARs:
target/locationiq-java-client-1.1.0.jar
target/lib/*.jar
Please follow the installation instruction and execute the following Java code:
// Import classes:
import LocationIq.ApiClient;
import LocationIq.ApiException;
import LocationIq.Configuration;
import LocationIq.auth.*;
import LocationIq.models.*;
import com.locationiq.client.api.AutocompleteApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://eu1.locationiq.com/v1");
// Configure API key authorization: key
ApiKeyAuth key = (ApiKeyAuth) defaultClient.getAuthentication("key");
key.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//key.setApiKeyPrefix("Token");
AutocompleteApi apiInstance = new AutocompleteApi(defaultClient);
String q = "Empire state"; // String | Address to geocode
Integer 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.
Integer limit = 10; // Integer | Limit the number of returned results. Default is 10.
String 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.
Integer bounded = 1; // Integer | Restrict the results to only items contained with the viewbox
String countrycodes = "us"; // String | Limit search to a list of countries.
String acceptLanguage = "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
String 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
try {
List<Object> result = apiInstance.autocomplete(q, normalizecity, limit, viewbox, bounded, countrycodes, acceptLanguage, tag);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AutocompleteApi#autocomplete");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
All URIs are relative to https://eu1.locationiq.com/v1
Class | Method | HTTP request | Description |
---|---|---|---|
AutocompleteApi | autocomplete | GET /autocomplete.php | |
BalanceApi | balance | GET /balance.php | |
DirectionsApi | directions | GET /directions/driving/{coordinates} | Directions Service |
MatchingApi | matching | GET /matching/driving/{coordinates} | Matching Service |
MatrixApi | matrix | GET /matrix/driving/{coordinates} | Matrix Service |
NearestApi | nearest | GET /nearest/driving/{coordinates} | Nearest Service |
ReverseApi | reverse | GET /reverse.php | Reverse Geocoding |
SearchApi | search | GET /search.php | Forward Geocoding |
- Address
- Balance
- Daybalance
- DirectionsDirections
- DirectionsDirectionsRoutes
- DirectionsMatching
- DirectionsMatrix
- DirectionsMatrixSources
- DirectionsNearest
- DirectionsNearestWaypoints
- Error
- Location
- Matchquality
- Namedetails
Authentication schemes defined for the API:
- Type: API key
- API key parameter name: key
- Location: URL query string
It's recommended to create an instance of ApiClient
per thread in a multithreaded environment to avoid any potential issues.