我正在使用 Google API 方向服务,我想禁用地图中的两个标记之一。当我使用渲染选项并将可拖动设置为 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();
}
}
});
});