一个简单的加载速度非常快的示例,加载Virtual Earth地图到网站
一个简单的加载速度非常快的示例. 点击 here 加载 Virtual Earth 地图到网站。点击打印HTML源代码。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Load Virtual Earth on Demand</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> var loaded = false; var map = null; function onscriptload() { //get rid of our load animation and load the map document.getElementById("myMap").style.background = ""; map = new VEMap('myMap'); map.LoadMap(new VELatLong(-27.47, 153.03), 16, VEMapStyle.Hybrid); } function loadVEAPI() { if (!loaded) { loaded = true; //set a nice animated gif to show the map is loading document.getElementById("myMap").style.background = "url(ajax-loader.gif) center center no-repeat"; if (!(window.attachEvent)) { appendJS("http://dev.virtualearth.net/mapcontrol/v6.2/js/atlascompat.js"); } appendJS("http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&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); } </script> </head> <body> <p>A simple website doing its own thing, loading very fast. Click <a href="#" onclick="loadVEAPI()">here</a> to load a Virtual Earth map on demand.</p> <div id="myMap" style="position: relative; width: 800px; height: 600px;"></div> </body> </html>