1

これが正しいグループかどうかはわかりません。そうでない場合は、お知らせください。

私のジレンマ:

PolylinesGoogle Maps v3 から返された結果を Google Earthに追加する必要がありDirectionsServiceます。その程度のウェブ上には何もないようです。ローマンは彼の運転シミュレーターでこれを行うので、それは可能でなければなりません: http://earth-api-samples.googlecode.com/svn/trunk/demos/drive-simulator/index.html

残念ながら、彼はそこで Google マップ v2 を使用しており、このコードを Google マップ v3 に転送する方法がわかりません。

4

1 に答える 1

1

誰かが興味を持っているなら、これが私がそれを解決する方法です:

function DrawLinesOnEarth() {
    var sLat;
    var sLon;
    //var start = document.getElementById("start").value;
    //var end = document.getElementById("end").value;
    var request = {
        origin: '40.306134,-74.05018',
        destination: '40.313223,-74.043496',
        travelMode: google.maps.TravelMode.WALKING
    };
    directionsService.route(request, function (result, status) {
        if (status == google.maps.DirectionsStatus.OK) {
            directionsDisplay.setDirections(result);
            var steps = result.routes[0].legs[0].steps;

            //Step through array of step legs and create polylines one by one
            var lineStringPlacemark = IMC_ge.createPlacemark('');
            var lineString = IMC_ge.createLineString('');
            lineStringPlacemark.setGeometry(lineString);
            // Add LineString points
            for (var x in steps) {
                for (var y in steps[x].path) {
                    sLat = steps[x].path[y].Na;
                    sLon = steps[x].path[y].Oa;
                    lineString.getCoordinates().pushLatLngAlt(sLat, sLon, 0);
                }
            }
            // Add the feature to Earth
            IMC_ge.getFeatures().appendChild(lineStringPlacemark);

        }
    });
}
于 2012-05-08T11:43:47.423 に答える