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
- <html>
- <head>
- <title>Driving Directions in Virtual Earth</title>
- <style type="text/css" media="screen"> ul, li {margin:0;padding:0;}
- 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; }
- ul.popMenu li { position: relative; }
- /* Styles for Menu Items */ ul.popMenu li a { display: block; text-decoration: none; color: black; padding: 1px 1px 0px 1px; }
- ul.popMenu li a:hover { background:#335EA8; color:white; }
- .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;}
- .cont { z-index: 3;width: 15em; height: 5em;border: solid 1px black; background: white; position: absolute;}
- </style>
- <script src="http://dev.virtualearth.net/mapcontrol/v4/mapcontrol.js"></script>
- <script>
- var map = null;
- var pLat;
- var pLon;
- var stPoint = null;
- var ePoint = null;
- //function OnPageLoad()
- //{
- // map = new VEMap('myMap');
- // map.LoadMap(new VELatLong( 19.06,81.65), 4, 'r', false);
- // map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
- // map.AttachEvent("oncontextmenu", SPopupMenu);
- //}
- //1.3.1115150037.31";
- //var map = null;
- var le = 0;
- function OnPageLoad()
- {
- var head = document.getElementsByTagName("head")[0];
- var s = document.createElement('script');
- s.id = 'VEScript';
- s.type = 'text/javascript';
- s.src = "http://maps.live.com/veapi.ashx?v=1.3.1204222815.33";
- head.appendChild(s);
- DelayGetMap();
- }
- function DelayGetMap()
- {
- try {
- map = new VEMap('myMap');
- //document.getElementById("myLoading").style.display = "none";
- document.getElementById("myMap").style.display = "block";
- //map.LoadMap(new VELatLong(21.6, 85.33), 10 ,'h' ,false);
- map.LoadMap(new VELatLong( 19.06,81.65), 4, 'r', false);
- map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
- map.AttachEvent("oncontextmenu", SPopupMenu);
- }catch(err)
- {
- if (le < 30)
- {
- le++;
- setTimeout("DelayGetMap()",51);
- alert("Site is busy.");
- GetMap();
- }
- }
- }
- function SPopupMenu(e)
- {
- pLat = e.view.LatLong.Latitude;
- pLon = e.view.LatLong.Longitude;
- var latlong = map.LatLongToPixel(new VELatLong(pLat,pLon));
- var x = map.GetLeft();
- var y = map.GetTop();
- var menu = document.getElementById('popupmenu');
- menu.style.display='block'; //Showing the menu
- menu.style.left = latlong.x + x; //Positioning the menu
- menu.style.top = latlong.y + y;
- }
- function rmPopupMenu()
- {
- var menu = document.getElementById('popupmenu').style.display='none';
- }
- function SetStart()
- {
- try
- {
- map.DeletePushpin('start');
- } catch(err) {}
- stPoint = new VELatLong(pLat, pLon);
- var pin = new VEPushpin('start', stPoint, null, 'Start Here', 'Starting point');
- map.AddPushpin(pin);
- rmPopupMenu();
- }
- function SetEnd()
- {
- try
- {
- map.DeletePushpin('end');
- } catch(err){}
- ePoint = new VELatLong(pLat, pLon);
- var pin = new VEPushpin('end', ePoint, null, 'pin', 'end');
- map.AddPushpin(pin);
- rmPopupMenu();
- }
- function gDir()
- {
- map.GetRoute(stPoint, ePoint, VEDistanceUnit.Kilometers, null, GRoute);
- rmPopupMenu();
- }
- function GRoute(route)
- {
- var rtInfo ="Total distance:"+route.Itinerary.Distance+route.Itinerary.DistanceUnit;
- document.getElementById("info").innerHTML = rtInfo;
- }
- </script>
- </head>
- <body onload="OnPageLoad();" style="OVERFLOW:hidden">
- <div id="info" style="Width:100px;Height:15px;Font-family:Arial;Font-size:12px;display:block;"></div>
- <div id="myMap" style="WIDTH:800px;POSITION:relative;HEIGHT:650px">
- </div>
- <DIV>
- <ul id="popupmenu" class="popMenu">
- <li>
- <a href="#" onclick='SetStart()'>Start</a>
- <a href="#" onclick='SetEnd()'>End</a>
- <a href="#" onclick='gDir()'>ShowRoute</a></li>
- </ul>
- </DIV>
- <!-- <DIV id="Dt" style="WIDTH: 100px; HEIGHT: 10px"></DIV> -->
- </body>
- </html>