天地图:加载天地图

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

      });
原文地址:https://www.cnblogs.com/MsHibiscus/p/11490343.html