-1

1,000〜2,000(lat / lon)ポイントで構成されるルートを表示する必要があります。

私はこれをやろうとしましたが、それほど多くのポイントのルートを示すのは良い解決策ではないと思います。それを行うための最良の方法についてアドバイスしてください。

function calcRoute() {    
    var request = {
        origin:new google.maps.LatLng(37, -97),
        waypoints: [
        {
            location:new google.maps.LatLng(39, -97),
            stopover:false
        },{
            location:new google.maps.LatLng(32, -95),
            stopover:false
        }],
        destination:new google.maps.LatLng(37, -97),
        travelMode: google.maps.DirectionsTravelMode.DRIVING
    };    

    directionsService.route(request, function(response, status) {
        if (status == google.maps.DirectionsStatus.OK) {
            directionsDisplay.setDirections(response);
        }
    });
}
4

1 に答える 1

0

結果全体をDirectionsRendererに渡す代わりに、google.maps.DirectionsRouteオブジェクトのoverview_path(簡略化)を使用して、ポリラインをマップに直接追加できます。次に例を示します。

directionsService.route(request,plot);


function plot(result,status){
    if (status == google.maps.DirectionsStatus.OK) {
        for (var n = 0 ;n < result.routes.length ; n++ ){
            addLine(result.routes[n].overview_path);
        }
    }
}

function addLine(path){
    var line = new google.maps.Polyline ({
    path: path,
    map: map
    });
}
于 2013-01-26T09:19:59.227 に答える