0

在 Google Map V3 中需要帮助我想在路线中显示多个点。目前我已经提到了起点和终点,但是如何显示我在航点(arrWaypoints)数组中的所有点?下面是我的代码。

var origin = arrWaypoints[0];
var destination = arrWaypoints[1];
this.directions.route({
                    origin: origin,
                    destination: destination,
                    travelMode: google.maps.DirectionsTravelMode.DRIVING,
                    unitSystem: google.maps.DirectionsUnitSystem.METRIC
                }, function(result, status) {
  ........

谢谢,沙拉特

4

1 回答 1

0

在您的示例中,没有要显示的航点。如果您要包含其他航点,则请求将如下所示:

var origin = arrWaypoints[0];
var destination = arrWaypoints[arrWaypoints.length-1];
// Origin and destination don't need to be in the arrWaypoints anymore as they're listed separately in the request.
arrWaypoints.splice(arrWaypoints.length-1, 1);
arrWaypoints.splice(0, 1);
this.directions.route({
                origin: origin,
                destination: destination,
                waypoints: arrWaypoints,
                travelMode: google.maps.DirectionsTravelMode.DRIVING,
                unitSystem: google.maps.DirectionsUnitSystem.METRIC
            }, function(result, status) {
  ........
于 2013-04-26T13:23:05.690 回答