2013-04-26 53 views
0

在Google地圖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) { 
    ........ 

感謝, 沙拉斯

回答

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) { 
    ........ 
+0

感謝Eric,您的意見幫助我解決了問題... – Sharath 2013-04-30 04:31:54