R
rlawrimore
Guest
Can someone help me with this code from my aspx page. I want to get the value of "distance" to the C# code page behind and cannot seem to get it to work.
function directionsUpdated(e) {
//Get the current route index.
var routeIdx = directionsManager.getRequestOptions().routeIndex;
//Get the distance units used to calculate the route.
//var routeOptx = directionsManager.getRequestOptions().routeOptimization;
directionsManager.setRequestOptions({
routeMode: Microsoft.Maps.Directions.RouteMode.driving,
routeOptimization: Microsoft.Maps.Directions.RouteOptimization.shortestDistance
});
//Get the distance of the route, rounded to 2 decimal places.
var distance = Math.round(e.routeSummary[routeIdx].distance * 100) / 100;
//Get the distance units used to calculate the route.
var units = directionsManager.getRequestOptions().distanceUnit;
var distanceUnits = '';
if (units == Microsoft.Maps.Directions.DistanceUnit.km) {
distanceUnits = 'km'
} else {
//Must be in miles
distanceUnits = 'miles'
}
//Time is in seconds, convert to minutes and round off.
var time = Math.round(e.routeSummary[routeIdx].timeWithTraffic / 60);
document.getElementById('routeInfoPanel').innerHTML = 'Distance: ' + distance + ' ' + distanceUnits + '<br/>Time with Traffic: ' + time + ' minutes';
}
Continue reading...
function directionsUpdated(e) {
//Get the current route index.
var routeIdx = directionsManager.getRequestOptions().routeIndex;
//Get the distance units used to calculate the route.
//var routeOptx = directionsManager.getRequestOptions().routeOptimization;
directionsManager.setRequestOptions({
routeMode: Microsoft.Maps.Directions.RouteMode.driving,
routeOptimization: Microsoft.Maps.Directions.RouteOptimization.shortestDistance
});
//Get the distance of the route, rounded to 2 decimal places.
var distance = Math.round(e.routeSummary[routeIdx].distance * 100) / 100;
//Get the distance units used to calculate the route.
var units = directionsManager.getRequestOptions().distanceUnit;
var distanceUnits = '';
if (units == Microsoft.Maps.Directions.DistanceUnit.km) {
distanceUnits = 'km'
} else {
//Must be in miles
distanceUnits = 'miles'
}
//Time is in seconds, convert to minutes and round off.
var time = Math.round(e.routeSummary[routeIdx].timeWithTraffic / 60);
document.getElementById('routeInfoPanel').innerHTML = 'Distance: ' + distance + ' ' + distanceUnits + '<br/>Time with Traffic: ' + time + ' minutes';
}
Continue reading...