在 Google API DirectionsService 中禁用两个可拖动标记之一

Disable one of two draggable Markers in Google API DirectionsService

我正在使用 Google API 路线服务,我想禁用地图中的两个标记之一。当我使用 render Options 并将 draggable 设置为 false 时,两个标记都设置为 false,但我想将其中一个标记禁用为 false,而不是将它们都设置为 false。

function initialize() {
        var mapOptions = {
            zoom: 15,
            center: orgn
        };
        map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
        directionsDisplay.setMap(map);
        google.maps.event.addListener(directionsDisplay, 'directions_changed', function () {
            computeTotalDistance(directionsDisplay.getDirections());
        });
        calcRoute();
        map.setZoom(15);
        map.setCenter(orgn);
    }

    function calcRoute() {
        var request = {
            origin: orgn,
            destination: 'دبیرستان شهدا، Ahvaz, Khuzestan, Iran',
            travelMode: google.maps.TravelMode.DRIVING
        };
        directionsService.route(request, function (response, status) {
            if (status == google.maps.DirectionsStatus.OK) {
                directionsDisplay.setDirections(response);
            }
        });
    }

    function computeTotalDistance(result) {
        var total = 0;
        var myroute = result.routes[0];
        for (var i = 0; i < myroute.legs.length; i++) {
            total += myroute.legs[i].distance.value;
        }
        total = total / 1000.0;
        document.getElementById('total').innerHTML = total + ' Km';
        $('#<%= tt.ClientID %>').val(total);
    }
    var orgn = new google.maps.LatLng(31.321173, 48.672320);
    var mapOptions = {
        zoom: 13,
        center: orgn
    };

    var rendererOptions = {
        draggable: true
    };
    var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);
    var directionsService = new google.maps.DirectionsService();
    google.maps.event.addDomListener(window, 'load', initialize);

    $(document).ready(function () {
        $('#<%= SchoolDD.ClientID %>').bind('change', function () {
            $.ajax({
                url: "ajax.ashx?m=" + $(this).val(),
                success: function (result) {
                    if (result == '(0)') {
                        $('#std').hide();
                        $('#schoolpoint').fadeIn();
                    }
                    else {
                        orgn = result;
                        calcRoute();
                    }
                }
            });
        });

查找可拖动参数。用于此的参数。

var marker = new google.maps.Marker({
    position: latlng,
    draggable:<this>, 
    map: map,
    shadow: iconShadow,
    icon: getMarkerImage(color),
    shape: iconShape,
    title: label,
    zIndex: Math.round(latlng.lat()*-100000)<<5
});

工作:http://www.geocodezip.com/v3_directions_custom_icons_draggableStart.html