Compartilhar via


Virtual Earth - Printing mapping directions to paper

There are several different ways to print the mapping directions to the paper. I have attached a simple sample program that should be able to get started. What this program does is display the directions in a TextArea; using JavaScript create a Post method and have the routing information posted onto another page.

 

<%

@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

html xmlns="https://www.w3.org/1999/xhtml" >

<

head runat="server">

<title>Virtual Earth - Print Mapping directions </title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="text/javascript" src="https://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5"></script>

<script type="text/javascript">

var map = null;

function GetMap()

{

map =

new VEMap('myMap');

map.LoadMap();

map.GetRoute(

'Microsoft','Space Needle',null,null,onGotRoute);

}

function onGotRoute(route)

{

var routeinfo="Route info:\r\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(

"directions").value = routeinfo;

}

</script>

</

head>

<

body onload="GetMap();">

<form id="form1" runat="server">

<div id='myMap' style="position: relative; width: 100%; height: 400px;"></div> <br/>

<div>

<textarea id="directions" name="directions" style="width: 700px; height: 400px" rows="2"

cols="4"></textarea>

</div>

</form>

</

body>

</

html>


For more information you can visit the following websites:

1. https://msdn2.microsoft.com/en-us/library/bb412546.aspx

2. https://blogs.msdn.com/virtualearth/archive/2007/05/01/the-virtual-earth-lab-mix-07.aspx

3. https://msdn.microsoft.com/en-us/library/cc966926.aspx

4. https://msdn.microsoft.com/en-us/library/cc981108.aspx

Comments

  • Anonymous
    August 10, 2007
    There are several different ways to print the mapping directions to the paper. I have attached a simple