All Projects → googlemaps → Google Maps Services Java

googlemaps / Google Maps Services Java

Licence: apache-2.0
Java client library for Google Maps API Web Services

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Google Maps Services Java

Rosrust
Pure Rust implementation of a ROS client library
Stars: ✭ 355 (-76.29%)
Mutual labels:  client-library
Standardfile
Yet Another Standardfile (standardnotes server) Implementation written in Golang
Stars: ✭ 34 (-97.73%)
Mutual labels:  client-library
Octonode
github api v3 in nodejs
Stars: ✭ 1,126 (-24.78%)
Mutual labels:  client-library
Phrets
PHP client library for interacting with a RETS server to pull real estate listings, photos and other data made available from an MLS system
Stars: ✭ 416 (-72.21%)
Mutual labels:  client-library
M2x Python
AT&T M2X Python Library
Stars: ✭ 25 (-98.33%)
Mutual labels:  client-library
Gomusicbrainz
a Go (Golang) MusicBrainz WS2 client library - work in progress
Stars: ✭ 42 (-97.19%)
Mutual labels:  client-library
Etcd3
🔖 Node.js client for etcd3
Stars: ✭ 336 (-77.56%)
Mutual labels:  client-library
Google Api Nodejs Client
Google's officially supported Node.js client library for accessing Google APIs. Support for authorization and authentication with OAuth 2.0, API Keys and JWT (Service Tokens) is included.
Stars: ✭ 9,722 (+549.43%)
Mutual labels:  client-library
Ably Go
Go client library SDK for Ably realtime messaging service
Stars: ✭ 29 (-98.06%)
Mutual labels:  client-library
Goodreads Dotnet
📚 Goodreads .NET API Client Library
Stars: ✭ 45 (-96.99%)
Mutual labels:  client-library
Cs16 Client
Counter-Strike 1.6 rewritten client.dll. Without VGUI, ParticleMan and ecology friendy.
Stars: ✭ 449 (-70.01%)
Mutual labels:  client-library
Github Api
Java API for GitHub
Stars: ✭ 743 (-50.37%)
Mutual labels:  client-library
Ldaptive
A simple, extensible Java API for interacting with LDAP servers
Stars: ✭ 43 (-97.13%)
Mutual labels:  client-library
Pynsq
The official Python client library for NSQ
Stars: ✭ 393 (-73.75%)
Mutual labels:  client-library
Libnsq
async C client library for NSQ
Stars: ✭ 75 (-94.99%)
Mutual labels:  client-library
Agollo
🚀Go client for ctrip/apollo (https://github.com/ctripcorp/apollo)
Stars: ✭ 348 (-76.75%)
Mutual labels:  client-library
Localstack Dotnet Client
A lightweight .NET client for LocalStack
Stars: ✭ 40 (-97.33%)
Mutual labels:  client-library
Ably Js
Javascript, Node, Typescript client library SDK for Ably realtime messaging service
Stars: ✭ 99 (-93.39%)
Mutual labels:  client-library
Mariadbpp
C++ client library for MariaDB.
Stars: ✭ 76 (-94.92%)
Mutual labels:  client-library
Unleash Client Python
Unleash client for Python 💡💡💡
Stars: ✭ 44 (-97.06%)
Mutual labels:  client-library

Java Client for Google Maps Services

Build Status Coverage Status Maven Central Version Javadocs GitHub contributors Stack Exchange questions

Description

Use Java? Want to geocode something? Looking for directions? Maybe matrices of directions? This library brings the Google Maps API Web Services to your server-side Java application. Analytics

The Java Client for Google Maps Services is a Java Client library for the following Google Maps APIs:

Keep in mind that the same terms and conditions apply to usage of the APIs when they're accessed through this library.

Requirements

  • Java 1.8 or later.
  • A Google Maps API key.

API keys

Each Google Maps Web Service request requires an API key. API keys are generated in the 'Credentials' page of the 'APIs & Services' tab of Google Cloud console.

For even more information on getting started with Google Maps Platform and generating an API key, see Get Started with Google Maps Platform in our docs.

API Key Security

The Java Client for Google Maps Services is designed for use in both server and Android applications. In either case, it is important to add API key restrictions to improve the security of your API key. Additional security measures, such as hiding your key from version control, should also be put in place to further improve the security of your API key.

You can refer to API Security Best Practices to learn more about this topic.

NOTE: If you are using this library on Android, ensure that your application is using at least version 0.19.0 of this library so that API key restrictions can be enforced.

Installation

You can add the library to your project via Maven or Gradle.

Note: Since 0.1.18 there is now a dependency on SLF4J. You need to add one of the adapter dependencies that makes sense for your logging setup. In the configuration samples below we are integrating slf4j-nop, but there are others like slf4j-log4j12 and slf4j-jdk14 that will make more sense in other configurations. This will stop a warning message being emitted when you start using google-maps-services.

Maven

<dependency>
  <groupId>com.google.maps</groupId>
  <artifactId>google-maps-services</artifactId>
  <version>(insert latest version)</version>
</dependency>
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-simple</artifactId>
  <version>1.7.25</version>
</dependency>

Gradle

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.google.maps:google-maps-services:(insert latest version)'
    implementation 'org.slf4j:slf4j-simple:1.7.25'
}

You can find the latest version at the top of this README or by searching Maven Central.

Developer Documentation

View the javadoc.

Additional documentation for the included web services is available at https://developers.google.com/maps/.

Usage

This example uses the Geocoding API with an API key:

GeoApiContext context = new GeoApiContext.Builder()
    .apiKey("AIza...")
    .build();
GeocodingResult[] results =  GeocodingApi.geocode(context,
    "1600 Amphitheatre Parkway Mountain View, CA 94043").await();
Gson gson = new GsonBuilder().setPrettyPrinting().create();
System.out.println(gson.toJson(results[0].addressComponents));

// Invoke .shutdown() after your application is done making requests
context.shutdown();

Note: The GeoApiContext is designed to be a Singleton in your application. Please instantiate one on application startup, and continue to use it for the life of your application. This will enable proper QPS enforcement across all of your requests.

At the end of the execution, call the shutdown() method of GeoApiContext, otherwise the thread will remain instantiated in memory.

For more usage examples, check out the tests.

Features

Google App Engine Support

To use Google App Engine with this client library add the latest App Engine dependency to your build.gradle file:

dependencies {
    implementation 'com.google.appengine:appengine-api-1.0-sdk:<latest version>'
}

You can then use this client library on Google App Engine with the following code change:

new GeoApiContext.Builder(new GaeRequestHandler.Builder())
    .apiKey("AIza...")
    .build();

The new GaeRequestHandler.Builder() argument to GeoApiContext.Builder's requestHandlerBuilder tells the Java Client for Google Maps Services to utilise the appropriate calls for making HTTP requests from Google App Engine, instead of the default OkHttp3 based strategy.

Rate Limiting

Never sleep between requests again! By default, requests are sent at the expected rate limits for each web service, typically 50 queries per second for free users. If you want to speed up or slow down requests, you can do that too, using new GeoApiContext.Builder().queryRateLimit(qps).build(). Note that you still need to manually handle the delay between the initial request and successive pages when you're paging through multiple result sets.

Retry on Failure

Automatically retry when intermittent failures occur. That is, when any of the retriable 5xx errors are returned from the API.

To alter or disable automatic retries, see these methods in GeoApiContext:

  • .disableRetries()
  • .maxRetries()
  • .retryTimeout()
  • .setIfExceptionIsAllowedToRetry()

POJOs

Native objects for each of the API responses.

Asynchronous or synchronous -- you choose

All requests support synchronous or asynchronous calling style.

GeocodingApiRequest req = GeocodingApi.newRequest(context).address("Sydney");

// Synchronous
try {
    req.await();
    // Handle successful request.
} catch (Exception e) {
    // Handle error
}

req.awaitIgnoreError(); // No checked exception.

// Async
req.setCallback(new PendingResult.Callback<GeocodingResult[]>() {
  @Override
  public void onResult(GeocodingResult[] result) {
    // Handle successful request.
  }

  @Override
  public void onFailure(Throwable e) {
    // Handle error.
  }
});

Building the Project

Note: You will need an API key or Client ID to run the tests.

# Compile and package the project
$ ./gradlew jar

# Run the tests
$ ./gradlew test

Support

This library is community supported. We're comfortable enough with the stability and features of the library that we want you to build real production applications on it. We will try to support, through Stack Overflow, the public and protected surface of the library and maintain backwards compatibility in the future; however, while the library is in version 0.x, we reserve the right to make backwards-incompatible changes. If we do remove some functionality (typically because better functionality exists or if the feature proved infeasible), our intention is to deprecate and give developers a year to update their code.

If you find a bug, or have a feature suggestion, please log an issue. If you'd like to contribute, please read How to Contribute.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].