Unable to use the table #2 types with Google Places API

匿名 (未验证) 提交于 2019-12-03 08:30:34

问题:

I am unable to get any results with the Places API when I use a types=transit_station|neighborhood (or any other type included in the table 2 here: http://code.google.com/apis/maps/documentation/places/supported_types.html#table2

Apparently, this is not related to a specific location (I've tried both Milan, Italy and London, GB), so I'm wondering if I'm doing something wrong or if the API is not currently working as expected.

If the above has no solution, I'd be very happy if there was another way of finding the neighborhood of a building (for instance, in this map: http://g.co/maps/hfdke I'd like to be able to find "Fiera Campionaria", "Il Portello" etc).

回答1:

First of all:

Keep in mind that you only can find a place that has been created by somebody. Also remember that the places-API is experimental.


I also didn't find any place of type neighborhood in Milan or London.

But I find them e.g. in Paris, New York, Washington, so you may test your application there.


What I realized while playing around with the API: When I define the range to search for by location and radius the results often are very inaccurate.

For example I search for a neighborhood starting by a point in radius of 5km, it will find a neighborhood in 4km but not in 400m.

The results are much more exactly when I search within LatLngBounds



回答2:

What you are looking for are sublocality's, this can be confirmed through a Places Autocomplete API request:

Input "Fiera Campionaria" returns "Fiera Campionaria, Milano, Italia" with types "sublocality", "political", "geocode": https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Fiera%20Campionaria&sensor=false&key=your_api_key

Input "Il Portello" returns "Il Portello, Milano, Italia" with types "sublocality", "political", "geocode": https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Il%20Portello&sensor=false&key=your_api_key

Unfortunately a Places API Search request in this area with types specified as "sublocality|political|geocode" does not return these results: https://maps.googleapis.com/maps/api/place/search/json?location=45.47536640,9.15523110&radius=3000&sensor=false&types=sublocality|political|geocode&key=your_api_key

I have reported this Internally as a bug.

Cheers

Chris



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!