1,首先需要引進官方的js:
1 <script type="text/javascript" src="http://api.tianditu.gov.cn/api?v=4.0&tk=密鑰" ></script>
2,創建放地圖的容器,並設置好id和容器的大小
<div id="mapDiv"></div>
3,加載基本底圖
createdMap: function () { var that = this; this.map = new T.Map("mapDiv"); //設置顯示地圖的中心點和級別 //zoom縮放等級 this. map.centerAndZoom(new T.LngLat(116.40969, 39.89945), zoom); //創建圖片對象 var icon = new T.Icon({ iconUrl: that.imgUrl,//圖片地址 iconSize: new T.Point(19, 27), iconAnchor: new T.Point(10, 25) }); //向地圖上添加自定義標注 var marker = new T.Marker(new T.LngLat(lon, lat), { icon: icon }); this.map.addOverLay(marker); });