我想使用谷歌距離矩陣來計算100 x 100 = 10000之間的距離。我總是能夠與標準使用計費,但繼續得到錯誤OVER_QUERY_LIMIT
我總是檢查的限制:
1)2500 /天,但我使計費每秒
2)100層的元件,我插入的間隔對客戶端5秒
3)每查詢100個元件我總是有目的地爲原籍
Google距離矩陣如何升級配額請求
我的工作的JavaScript與jquery 25組的元素和1
var 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
}
我只使用遠程服務。
找到請提供[mcve]來演示您的問題。 – geocodezip
我把我的代碼@geocodezip – ssgakhal