开发者

Getting full address from business name -- Google Maps API

开发者 https://www.devze.com 2023-01-06 01:29 出处:网络
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 insta

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 开发者_Python百科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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号