1

感谢您的任何帮助,您可以提供!我是谷歌地图的新手,我正在使用 API V3 中的 RouteOptimize 代码。我正在尝试使生成的路线“可拖动”。下面是我的代码的一部分,但我知道我在方向显示中遗漏了一些简单的东西。

var rendererOptions = {
draggable: true
};
var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);;
        var directionsService = new google.maps.DirectionsService();
        var map;

        function initialize() {
          directionsDisplay = new google.maps.DirectionsRenderer({panel:document.getElementById('directions_panel')});
          var chicago = new google.maps.LatLng(41.850033, -87.6500523);
          var mapOptions = {
            zoom: 6,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            center: chicago
          }
          map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
          directionsDisplay.setMap(map);
        }
4

1 回答 1

4

您缺少DirectionsRenderer 的可拖动选项

    var directionsService = new google.maps.DirectionsService();
    var map;
    var directionsDisplay;

    function initialize() {
      var rendererOptions = {
        draggable: true,
        panel:document.getElementById('directions_panel')
      };

      directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);
      var chicago = new google.maps.LatLng(41.850033, -87.6500523);
      var mapOptions = {
        zoom: 6,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        center: chicago
      }
      map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
      directionsDisplay.setMap(map);
    }
于 2013-01-09T01:09:08.263 回答