天地圖:加載天地圖


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);

      });

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM