Many Virtual Earth applications need to update content on the map after the map is panned.  This can be done by attaching a callback to the "onendcontinuous" pan event on the VEMap.  The following code sample shows this:

var map = null;
function HandleEndPan()
{
   // insert your end pan code here…
}

function EventMapLoad()
{
   map.AttachEvent('onendcontinuouspan', HandleEndPan);
}

map = new VEMap('myMap');
map.onLoadMap = EventMapLoad;
map.LoadMap();

However, if the user is panning the map very often in short increments (which can be common as the user pans the map around), this event can fire many times.  If the code executing in response to the pan is a heavyweight operation, this can hinder performance of the application.

One solution to this problem is to throttle the end pan events by using a timer with a sliding window.  For example, the following code sample sets a sliding window to 1.5 seconds and will only process the HandleEndPan when the time expires and there has not been another pan within that window: (changes to the original example are in bold)

var map = null;

var endPanTimer = null;
var END_PAN_TIMER_DELAY = 1500;

function HandleEndPan()
{

   endPanTimer = null; 

   // insert your end pan code here…
}

function EventEndContinuousPan()
{
   //If the timer is set, clear it and reset it
   if (endPanTimer != null)
   {
      window.clearTimeout(endPanTimer);
   }
   endPanTimer = window.setTimeout(HandleEndPan, END_PAN_TIMER_DELAY);
}

function EventMapLoad()
{
   map.AttachEvent('onendcontinuouspan', EventEndContinuousPan);
}

map = new VEMap('myMap');
map.onLoadMap = EventMapLoad;
map.LoadMap();

This greatly reduces the number of calls to HandleEndPan.  Here are links to the complete listing for the sample code for both examples:

In these examples, the number of calls to HandleEndPan is displayed below the map as you pan the map.  As you can see, panning with throttling greatly reduces the number of calls to HandleEndPan as you pan the map.  This is an effective technique for reducing the number of calls to any expensive operations which need to be performed as as you pan the map in your application.