By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,759 Members | 1,778 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,759 IT Pros & Developers. It's quick & easy.

When I Select Source & Destination Dynamically Path Getting Scatter Across The Map

windows_mss
P: 13
When I Select Source & Destination Dynamically,
Path Getting Scatter Across The Map...


hi,

i can able to get the Correct Route and Path for the corresponding Source

and destination, like this,

map.GetRoute('Redmond, Washington, United States','seattle, Washington, United States',VEDistanceUnit.KiloMeter,VERouteType.Short est);

when i try to do the same dynamically, i fails here, i attached the code please

tell where i gone wrong


Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  <head>
  3.   <title>Driving Directions in Virtual Earth</title>
  4.   <style type="text/css" media="screen"> ul, li {margin:0;padding:0;}
  5.  ul.popMenu { position:absolute; margin: 0; padding: 0px; list-style: none; font-family: arial; font-size:10px; text-align: center; width: 100px; /* Width of Menu Items */ border: 1px solid #ccc; background:white; display:none; }
  6.  ul.popMenu li { position: relative; }
  7.  /* Styles for Menu Items */ ul.popMenu li a { display: block; text-decoration: none; color: black; padding: 1px 1px 0px 1px; }
  8.  ul.popMenu li a:hover { background:#335EA8; color:white; }
  9.  .msg {filter: alpha(opacity=80);opacity: .8;z-index: 3;width: 15em;height: 15em;border: solid 1px black;background: white; visibility: hidden;overflow: auto;font-family: Verdana;font-size: 75%;position: absolute;}
  10.  .cont { z-index: 3;width: 15em; height: 5em;border: solid 1px black; background: white; position: absolute;}
  11.  </style>
  12.  <script src="http://dev.virtualearth.net/mapcontrol/v4/mapcontrol.js"></script>
  13.   <script>
  14.     var map = null;
  15.     var pLat;
  16.   var pLon;
  17.   var stPoint = null;
  18.   var ePoint = null;
  19.  
  20.   //function OnPageLoad()
  21.   //{
  22.   //  map = new VEMap('myMap');
  23.   //  map.LoadMap(new VELatLong( 19.06,81.65), 4, 'r', false);
  24.   //  map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
  25.   //  map.AttachEvent("oncontextmenu", SPopupMenu);
  26.   //}
  27.  
  28. //1.3.1115150037.31";
  29. //var map = null;
  30.          var le = 0;
  31.          function OnPageLoad()
  32.          {
  33.      var head = document.getElementsByTagName("head")[0];
  34.      var s = document.createElement('script');
  35.      s.id = 'VEScript';
  36.      s.type = 'text/javascript';
  37.      s.src = "http://maps.live.com/veapi.ashx?v=1.3.1204222815.33";
  38.      head.appendChild(s);
  39.      DelayGetMap();
  40.          }
  41.          function DelayGetMap()
  42.          {
  43.                 try {
  44.                         map = new VEMap('myMap');
  45.                         //document.getElementById("myLoading").style.display = "none";
  46.                         document.getElementById("myMap").style.display = "block";
  47.                         //map.LoadMap(new VELatLong(21.6, 85.33), 10 ,'h' ,false);
  48.                         map.LoadMap(new VELatLong( 19.06,81.65), 4, 'r', false);
  49.       map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
  50.       map.AttachEvent("oncontextmenu", SPopupMenu);
  51.                 }catch(err)
  52.                 {
  53.                         if (le < 30)
  54.                         {
  55.                                 le++;
  56.                                 setTimeout("DelayGetMap()",51);
  57.                                 alert("Site is busy.");
  58.                                 GetMap();
  59.                         }
  60.                 }
  61.          }
  62.  
  63.   function SPopupMenu(e)
  64.   {
  65.     pLat = e.view.LatLong.Latitude;
  66.     pLon = e.view.LatLong.Longitude;
  67.     var latlong = map.LatLongToPixel(new VELatLong(pLat,pLon));
  68.  
  69.     var x = map.GetLeft();
  70.     var y = map.GetTop();
  71.  
  72.     var menu = document.getElementById('popupmenu');
  73.     menu.style.display='block'; //Showing the menu
  74.     menu.style.left = latlong.x + x; //Positioning the menu
  75.     menu.style.top = latlong.y + y;
  76.   }
  77.  
  78.   function rmPopupMenu()
  79.   {
  80.     var menu = document.getElementById('popupmenu').style.display='none';
  81.   }
  82.  
  83.   function SetStart()
  84.   {
  85.     try
  86.     {
  87.     map.DeletePushpin('start');
  88.     } catch(err) {}
  89.  
  90.     stPoint = new VELatLong(pLat, pLon);
  91.     var pin = new VEPushpin('start', stPoint, null, 'Start Here', 'Starting point');
  92.     map.AddPushpin(pin);
  93.  
  94.     rmPopupMenu();
  95.   }
  96.  
  97.   function SetEnd()
  98.   {
  99.     try
  100.     {
  101.     map.DeletePushpin('end');
  102.     } catch(err){}
  103.  
  104.     ePoint = new VELatLong(pLat, pLon);
  105.     var pin = new VEPushpin('end', ePoint, null, 'pin', 'end');
  106.     map.AddPushpin(pin);
  107.  
  108.     rmPopupMenu();
  109.   }
  110.  
  111.   function gDir()
  112.   {
  113.     map.GetRoute(stPoint, ePoint, VEDistanceUnit.Kilometers, null, GRoute);
  114.     rmPopupMenu();
  115.   }
  116.  
  117.  function GRoute(route)
  118.          {
  119.           var rtInfo ="Total distance:"+route.Itinerary.Distance+route.Itinerary.DistanceUnit;
  120.      document.getElementById("info").innerHTML = rtInfo;
  121.  
  122.          }
  123.   </script>
  124.  </head>
  125.  <body onload="OnPageLoad();" style="OVERFLOW:hidden">
  126.   <div id="info" style="Width:100px;Height:15px;Font-family:Arial;Font-size:12px;display:block;"></div>
  127.   <div id="myMap" style="WIDTH:800px;POSITION:relative;HEIGHT:650px">
  128.   </div>
  129.   <DIV>
  130.    <ul id="popupmenu" class="popMenu">
  131.     <li>
  132.      <a href="#" onclick='SetStart()'>Start</a>
  133.      <a href="#" onclick='SetEnd()'>End</a>
  134.      <a href="#" onclick='gDir()'>ShowRoute</a></li>
  135.    </ul>
  136.   </DIV>
  137.    <!-- <DIV id="Dt" style="WIDTH: 100px; HEIGHT: 10px"></DIV> -->
  138.  </body>
  139. </html>
  140.  
  141.  
Feb 8 '07 #1
Share this Question
Share on Google+
4 Replies


kenobewan
Expert 2.5K+
P: 4,871
What error do you get? Try writing the values of stPoint & ePoint to check that they are valid...
Feb 9 '07 #2

windows_mss
P: 13
my problem solved
Feb 27 '07 #3

kenobewan
Expert 2.5K+
P: 4,871
How did you fix the problem?
Feb 27 '07 #4

windows_mss
P: 13
I Missed This line in <head>

Expand|Select|Wrap|Line Numbers
  1. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Feb 28 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.