从商家名称获取完整地址 - Google Maps API [英] Getting full address from business name -- Google Maps API

查看:108
本文介绍了从商家名称获取完整地址 - Google Maps API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在玩Google Maps API,到目前为止它非常棒,但我遇到了我的第一个障碍。我需要一种方法来获得城市和城市中企业名称的完整地址。州。例如,在谷歌地图(maps.google.com)中搜索The Westin Hollywood CATroubadour,给了我完整的地址:9081 Santa Monica Boulevard - West Hollywood,CA 90069
麻烦的是, t找到一种方法来通过API来做到这一点。我在网上查了一下,发现了类似的问题,但我找不到任何回答我的问题的东西。我可以通过地理编码成功获取经纬度,但我需要一种方法根据商家名称获取确切的地址。这可能吗?



在此先感谢您的任何建议! 解决方案

Google Geocoding API 的输出结果不是 strong>返回完整的地址?



据Google称: b
$ b


地理编码是将地址(如1600 Amphitheatre Parkway,Mountain View,CA)转换为地理坐标(如纬度37.423021和经度-122.083739),您可以使用它来放置标记或放置地图。 Google Geocoding API提供了一种通过HTTP请求访问地理编码器的直接方式。此外,该服务允许您执行逆向操作(将坐标转换为地址);这个过程被称为反向地理编码。


强调我的意思。



XML响应看起来像是这样。

 < formatted_address> 1600露天剧场Pkwy,
Mountain View,CA 94043 ,美国< / formatted_address>
< address_component>
< long_name> 1600< / long_name>
< short_name> 1600< / short_name>
< type> street_number< / type>
< / address_component>
< address_component>
< long_name>圆形露天剧场Pkwy< / long_name>
< short_name> Amphitheatre Pkwy< / short_name>
< type>路由< / type>
< / address_component>
< address_component>
< long_name> Mountain View< / long_name>
< short_name> Mountain View< / short_name>
< type> locality< / type>
< type>政治< / type>
< / address_component>
...

如果不是,您可以尝试使用 Google Directions API

部分XML输出以及JSON输出包含地址。这是Google的示例XML输出的一部分。

 < start_address>美国俄克拉何马城OK< / start_address> 
< end_address>美国加利福尼亚州洛杉矶< / end_address>

我不知道您是否必须补写其中一个地址,或者您是否可以计算具有相同起点和终点的路线。


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!

解决方案

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.

这篇关于从商家名称获取完整地址 - Google Maps API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆