title: Bing Maps Context Menu
body: <p>I just got interested in working with the Bing Maps so i thought it would be excelent so look at one of their examples. So i grabbed the full source code from Microsoft's sample but it isn't working. Is the code wrong or am i doing something wrong?
  Heres the link to the website: <a href="http://msdn.microsoft.com/en-us/library/aa907681.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa907681.aspx</a></p>
  
  <p>And here is my code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Driving Directions in Bing Maps&lt;/title&gt;
  &lt;style type="text/css" media="screen"&gt;
  ul, li {margin:0;padding:0;}
  
  ul.pmenu
  {
      position:absolute;
      margin: 0;
      padding: 1px;
      list-style: none;
      width: 150px; /* Width of Menu Items */
      border: 1px solid #ccc;
      background:white;
      display:none;
      z-index:10;
  }
  
  ul.pmenu li { position: relative; }
  
  /* Styles for Menu Items */
  ul.pmenu li a
  {
      display: block;
      text-decoration: none;
      color: black;
      padding: 2px 5px 2px 20px;
  }
  
  ul.pmenu li a:hover
  {
      background:#335EA8;
      color:white;
  }
  &lt;/style&gt;
  
  &lt;script src="http://dev.virtualearth.net/mapcontrol/v4/mapcontrol.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  var map = null;
  var popuplat;
  var popuplon;
  var startpt = null;
  var endpt = null;
  
  function OnPageLoad()
  {
  map = new VEMap('myMap');
  map.LoadMap(new VELatLong(-33.7939, 151.1093), 10, 'r', false);
  map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
  map.AttachEvent("oncontextmenu", ShowPopupMenu);
  
  }
  
  function ShowPopupMenu(e)
  {
  popuplat = e.view.LatLong.Latitude;
  popuplon = e.view.LatLong.Longitude;
  var latlong = map.LatLongToPixel(new VELatLong(popuplat,popuplon));
  
  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 RemovePopupMenu()
  {
  var menu = document.getElementById('popupmenu').style.display='none';
  }
  
  function SetStart()
  {
  try {
  map.DeletePushpin('start');
  } catch(err) {}
  
  startpt = new VELatLong(popuplat, popuplon);
  var pin = new VEPushpin('start', startpt, null, 'Start Here', 'Starting point');
  map.AddPushpin(pin);
  
   RemovePopupMenu();
  }
  
  function SetEnd()
  {
  try {
  map.DeletePushpin('end');
  } catch(err) {
  
  endpt = new VELatLong(popuplat, popuplon);
  var pin = new VEPushpin('end', endpt, null, 'pin', 'end');
  map.AddPushpin(pin);
  
   RemovePopupMenu();
  }
  
  function GetDirections()
  {
  map.GetRoute(startpt, endpt, VEDistanceUnit.Kilometers, VERouteType.Quickest, OnGotRoute);
  
  RemovePopupMenu();
  }
  
  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 &lt; 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);
  }
  
   &lt;/script&gt;
   &lt;/head&gt;
  &lt;body onload="OnPageLoad();"&gt;
  &lt;div id="myMap" style="position:relative;width:600px;height:400px;"&gt;&lt;/div&gt;
  &lt;div id="menu"&gt;
  &lt;ul id="popupmenu" class="pmenu"&gt;
  &lt;li&gt;&lt;a href="#" onclick='SetStart()'&gt;Set Start&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="#" onclick='SetEnd()'&gt;Set End&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="#" onclick='GetDirections()'&gt;Get Directions&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;/div&gt;
  &lt;/body&gt;
       &lt;/html&gt;
  </code></pre>