首页 文章

Google Places API:搜索包含空格的名称

提问于
浏览
1

是否可以搜索包含空格的名称?

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

谢谢!

4 回答

  • 2

    Places API不正式支持使用多个关键字或名称执行地方搜索请求,因此无法保证返回准确的结果 .

    如果您认为支持多个关键字或名称是有用的功能,请提交'Places API - Feature Request' here .

  • 7

    正如SKAR所说,当你有空格时添加%22 . 您的搜索词,而不是汉堡王,成为“汉堡王” .

    URL,如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]

    不要_2082528_你的%20(空格)除了%22,但 add 它们在你的搜索词之前和之后 .

    干杯

  • 0

    如果名称之间有空格,请使用“” -

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

    有空格时添加 %22 (引号)

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

    谢谢,SKAR

相关问题