天地图:加载天地图


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