djangofan djangofan - 14 days ago 5
Java Question

How do I get Google Maps "Places API" to return ZIP code information?

How do I get Google Maps "Places API" to return ZIP code information? In all the examples I find on the internet, none of them show results returning that contain a ZIP code. Is there a trick to this or is it not possible?

Answer

This seems like it's returning a "postal code" (4 digits for some reason) in the address_component section:

https://developers.google.com/places/documentation/#PlaceDetailsRequests

However, I think what you're looking for is the Google Geocoding API:

Geocoding is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain View, CA") into geographic coordinates (like latitude 37.423021 and longitude -122.083739), which you can use to place markers or position the map. The Google Geocoding API provides a direct way to access a geocoder via an HTTP request. Additionally, the service allows you to perform the converse operation (turning coordinates into addresses); this process is known as "reverse geocoding."

You can see in the JSON and XML responses a 5-digit postal code:

https://developers.google.com/maps/documentation/geocoding/#JSON