Simple Java library for Google Geocoding API.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


License: MIT Build status Quality Gate GitHub tag Maven Central

Simple Java library for the Google Geocoding API.


The library is distributed from the Maven Central Repository since the release of the version 2.0. Just include the following dependency in your pom.xml in order to use the library:


Code examples

GoogleGeocode googleGeocode = new GoogleGeocode(your_api_key, address); // the address must not be encoded
String jsonString = googleGeocode.getJsonString(); // may throw IOException

Alternatively, an object representing the Google Geocoding API json response can be returned:

GoogleGeocode googleGeocode = new GoogleGeocode(your_api_key, latitude, longitude); // reverse geocoding
GeocodeResponse geocodeResponse = googleGeocode.getResponseObject(); // may throw IOException

This object is usefull to get the response content:

if (googleResponse.isStatusOK()) {
   String country = getCountryShortName(); // returns the country short name of the first result
   // more code

Any result in the list of results can be accessed through two ways:

// returns the formatted address of the third result
// or null if the index is out of bounds
String formattedAddress = geocodeResponse.getFormattedAddress();


// returns the geometry object of the position in the results list defined by the index parameter
// or null if it is out of bounds
Geometry geometry = geocodeResponse.getGeometry(index);

The Google Geocoding API language parameter can also be defined:

GoogleGeocode googleGeocode = new GoogleGeocode(your_api_key, address);

Enjoy! 😄