1

我正在构建几条折线捕捉到道路。下面是其中 2 个的代码。超过 15 条折线捕捉到道路,我有以下错误:“路线请求失败:OVER_QUERY_LIMIT”。

因此,我想找到一个解决方案。其中之一是将所有这些信息缓存在我的计算机中,所以我从谷歌地图得到的唯一东西就是地图。那可能吗 ?

你知道其他一些解决方案吗?

//Circuit CHL1C1

CHL1C1 = [
    new google.maps.LatLng(-22.91401,-68.192237),
    new google.maps.LatLng(-23.226361,-67.064938)
    ];

var traceCHL1C1 = new google.maps.Polyline({
    path: CHL1C1,
    strokeColor: "red",
    strokeOpacity: 1.0,
    strokeWeight: 4
});

var serviceCHL1C1 = new google.maps.DirectionsService(),traceCHL1C1,snap_pathCHL1C1=[];
traceCHL1C1.setMap(map);
for(j=0;j<CHL1C1.length-1;j++){
    serviceCHL1C1.route({origin: CHL1C1[j],destination: CHL1C1[j+1],travelMode: google.maps.DirectionsTravelMode.DRIVING},function(result, status) {
        if(status == google.maps.DirectionsStatus.OK) {
            snap_pathCHL1C1 = snap_pathCHL1C1.concat(result.routes[0].overview_path);
            traceCHL1C1.setPath(snap_pathCHL1C1);
        } else alert("Directions request failed: "+status);        
    });
}




//Circuit CHL1C2

CHL1C2 = [
    new google.maps.LatLng(-22.898988,-68.198154),
    new google.maps.LatLng(-22.337195,-68.016747),
    new google.maps.LatLng(-22.443062,-68.899408)
];

var traceCHL1C2 = new google.maps.Polyline({
    path: CHL1C2,
    strokeColor: "green",
    strokeOpacity: 1.0,
    strokeWeight: 4
});

var serviceCHL1C2 = new google.maps.DirectionsService(),traceCHL1C2,snap_pathCHL1C2=[];
traceCHL1C2.setMap(map);
for(j=0;j<CHL1C2.length-1;j++){
    serviceCHL1C2.route({origin: CHL1C2[j],destination: CHL1C2[j+1],travelMode: google.maps.DirectionsTravelMode.DRIVING},function(result, status) {
        if(status == google.maps.DirectionsStatus.OK) {
            snap_pathCHL1C2 = snap_pathCHL1C2.concat(result.routes[0].overview_path);
            traceCHL1C2.setPath(snap_pathCHL1C2);
        } else alert("Directions request failed: "+status);        
    });
}
4

2 回答 2

0

免费 API 最多有 8 个航点。但是,根据您要执行的操作,您可以通过创建折线数组并为数组中的每个元素只调用一次方向服务来绕过此限制。

于 2014-04-09T02:28:57.050 回答
0

如果我错了,请纠正我,但免费 API 最多有 8 个航点。

于 2013-11-28T18:31:14.840 回答