SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast Jmz's Avatar
    Join Date
    Jun 2005
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript and Microsoft Virtual Earth

    Hi, I'm making a script for my works website that will use Microsoft Virtual Earth to give users directions. The proble is the Virtual Earth SDK uses javascript and I haven't got a clue.

    Here's my code:
    Code:
    <html>
       <head>
          <title></title>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
          <script src="http://dev.virtualearth.net/mapcontrol/v4/mapcontrol.js"></script>
          <script>
             var map = null;
             
             function GetMap()
             {
                map = new VEMap('myMap');
                map.LoadMap();
             
                map.GetRoute('DH2 1DD',
                         'ne215tl',
                         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;
                alert(routeinfo);
             }
          </script>
       </head>
       <body onload="GetMap();">
          <div id='myMap' style="position:relative; width:400px; height:400px;"></div>
       </body>
    </html>
    Basically what that does is brings up an alert box with the directions and then shows the map with the route marked out. What I need is for the directions to appear on the page with the map. I tried changing the alert(routeinfo) to document.write(routeinfo) and it showed the directions in the browser however the page loads for ages and doesn't display the map.

    What is the best way to do what I want?
    Would it be possible to somehow convert the routeinfo variable to an asp variable (then at least I'll an idea of what I'm doing)?
    Last edited by Jmz; Apr 2, 2007 at 01:42. Reason: added [code] tags

  2. #2
    SitePoint Enthusiast Jmz's Avatar
    Join Date
    Jun 2005
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I managed to get this fixed, if anybody else is having a similar problem PM me and I'll be happy to help


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •