简体   繁体   中英

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. 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.

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. 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. Here is the results from the API and a picture from the web:

<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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM