简体   繁体   中英

Is it possible to exclude some 'types' from the Google Places API responses?

I have a travel site that lists the POI of each city. So I use the Google Places API to return points of interest like this:

 https://maps.googleapis.com/maps/api/place/search/json?location=45.8150108,15.981919&radius=10000&types=point_of_interest&hasNextPage=true&nextPage()=true&sensor=false&key=My_Key

However, in addition to POI it returns other types like this:

  "types": [
    "travel_agency",
    "real_estate_agency",
    "lodging",
    "point_of_interest",
    "establishment"
  ],

Which causes returning things like hotels and offices instead of just POI, is there a way to force return just POI ? I tried using type instead of types but it still returns other types .

Currently you cannot exclude certain types from Places API searches. There is a feature request in the public issue tracker to add this functionality.

https://issuetracker.google.com/issues/35822993

You can star this feature request to add your vote and subscribe to further notifications.

Please note that endpoint https://maps.googleapis.com/maps/api/place/search/json is not documented.

There are following endpoints for Places API searches :

  • Nearby search https://maps.googleapis.com/maps/api/place/nearbysearch/output?parameters
  • Radar search https://maps.googleapis.com/maps/api/place/radarsearch/output?parameters
  • Text search https://maps.googleapis.com/maps/api/place/textsearch/output?parameters

You should use one of them. Also the types parameter was deprecated in February 2016:

https://developers.google.com/places/web-service/search#deprecation

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