How to delay load the Virtual Earth map control

This code snippet shows how to add a delay into the loading of the VE map control. This can be required if the control has not fully loaded before you try to access it.

var count;
LoadMap();

function LoadMap()
{
    try
    {
        // Create a map control. This will fail if the javascript hasnt loaded yet
        map = new VEMap(‘myMap’);
        map.LoadMap(new VELatLong(52.1, 1.0965), 14 ,‘r’ ,false);
    }
    catch(err)
    {
        if (count < 20)
        {
            count++;
            setTimeout("LoadMap()",500);
        }
        else
            alert("Cannot load VE map control. Site is busy.");
    }
}

 

Advertisements