♪ [music] ♪ How's it going,
Google Maps Platform developers? Today, I want to tell you
about the Geocoding API. The Geocoding API is a service that provides geocoding
and reverse geocoding of addresses. But my fourth grade teacher taught me that you should never use a word
in that word's definition. So allow me to briefly explain geocoding. Geocoding is the process
of converting addresses, like a street address,
into geographic coordinates like latitude and longitude. When using Google Maps Platform, some common uses of geocodes
are to place markers on a map or center a map at a precise location. Reverse geocoding is,
naturally, the reverse. It's the process of converting
geographic coordinates into a human readable address. This can be useful for a lot of things. For example, let's say you know a user's latitude
and longitude coordinates because they've given you permission
to access their geolocation. Using reverse geolocation, you can convert that
into a human readable address, or a business, or a place name, to make the information
more useful when displayed. So the Geocoding API let's you convert
addresses to coordinates and coordinates to addresses. You can also use the Geocoding API to find the address for a given place ID returned by the Places API. You access the Geocoding API
through an HTTP interface. But geocoding is also available as part of the client-side
Google Maps JavaScript API, as well as for server-side use with the Java, Python, Go,
and Node.js utility libraries available in the Google Maps org
on GitHub at the link below. First, I want to focus
on accessing the Geocoding API via HTTP requests. Let's look at examples of geocoding
and reverse geocoding requests. If you want to try
the examples for yourself, you'll need an API key. Find out how to generate
your API key in the <i>Geocast</i> episode, <i>How to generate and restrict API keys
for Google Maps Platform</i>, which I've linked below. Now, here is a request
for the Geocoding API. This address is 1600 Amphitheater Parkway,
Mountain View, California. And <i>/json</i> specifies that the output
must be in JSON format. Notice that you include
your API key as well. I can test this by entering the URL
into my web browser. You can see here that the response includes the latitude
and longitude of the address. Now, let's look at a reverse
geocoding example. This URL requests the address corresponding to a given
latitude and longitude in Brooklyn, New York, USA. It specifies that the output
must be in JSON format, just like our geocoding example. When I enter the URL in my browser, the response includes
a human readable address for the latitude and longitude location. Notice also that the result
includes properties that give you the fully formatted address in the <i>formatted_address</i> property, as well as the address
broken into components in the <i>address_components</i> array. And there you have it. You can now easily make a request
to geocode and reverse geocode using the Geocoding API. For more information on geocoding
with the REST API or client SDKs, check out the documentation linked below. Thanks for watching. ♪ [music] ♪