tags:

views:

21

answers:

1

Hi guys, 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!

A: 

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.

Gilbert Le Blanc