[英]Google Places API worse then web search?
I am trying to use the Google Places API through java to perform a text search on a string and retrieve the most likely address for the place that was searched. 我正在尝试通过Java使用Google Places API对字符串执行文本搜索,并为搜索到的位置检索最可能的地址。 I am doing this for several well known locations in the United States such as hospitals and schools.
我正在美国几个知名的地方(例如医院和学校)这样做。 An example search that has problems is the one below.
以下是一个有问题的示例搜索。 I took out my API key.
我拿出我的API密钥。
https://maps.googleapis.com/maps/api/place/textsearch/xml?query=evanston+township+high+school+evanston,+il+usa&key= *********** https://maps.googleapis.com/maps/api/place/textsearch/xml?query=evanston+township+high+school+evanston,+il+usa&key= ***********
I take the formatted_address of the first result of this query. 我将获取此查询的第一个结果的formatted_address。 This is generally accurate but I have noticed that sometimes it isn't correct.
这通常是准确的,但我注意到有时是不正确的。 For example, in this query there is no street address or zip code provided.
例如,在此查询中,没有提供街道地址或邮政编码。 I have tried other places and all I get is "United States" or the address without the actual number in this field.
我已经尝试过其他地方,但得到的只是“美国”或该字段中没有实际号码的地址。 But interestingly if I search the exact same string in Google the true address does come up.
但是有趣的是,如果我在Google中搜索完全相同的字符串,则会显示真实地址。 Here is the results from the API and a picture from the web:
这是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>
However, 然而,
It seems ridiculous that scraping from google results would give me more accurate addresses. 从Google搜索结果中抓取信息会给我更准确的地址,这似乎很可笑。 Is this the case or am I overlooking something?
是这种情况还是我忽略了什么? Any help is greatly appreciated.
任何帮助是极大的赞赏。
It's possible that it's just bad data in the Places API. 在Places API中,可能只是不良数据。 You can file a bug to try and get it fixed.
您可以提交错误以尝试修复它。 In the meantime, you can manually add the location into your application.
同时,您可以将位置手动添加到应用程序中。
Sample code: 样例代码:
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"
}
You can also try doing something like reverse geocoding the lat/lng you get, but I think that will be equally as inaccurate. 您还可以尝试对反向的经纬度进行地理编码等操作,但是我认为这同样不准确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.