Welcome

首页 / 软件开发 / Silverlight / 在Silverlight 2应用程序中集成Virtual Earth

在Silverlight 2应用程序中集成Virtual Earth2011-09-13 cnblogs TerryLee概述

Virtual Earth是什么,我想不用多做解释了。微软在推出自己的Virtual Earth之后,开放了大量的 APIs,使得我们可以方便集成到自己的应用程序中。

在HTML中集成

在开始之前,我们先来简单看一下如何在HTML中集成Virtual Earth,大家可以去这里查询相关APIs, 我们来看看如何加载默认地图,如下代码所示:

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript"
src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1"></script>
<script type="text/javascript">
var map = null;

function GetMap()
{
map = new VEMap("myMap");
map.LoadMap();
}
</script>
</head>
<body onload="GetMap();">
<div id="myMap" style="position:relative; width:480px; height:320px;"></div>
</body>
</html>

其实这段代码非常简单的简单,首先引入Virtual Earth Map控件,并且使用JavaScript来加载地图。