1
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript"  src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>

<script type="text/javascript">
function GetMap()
{ 

  var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), 
   {credentials: "Your Bing Maps Key",
   center: new Microsoft.Maps.Location(45.5, -122.5),
   mapTypeId: Microsoft.Maps.MapTypeId.road,
    zoom: 7});
 }
 </script>
 </head>
<body onload="GetMap();">
 <div id='mapDiv' style="position:relative; width:400px; height:400px;"></div>  
</body>
  </html>

我什至尝试过加载一个简单的地图,但我在 Microsoft 类 undefined 上遇到 js 错误

4

2 回答 2

3

将以下行添加到页面的 <head> 部分,在您上面粘贴的部分之前:

<script src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0" type="text/javascript"
charset="UTF-8"></script>
于 2011-02-10T17:49:20.700 回答
1

您是否包含地图 api 的包含?

<script type="text/javascript" src="bingmaps.js"></script>

还是您使用的是其余服务,在这种情况下,您需要在 AJAX 调用中指定服务的位置...

http://www.earthware.co.uk/blog/index.php/2010/10/using-jquery-with-the-bing-maps-rest-api/

于 2011-02-10T14:06:34.497 回答