2013/10/05

申請 Bing Maps API

最近比賽需要,所以就來申請Bing Maps API
Bing Maps API既Google Maps API的另一個選擇
首先到Bing Maps申請一組Key,申請之前必須先擁有Microsoft account

Bing Maps API有分三種版本,在這邊我是用Basic Key



  Trial Key Basic Key Enterprise Key
Public website ※ ※ ※
Windows Store app ※ ※ ※
Mobile ※ ※ ※
Broadcast ※ ※ ※
Not-for-profit ※ ※  
Education ※ ※  
Private website ※   ※
Business asset management ※   ※

申請完會看到Bing Maps Account Center




點Create or view keys

接著輸入應用名稱、網址和種類以及驗證碼

創立好之後,下面就會有Key出現

接著我們來建立HTML吧!
<!DOCTYPE html>
<html>
 <head>
 <meta 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 Key Number",
        center: new Microsoft.Maps.Location(45.5, -122.5),
        mapTypeId: Microsoft.Maps.MapTypeId.road,
        zoom: 7});
  }
 </script>
 </head>
 <body onload="GetMap();">
  <div id='mapDiv'></div>
 </body>
</html>

Bing Maps API用法也與Google Maps API的用法相近。只是Google Maps API是透過網址去設定Key,Bing Maps API則是透過建立地圖的建構子去設定Key



參考資料:
http://www.microsoft.com/maps/
http://msdn.microsoft.com/en-us/library/gg427610.aspx
http://msdn.microsoft.com/en-us/library/gg427624.aspx
http://www.bingmapsportal.com/ISDK/AjaxV7
http://blog.roodo.com/vsy_haha/archives/40735.html
http://www.w3schools.com/tags/tag_doctype.asp
http://blog.xuite.net/vexed/tech/22531922
http://bbs.csdn.net/topics/190058763