Skip to content
Products
Solutions
By industry
By use case
Resources
Products
Solutions
By industry
By use case
Resources
Products
Solutions
By industry
By use case
Resources
Introducing Plus Codes in Place Autocomplete, Place Details and Geocoding to help you serve users everywhere
Rasťo Šrámek
Software Engineer, Plus Codes
Miguel Ángel Vilela
Technical Solutions Engineer, Google Maps Platform
Apr 28, 2020
Try Google Maps Platform
Unlock access to real-world data and insights with a monthly $200 Google Maps Platform credit.
Get started

Although we’re constantly mapping the world–adding addresses, points of interest, roads, and more–there are many places without traditional addressing systems and some areas with no addresses or road names at all. This can be a challenge for businesses such as food delivery or on-demand transportation, that rely on precise locations to deliver services in these regions. And being able to receive goods and services at your specific location is particularly important right now. 

To address this challenge, we’ve integrated Plus Codes into Place Autocomplete across Places API, Places Library in Maps JavaScript API, Places SDK for Android, and coming soon to Places SDK for iOS. This enables anyone worldwide to use a unique, precise digital address, no matter where in the world they are. Now end users can indicate their precise locations to businesses to receive crucial goods and services that were difficult to access before. And businesses can better serve existing regions or expand their operations to new regions they couldn’t serve before.

But first, what’s a Plus Code? 

A Plus Code is a simple alphanumeric code which can be combined with a locality (for example: CWC8+R9 Mountain View), derived from latitude and longitude coordinates. Anyone can find the Plus Code for any location in the world by dropping a pin in Google Maps and they’re searchable on Google Search and Google Maps. Once someone knows the Plus Codes for their frequented locations, they’re able to use them just like a traditional address. 

Plus codes in Place Autocomplete 

Now that we’ve integrated Plus Codes into Place Autocomplete, when your users want to call a ride, have lunch delivered, or use any other location-based service you’ve developed, your application will automatically start returning Plus Code suggestions once the first letter of the town or locality in a Plus Code address is typed.

Plus Codes in Geocoding and Place Details

The process doesn’t end there. Once your user has selected the autocompleted Plus Code, you can use either Place Details or Geocoding to convert the Plus Code’s Place ID into geographic coordinates. Alternatively, this same Place ID can be used directly in the Directions API and Distance Matrix API to quickly dispatch a driver, schedule delivery, and more.

Here's a sample code snippet of how we implement the above scenario, combining programmatic Place Autocomplete with a Geocoding API request to get the geographic coordinates of an autocomplete-generated Plus Code entered by the user. You can see the same in full context and find other implementation options on GitHub.

/**
* This method demonstrates the programmatic approach to getting place predictions.
* The parameters in this request are currently biased to Kolkata, India.
*
* @param query the plus code query string (e.g. "GCG2+3M K")
*/
private void getPlacePredictions(String query) {
   // The value of `locationBias` biases prediction results to the rectangular
   // region provided (currently Kolkata). Modify these values to get results
   // to another area. Make sure to pass in the appropriate value/s for
   // .setCountries() as in the FindAutocompletePredictionsRequest.Builder
   // object as well.
   LocationBias locationBias = RectangularBounds.newInstance(
       new LatLng(22.458744, 88.208162),
       new LatLng(22.730671, 88.524896));

   // Create a new programmatic Place Autocomplete request in Places SDK for Android
   FindAutocompletePredictionsRequest newRequest = FindAutocompletePredictionsRequest.builder()
       .setLocationBias(locationBias)
       .setQuery(query)
       .setTypeFilter(TypeFilter.ESTABLISHMENT)
       .setCountries("IN")
       .build();

   // Perform autocomplete predictions request
   placesClient.findAutocompletePredictions(newRequest).addOnSuccessListener((response) -> {
       List<AutocompletePrediction> predictions = response.getAutocompletePredictions();
       if (predictions.isEmpty()) {
           Log.w(TAG, "No predictions found");
           return;
       }

       // Perform Geocoding API request from 1st prediction match
       AutocompletePrediction firstPrediction = predictions.get(0);
       geocodePlace(firstPrediction.getPlaceId());
   }).addOnFailureListener((exception) -> {
       if (exception instanceof ApiException) {
           ApiException apiException = (ApiException) exception;
           Log.e(TAG, "Place not found: " + apiException.getStatusCode());
       }
   });
}

// The Volley dispatch queue for network requests. Initialized with an Android Context object
RequestQueue queue;

/**
* Performs a Geocode API request
*
* @param placeID the ID of the Place to geocode
*/
private void geocodePlace(String placeID) {
   // Construct the request URL
   String apiKey = ""; // Your GMP API key
   String url = "https://maps.googleapis.com/maps/api/geocode/json?place_id=%s&key=%s";
   String requestURL = String.format(url, placeID, apiKey);

   // Use the HTTP request URL for Geocoding API to get geographic coordinates for the place
   JsonObjectRequest request = new JsonObjectRequest(Method.GET, requestURL, null,
       response -> {
           try {
               // Inspect the value of "results" and make sure it's not empty
               JSONArray results = response.getJSONArray("results");
               if (results.length() == 0) {
                   Log.w(TAG, "No results from geocoding request.");
                   return;
               }

               // Use Gson to convert the response JSON object to a POJO
               GeocodingResult result = new Gson()
                   .fromJson(results.getString(0), GeocodingResult.class);
               LatLng latLng = result.geometry.location;
               Log.d(TAG, "LatLng for geocoded place: " + latLng);
           } catch (JSONException e) {
               e.printStackTrace();
           }
       }, error -> Log.e(TAG, "Request failed"));

   // Add the request to the Request queue.
   queue.add(request);
}
Copied to clipboard!

Geocoding now also accepts Plus Codes as the address request parameter and will return the same Plus Code as a fully populated Geocoding result. For example, a Geocoding request with address=GCG2%2B3M%20Kolkata will return a result with the Plus Code formatted as both a global code and as a compound code, along with place_id: "GhIJm8QgsHKGNkARke18P7UZVkA".

With Plus Codes in Place Autocomplete, Place Details, Directions and Geocoding, you’re able to pick up or drop off your users and deliver food to their table no matter where in the world they are–helping businesses serve users where they currently operate and expand into new regions worldwide. 

Learn more from our YouTube video and see the documentation on Place Autocomplete in the Places API, Places SDK for Android, Places SDK for iOS, and Places Library, Maps JavaScript API. Documentation for the Geocoding API provides details about how Plus Codes can be used in Geocoding requests and responses. 

For more information on Google Maps Platform, visit our website.

Clay cityscape
Clay cityscape
Google Maps Platform
Get going with Google Maps Platform