Google Places API: Searching for names containing spaces

爷,独闯天下 提交于 2019-12-09 13:58:26

问题


Is it possible to search for names containing spaces?

name: ['Burger King|Subway']  //fails
name: ['McDonald|Subway|Chipotle'] // works

https://maps.googleapis.com/maps/api/place/search/json?location=33.4,-112.0&radius=5000&name=McDonald|Subway|Chipotle&sensor=false&key=yourkeyhere

Thanks!


回答1:


Performing a Places Search Request with multiple keywords or names is not officially supported by the Places API therefore is not guaranteed to return accurate results.

If you believe support for multiple keywords or names would be a useful feature, please file a 'Places API - Feature Request' here.




回答2:


As SKAR said, add %22 when you have spaces. Your search term, instead of Burger King, becomes "Burger King".

URL, as suggested by SKAR:

https://maps.googleapis.com/maps/api/place/nearbysearch/xml?location=-41.21545,174.89416&radius=10000&name=%22strike%20entertainment%20centre%22&sensor=true&key=[YourKey]

Do not replace your %20 (Spaces) by %22, but add them before and after your search term.

Cheers




回答3:


Use "+" if there is space inbetween the name -

https://maps.googleapis.com/maps/api/place/search/json?location=33.4,-112.0&radius=5000&name=Burger+King&sensor=false&key=YourKey



回答4:


Add %22 (quotes) when you have spaces

e.g. https://maps.googleapis.com/maps/api/place/nearbysearch/xml?location=-41.21545,174.89416&radius=10000&name=strike%22entertainment%22centre&sensor=true&key=[YourKey]

Thanks, SKAR



来源:https://stackoverflow.com/questions/10903363/google-places-api-searching-for-names-containing-spaces

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