Another interesting thing in Microsoft Virtual Earth is calculate the route between two points.
The method for do this is GetDirections.
This method has two parameters.
The first is an array with the list of the points.
The second is a VERouteOptions object that specified some options.
The options is:
DistanceUnit: enum (Kilometer, Miles)
DrawRoute: if true, the function draws the road on the map
RouteColor: the color of the route
RouteMode: enum VERouteMode (Walking, Driving)
RouteOptimize: enum (MinimizeTime, MinimizeDistance)
SetBestMapView: if true, the map moves on your route
RouteCallback: the function invoked when the search is finished
Add this html code under the map (see the first or second article)
<input id="txtStart" type="text" name="txtStart" value="Piana del Sole, Roma, Lazio, Italy"/>
<input id="txtEnd" type="text" name="txtEnd" value="Piazza del Popolo (historical site), Rome, Lazio, Italy"/>
<input id="find" type="button" value="Find" name="GetRoute"
onclick="GetRoute();"/>
Add this javascript function:
function GetRoute(){
try{
var options = new VERouteOptions();
options.DrawRoute = true;
options.SetBestMapView = true;
options.DistanceUnit = VERouteDistanceUnit.Kilometer;
map.GetDirections([document.getElementById('txtStart').value,
document.getElementById('txtEnd').value], options);
}
catch(e)
{
alert(e.message);
}
}
In the attachment you find the example page that I created.
VirtualEarth3.zip (1.13 kb)
Enjoy!