Google 个地方 API 比网络搜索差?

Google Places API worse then web search?

我正在尝试使用 Google 地点 API 到 java 对字符串执行文本搜索并检索最有可能被搜索地点的地址。我正在为美国的几个知名地点(例如医院和学校)执行此操作。下面是一个有问题的示例搜索。我拿出我的 API 钥匙。

https://maps.googleapis.com/maps/api/place/textsearch/xml?query=evanston+township+high+school+evanston,+il+usa&key=***********

我取了这个查询第一个结果的formatted_address。这通常是准确的,但我注意到有时它是不正确的。例如,在此查询中没有提供街道地址或邮政编码。我试过其他地方,但我得到的只是 "United States" 或该字段中没有实际数字的地址。但有趣的是,如果我在 Google 中搜索完全相同的字符串,就会出现真正的地址。这是 API 的结果和网络图片:

<PlaceSearchResponse>
<status>OK</status>
<result>
<name>Evanston Township High School District 202</name>
<type>political</type>
<formatted_address>
Evanston Township High School District 202, IL, USA <-------- returned by API
</formatted_address>
<geometry>
<location>
<lat>42.0450722</lat>
<lng>-87.6876969</lng>
</location>
<viewport>
<southwest>
<lat>42.0190300</lat>
<lng>-87.7326600</lng>
</southwest>
<northeast>
<lat>42.0717318</lat>
<lng>-87.6665614</lng>
</northeast>
</viewport>
</geometry>
<icon>
http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png
</icon>
<reference>
CqQBnwAAAMCLODi7Iisb_q4ilw73x1TGrw0Lj1bNS1sdZsmdmEhgKDslWJjlvXeVgxzLLdPWh-     vwaTV9by0aATpWwomOcB55rShH1FiL2UJPBIh9Db7OtJq9ks7qIhYoAvFBf-yaZ5kQo9amqOa8l3WU2V85haHQz80MvblSwGn6WNFHdPGwWxwNjYR3henBT4VuB9h5Od5BLM6PndAsvslfygg0hFQSECqRDvACMS5yfmZ-3d4epaUaFIgkXjNNIYuMwRLmfHmvSPVddoRU
</reference>
<id>82b50159171c4e7686f6b9b05705feee7b2b1305</id>
<place_id>ChIJ5fg1oQLQD4gRqZmJdt4oE7w</place_id>
</result>

然而,

从 google 结果中抓取会给我更准确的地址,这似乎很荒谬。是这种情况还是我忽略了什么?非常感谢任何帮助。

可能只是地点 API 中的错误数据。您可以将 bug to try and get it fixed. In the meantime, you can manually add 位置提交到您的应用程序中。

示例代码:

POST https://maps.googleapis.com/maps/api/place/add/json?key=AddYourOwnKeyHere HTTP/1.1
Host: maps.googleapis.com

{
  "location": {
    "lat": -33.8669710,
    "lng": 151.1958750
  },
  "accuracy": 50,
  "name": "Google Shoes!",
  "phone_number": "(02) 9374 4000",
  "address": "48 Pirrama Road, Pyrmont, NSW 2009, Australia",
  "types": ["shoe_store"],
  "website": "http://www.google.com.au/",
  "language": "en-AU"
}

您也可以尝试对 lat/lng 进行反向地理编码,但我认为这同样不准确。