2016-12-16 79 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

我们将不得不另谋出路...如果我觉得我会让你知道,如果你先找到它,如果你告诉我,我会感激。