2016-12-16 37 views
-1

我必須設置爲開車前的出行方式,它有阻力能夠標記在其中,我可以改變方向或選擇替代路線,當我沒有改變過境,不能這樣做。是否有任何限制或任何其他方式提前實現這一目標(travelMode: google.maps.TravelMode.TRANSIT谷歌地圖旅行中轉模式也不能拖動

function displayRoute(origin, destination, service, display) { 
      debugger; 
      service.route({ 
       origin: { 'placeId': origin_place_id }, 
       destination: { 'placeId': destination_place_id }, 
       travelMode: google.maps.TravelMode.TRANSIT, 
       unitSystem: google.maps.UnitSystem.IMPERIAL 
       //travelMode: TravelMode, 
       //transitOptions: TransitOptions, 
       //drivingOptions: DrivingOptions 
       ///avoidTolls: true 
      }, function (response, status) { 
       if (status === google.maps.DirectionsStatus.OK) { 
        display.setDirections(response); 
       } else { 
        alert('Could not display directions due to: ' + status); 
       } 
      }); 
     } 

謝謝!

回答

0

不幸的是,「拖動」模式中不能包含公交出行方式。剛纔我試圖找到一種方式,順便找到了你的問題。

作爲谷歌文檔說:

用戶可以修改騎車,步行或行車路線使用的DirectionsRenderer動態如果它們是可拖動顯示 ,允許 用戶選擇,並通過點擊和拖動改變路由 在地圖上產生的路徑。要表示渲染器的顯示 是否允許拖動路線,它的可拖動屬性設置爲true。 公交路線無法進行拖動

檢查在這裏:https://developers.google.com/maps/documentation/javascript/directions#TransitOptions

我們將不得不另謀出路...如果我覺得我會讓你知道,如果你先找到它,如果你告訴我,我會感激。