gpt4 book ai didi

javascript - 使用新 API key 的 Google 地方信息库 OVER_QUERY_LIMIT

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:32:59 25 4
gpt4 key购买 nike

我在我的 javascript 应用程序中使用 Places 库。当我使用 service.nearbySearch() 方法查找附近地点时,它工作正常。然后,当我发出 service.getDetails() 请求时,我得到每个请求的 OVER_QUERY_LIMIT 状态。在我的开发者控制台中,我可以跟踪对 Google Maps JavaScript API v3 发出的每个请求,但我没有从 places API 获得任何结果。

部分代码如下:

// How I load the library 
<script src="https://maps.googleapis.com/maps/api/js?libraries=places&key=API_KEY"></script>

// My places request
var places = new google.maps.places.PlacesService(map);
var location = new google.maps.LatLng(lat, lng);
var request = {
location: location,
radius: radius,
types: [type]
};

places.nearbySearch(request, function(results, status, pagination) {

if (status === google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {

// Get the details for each place
var detailsRequest = { placeId: results[i].id }

places.getDetails(detailsRequest, function(place, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
console.log('PLACE', place)
} else {
console.log('STATUS', status)
}
})
};
}

有什么想法吗?

最佳答案

答案是我请求 .getDetails() 方法的速度太快了。 Docs .

我正在遍历几十个位置,请求太多也太快了。很多时候,在 OVER_QUERY_LIMIT 错误之前,我只会得到 60 多个结果中的前 10 或 12 个。

我将对 .getDetails() 的调用移到了标记的点击事件中。这样一次只发送一个请求。

关于javascript - 使用新 API key 的 Google 地方信息库 OVER_QUERY_LIMIT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29232465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com