Handling Virtual Earth 6.2 “No Bird’s Eye Imagery” Bug

noimageryfinal Developer

There are locations in Virtual Earth where Bird’s eye Imagery doesn’t exist for certain directional facings.  When a user attempts to rotate the Bird’s eye view when imagery is unavailable for that directional facing, maps.live.com displays a warning message.  Nothing will occur by default using the VE 6.2 API.  In addition, a bug fires that causes the VE dashboard will become unusuable (see screenshot below) when a user rapidly clicks the same button several times using VE 6.2.  On the odd occasion the map view will even flip to road view showing all ocean tiles.

disappearingnav Developer

Notice how the map is on Aerial view and the Bird’s eye rotator buttons are missing.  The magnification buttons will not work when this occurs.  Flipping to road view while in this state will sometimes locks out bird’s eye view (never becomes available no matter were you pan or zoom).

Fixing this can enhance any VE application by using an easy workaround:

1) Handle onclick event when clicking the rotate clockwise/counter-clockwise buttons, check to see if orientation facing has changed.  If the orientation has not changed, imagery is unavailable.

2) Briefly hide (or disable) the rotator buttons to prevent the user from clicking on them too quickly.

The sample code below shows an example of missing bird’s eye imagery (try to rotate counter clockwise).  It also uses the workaround above, although you will need to click the “Get Orientation” div to get the map orientation before you can handle case 1).

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
      <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
      <script type=”text/javascript” src=”http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2″></script>
      <script type=”text/javascript”>
      var map = null;
      var currentOrientation;
      function GetMap()
         map = new VEMap(‘myMap’);
  map.LoadMap(new VELatLong(40.0643932590466,-75.46038866043091),16,VEMapStyle.Birdseye);
  //Set onclick handler for dashboard rotator
  //Check orientation

function CounterClockwise()
 //Hide the rotator to prevent user from rapidly clicking on button and firing VE bugs
 document.getElementById(‘MSVE_navAction_ccwWrapper’).style.display = ‘none’;
 if(currentOrientation == map.GetBirdseyeScene().GetOrientation())
  alert(“Unable to rotate CounterClockwise”);
 setTimeout(“document.getElementById(‘MSVE_navAction_ccwWrapper’).style.display = ‘block’;”,1000);

function getOrientation()
 currentOrientation = map.GetBirdseyeScene().GetOrientation();

   <body onload=”GetMap();”>
    <div id=’myMap’ style=”position:relative; width:400px; height:400px;”></div>
    <div onclick=”currentOrientation = map.GetBirdseyeScene().GetOrientation();”>Get Orientation</div>