The Virtual Earth JavaScript is big (XXKB). Microsoft have done the following to reduce the size and speed it up:
- JavaScript optimisation
- TODO: add more
If you want to load your page, display a loading message and then start downloading the file:
- Don’t include the JavaScript link in your header!
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script>
var map = null;
var le = 0;
function GetMap()
{
var head = document.getElementsByTagName("head")[0];
var s = document.createElement('script');
s.id = 'VEScript';
s.type = 'text/javascript';
s.src="http://local.live.com/veapi.asjx";
head.appendChild(s);
DelayGetMap();
}
function DelayGetMap()
{
try {
map = new VEMap('myMap');
document.getElementById("myLoading").style.display = "none";
document.getElementById("myMap").style.display = "block";
map.LoadMap(new VELatLong(47.6, -122.33), 10 ,'h' ,false);
}catch(err)
{
if (le < 30)
{
le++;
setTimeout("DelayGetMap()",1000);
}else
{
alert("Site is busy.");
}
}
}
</script>
</head>
<body onload="GetMap();">
<div id='myMap' style="position:relative; width:400px; height:400px;display:none;"></div>
<div id='myLoading' style="position:relative; width:400px; height:400px;">Loading...</div>
</body>
</html>
Something wrong with the code? Correct it at the Virtual Earth WIKI
Preloading message for VE JavaScript