scottt40


How do I display the directions in a printable popup window or in a div on the side. Does someone have this code

Thanks




Re: V5 - Developing a Map that has printable directions

Derek Chan


Hi,

Don't know how exactly you want the div, but here's some code to help you out:


Code Snippet

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx v=5"></script>
<script>
var map = null;
var number = 0;
function GetMap()
{
map = new VEMap('myMap');
map.LoadMap();

//map.GetRoute('Microsoft', 'Space Needle', null, null, onGotRoute);
map.GetRoute("Dallas/Fort Worth International Airport, Dallas Texas", "Tulsa International Airport, Tulsa, OK",null,null,onGotRoute);


}
function onGotRoute(route)
{
var routeinfo="Route info:\n\n";
routeinfo+="Total distance: ";
routeinfo+= route.Itinerary.Distance+" ";
routeinfo+= route.Itinerary.DistanceUnit+"\n";

var steps="";
var len = route.Itinerary.Segments.length;
for(var i = 0; i < len ;i++)
{
steps+=route.Itinerary.Segments[i].Instruction+" -- (";
steps+=route.Itinerary.Segments[i].Distance+") ";
steps+=route.Itinerary.DistanceUnit+"\n";
}
routeinfo+="Steps:\n"+steps;
document.getElementById('temp').innerHTML=routeinfo;
}
</script>
</head>
<body onload="GetMap();">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
<div id="temp"></div>
</body>
</html>

Hope that helps,