Google Geocoding APIs support plus codes

140 views
Skip to first unread message

Doug Rinckes

unread,
Sep 25, 2018, 6:01:26 AM9/25/18
to open-location-code EXTERNAL
The Google Geocoding API now supports plus codes in addresses, and includes them in responses. This has required a big effort by the team and I'm really excited by this.

I'm going to provide some information about the API, and some caveats. As always, if you send me feedback I can work with the API team to make changes.

This is primarily about Google's Web Services Geocoding API. I'm also going to mention the Javascript Geocoding API, but not the Android, iOS or any other geocoding SDK yet since I haven't done any testing myself.

The first change is that each result may* include a plus code. For example, doing a geocoding search for Google Zurich contains:

"plus_code" : {
   "compound_code" : "9G8F+6W Zürich, Switzerland",
   "global_code" : "8FVC9G8F+6W"
},

*Some results will not include plus codes, such as political features, or large natural features.

Converting a plus code to a location
If the address parameter is a global code, or a local code and locality, the API returns a single result, with no address components, no formatted address and no types.The location field gives the code centre:
{
   "results" : [
      {
         "address_components" : [],
         "formatted_address" : "",
         "geometry" : {
            "location" : {
               "lat" : 47.3655625,
               "lng" : 8.524812499999999
            },
            "location_type" : "APPROXIMATE",
            "viewport" : { ... }
            }
         },
         "place_id" : "ChIJAAAAAAAAAAARAAAAAAAAAAA",
         "types" : []
      }
   ],
   "status" : "OK"
}
Converting a location to a plus code
When you do a reverse lookup to the web service API, it converts the latitude and longitude into a 10 digit plus code. This is returned outside of the results list so it did not affect existing behaviour:

{
   "plus_code" : {
      "compound_code" : "9G8F+6W Zürich, Switzerland",
      "global_code" : "8FVC9G8F+6W"
   },
   "results" : [ ... ]

Caveats:
  1. Only 10-digit codes are returned by the API.
  2. The viewport coordinates in the response to a plus code search, are not the bounds of the plus code box.
  3. Converting a location to a plus code is only possible with the web service API. The javascript API only returns the result list and the status code, although we're working on this.
Please try it out and let me know what you think!

Ngā mihi,
Doug Rinckes, Technical Program Manager, Google Switzerland GmbH; 9G8F+6W Zürich

Jeffrey Duncan

unread,
Apr 4, 2019, 7:03:56 PM4/4/19
to Plus Codes Community Forum
As this is intended to go mainstream, hopefully, is there a way for me to quickly convert all of the address that I have into plus+codes?  And then, can I reverse that to get the street address again, afterward?

Barry Hunter

unread,
Apr 4, 2019, 7:17:14 PM4/4/19
to Plus Codes Community Forum
If you have coordinates for the addresses should just be able to 'convert' them direct to the plus code. There are code libraries to do this

If you don't have coordinates, would have to obtain them. eg using a Geocoder. The Google Geocoder just does this in one step, provides the coordinate and immediately convert it to plus code for you. 

In this regard the Google provided Geocoder might not be the best solution. The terms of use, might prevent you storing the plus code obtained!
 Customer will not extract, export, scrape, or cache Google Maps Content for use outside the Services.  For example, Customer will not:(i) pre-fetch, index, store, reshare, or rehost Google Maps Content outside the services; (ii) bulk download geocodes; ...
 
which kinda hinders its utility!


Not saying the Google Geocoding API doesn't have its uses in relation to plus codes. But 'bulk geocoding' an address database for use outside Google Maps is not one of them. 



You can 'reverse' or decode a plus code to get a coordinate, but not an address. But again could use a reverse geocoder, to get an address from the coordinate. 



--
Public site: http://www.openlocationcode.com/
Github project: https://github.com/google/open-location-code
Demo site: http://plus.codes/
---
You received this message because you are subscribed to the Google Groups "Plus Codes Community Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-location-c...@googlegroups.com.
To post to this group, send email to open-loca...@googlegroups.com.
Visit this group at https://groups.google.com/group/open-location-code.
To view this discussion on the web, visit https://groups.google.com/d/msgid/open-location-code/2d7724aa-77fa-44d9-96c1-b19fad1826b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages