
var mapElementName = 'myMap';
var mapControlVersion = '6.2';

// Dynamic loading script from http://www.soulsolutions.com.au/examples/VE62/loadondemand.htm
var loaded = false;        
var map = null; 
       
function onscriptload() 
{            
    // Get rid of our load animation            
    document.getElementById(mapElementName).style.background = "";   
                 
    var locationLatLong = new VELatLong(54.9713020325, -2.1112570763);
    
    map = new VEMap(mapElementName);
    map.LoadMap(locationLatLong, 1, VEMapStyle.Road, true, VEMapMode.Mode2D, false, 0);
    map.HideDashboard();
    map.HideScalebar();
    map.SetZoomLevel(10);

    AddLocationPushpin(locationLatLong);
}        

function loadVEAPI() 
{ 
    if (!loaded) 
    {                
        loaded = true; 
                       
        // Set a nice animated gif to show the map is loading                
        document.getElementById(mapElementName).style.background = "url(images/ajax-loader.gif) center center no-repeat";    
                    
        if (!(window.attachEvent)) 
        {                    
            appendJS("http://dev.virtualearth.net/mapcontrol/v" + mapControlVersion + "/js/atlascompat.js");
        }   
                     
        appendJS("http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=" + mapControlVersion + "&onScriptLoad=onscriptload");            
    }        
}

function appendJS(filename) 
{            
    var fileref = document.createElement('script');            
    fileref.setAttribute("type", "text/javascript");            
    fileref.setAttribute("src", filename);            
    document.getElementsByTagName("head")[0].appendChild(fileref);        
}

function AddLocationPushpin(myLocation)
{
    map.SetCenter(myLocation);    

    var myPushpin = new VEShape(VEShapeType.Pushpin, myLocation);

    myPushpin.SetTitle("Crescent Avenue, Hexham, Northumberland, England"); 

    var description = "<p></p>";
    description += "<p><i>25/08/2009 06:54:22 GMT</i></p>";
    myPushpin.SetDescription(description);

    map.AddShape(myPushpin);
}

// Start the loading
loadVEAPI();

