Google Places的批量请求(Javascript v3) [英] Batch requests for Google Places (Javascript v3)

查看:84
本文介绍了Google Places的批量请求(Javascript v3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在JavaScript中为 Places Library 批量请求?我已经看过这一页,所以我已经收集了它,至少我可以我不知道它如何与Places API协同工作。



我需要为在Google地图上找到的每个地方运行一次请求(这会导致很多OVER_QUERY_LIMIT例外)。我已经考虑过排队请求并分开运行它们,但是如果用户有数百个排队的地方,如果用户先发制人地关闭了页面,结果将会丢失。



在这种情况下,如果可能的话,我宁可不推迟处理到服务器。 解决方案

$ b try {
service.getDetails(place,getMorePlaceDetails);
clearInterval(intId);
} catch(e){
console.info(无法获得详细信息关于+ place.name +;重试在3 ...);
}
},3000);

每次尝试获取更多细节时引发异常的地方都会在3秒内重试。

Is there a way to batch requests for the Places Library in JavaScript? I've seen this page, so I've gathered it's possible, at least, I'm just not sure how it'd work with Places API.

I need to run a request for every place I find on google maps (this leads to a lot of OVER_QUERY_LIMIT exceptions). I've given thought to queuing the requests and running them a second apart, but if a user gets several hundred places queued up, a fair amount of results are going to go missing if the user closes the page preemptively.

I'd rather not defer processing to the server in this case if possible.

解决方案

Well, here was my solution in Javascript:

var intId = setInterval(function() {
    try {
        service.getDetails(place, getMorePlaceDetails);
        clearInterval(intId);
    } catch(e) {
        console.info("Could not get detailed information about "+place.name+"; retrying in 3...");
    }
}, 3000);

Every place that threw an exception when it tried to get more details was retried in 3 seconds.

这篇关于Google Places的批量请求(Javascript v3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆