3

I've been playing around with the Google Maps API and so far it's awesome, but I've run into my first snag. I need a way to get the full address for a business name in a city & state. For instance, searching for "The Troubadour, West Hollywood CA" in Google maps (maps.google.com) gives me the full address: 9081 Santa Monica Boulevard - West Hollywood, CA 90069 The trouble is, I can't find a way to do this through the API. I've looked around on the net and at similar questions on SO, but I can't find anything that answers my question. I can successfully get the lat/lon with geocoding, but I need a way to get the exact address based on the business name. Is this possible?

Thanks in advance for any advice!

rainbowFish
  • 265
  • 3
  • 13
  • I asked a similar question - did you ever find a solution? The below answer looks not to work. http://stackoverflow.com/q/34550057/1840471 – Max Ghenis Jan 04 '16 at 04:13

1 Answers1

3

Doesn't the output of the Google Geocoding API return the full address?

According to Google:

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."

Emphasis mine.

The XML response seems like it does.

  <formatted_address>1600 Amphitheatre Pkwy, 
        Mountain View, CA 94043, USA</formatted_address> 
  <address_component> 
    <long_name>1600</long_name> 
    <short_name>1600</short_name> 
    <type>street_number</type> 
  </address_component> 
  <address_component> 
    <long_name>Amphitheatre Pkwy</long_name> 
    <short_name>Amphitheatre Pkwy</short_name> 
    <type>route</type> 
  </address_component> 
  <address_component> 
    <long_name>Mountain View</long_name> 
    <short_name>Mountain View</short_name> 
    <type>locality</type> 
    <type>political</type> 
  </address_component>
  ... 

if not, you could try using the Google Directions API.

Part of the XML output, as well as the JSON output, includes addresses. Here's part of Google's example XML output.

<start_address>Oklahoma City, OK, USA</start_address> 
<end_address>Los Angeles, CA, USA</end_address> 

I don't know if you would have to make up one of the addresses, or if you could calculate a route with the same start and end point.

gdvalderrama
  • 713
  • 1
  • 17
  • 26
Gilbert Le Blanc
  • 50,182
  • 6
  • 67
  • 111
  • 1
    The two links provided are now broken. The current Maps API HTTP result fails for OP's example: http://maps.google.com/maps/api/geocode/json?address=The%20Troubadour,%20West%20Hollywood%20CA only shows West Hollywood, not an address. – Max Ghenis Jan 04 '16 at 04:08
  • 1
    According to the Geocoding API documentation: `Additional address elements such as business names and unit, suite or floor numbers should be avoided.` – gdvalderrama Jun 09 '16 at 08:29