简体   繁体   English

使用Google Maps API nearBysearch有多种类型

[英]Using Google maps API nearBysearch with multiple types

So I am working with google maps API in Javascript and my code for searching looks like this: 所以我在Javascript中使用谷歌地图API,我的搜索代码如下所示:

therequest = {
bounds: map.getBounds(),
type: 'Cafe',
};

service.nearbySearch(therequest, callback);

I want to search for multiple types in one search and I know you can use: 我想在一次搜索中搜索多种类型,我知道你可以使用:

types: ['Cafe','bar']

But according to google documentation this method will stop being supported at the start of next year. 但根据谷歌文档,这种方法将在明年初停止支持。 Is there a replacement method for achieving a similar search or would you just have to loop over the searches with different requests? 是否有替换方法来实现类似的搜索,或者您是否只需要使用不同的请求循环搜索?

Any help would be appreciated! 任何帮助,将不胜感激!

Thanks, 谢谢,

Mark 标记

As of now, I think Google not yet released the alternative way/replacement for that parameter. 截至目前,我认为谷歌尚未发布该参数的替代方式/替代品。 It only says in this documentation that, 它只在本文档中说,

The implementation for types in text search requests is changing. 文本搜索请求中类型的实现正在发生变化。 The types parameter is deprecated as of February 16, 2016, replaced by a new type parameter which only supports one type per search request. types参数自2016年2月16日起不再使用,替换为每个搜索请求仅支持一种类型的新类型参数。 Requests using the deprecated features will be supported until February 16, 2017, after which all text searches must use the new implementation. 使用已弃用功能的请求将在2017年2月16日之前得到支持,之后所有文本搜索都必须使用新实现。

So we still have one year to use it, Also maybe Google might extend that period like they do on the id and reference field that supposedly deprecated on June 24, 2014. They extend it one more year because they are looking into ways of ensuring this change will not break the existing code. 所以我们还有一年的时间可以使用它,也许谷歌可能延续那段时间,就像他们在2014年6月24日推荐的ID和参考字段一样。他们再延长一年,因为他们正在研究如何确保这一点更改不会破坏现有代码。 Just an opinion. 只是一个意见。

You can do a request with ajax for example to (specifying the output and the parameters) : 您可以使用ajax执行请求(例如,指定输出和参数):

https://maps.googleapis.com/maps/api/place/nearbysearch/output?parameters https://maps.googleapis.com/maps/api/place/nearbysearch/output?parameters

See the docs : 查看文档:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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