我想使用谷歌距离矩阵计算100 x 100 = 10000之间的距离。并且我始终使用标准使用方式启用结算,但继续提供错误 OVER_QUERY_LIMIT
我总是检查限制:
1)2500 /天,但我启用结算
2)每秒100个元素,我在客户端插入5秒的间隔
3)每个查询100个元素我总是有25个目的元素和1个原点
我正在使用jquery
进行javascriptvar origin_vertices = [{ lat: 44.1101790, lng: 12.4232134} ......,{ lat: 45.9859019, lng: 112.6167280}]; // 100 elements
var number_of_split = 4;
var service = new google.maps.DistanceMatrixService();
var my_origin = JSON.parse(JSON.stringify(origin_vertices));
var origin_dict = [];
for (var i =0; i < my_origin.length; ++i){
var my_dest = JSON.parse(JSON.stringify(origin_vertices));
var temp_origin = [];
temp_origin[0] = my_origin[i];
for (var j = 0; j < number_of_split; ++j){
var split_array = my_dest.splice(0, 25);
origin_dict.push({origin: temp_origin, destination: split_array})
}
}
// after this operations i have a vector of 400 elements, with 1 origin and 25 destination
var dim_new_array = origin_dict.length;
var i = 0;
var interval = setInterval(function() {
orig = origin_dict[i].origin;
dest = origin_dict[i].destination;
callservice(orig, dest);
i++;
if(dim_new_array <= i){
clearInterval(interval);
}
}, 3000);
function callservice(orig, dest){
// serve solo per chiamae la API
service.getDistanceMatrix({
origins: orig,
destinations: dest,
travelMode: google.maps.TravelMode.DRIVING,//DRIVING, BICYCLING, WALKING, TRANSIT
unitSystem: google.maps.UnitSystem.METRIC,//IMPERIAL
avoidHighways: false,
avoidTolls: false
}, Callback);// service
}
我只使用距离服务。
答案 0 :(得分:0)
正如您已经提到的,您启用了结算功能;我建议采取两个步骤,确保您已正确配置所有内容。