首页 资源列表 文章列表

天地图 地图选择控件默认选中卫星混合 天地图API,HTML

this.T = window.T;


     var imageURL = "http://t0.tianditu.gov.cn/img_c/wmts?" +

       "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=c&FORMAT=tiles" +

       "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=这里密钥密钥";


     //初始化地图对象

     this.map = new this.T.Map(this.container, {

       projection: "EPSG:4326",

       layers: [new T.TileLayer(imageURL, {minZoom: 1, maxZoom: 18})],

     });


 let ctrl = new T.Control.MapType([

     // 这里顺序不能变,图层要放到第一个

       {

         title: "卫星混合",

         icon: "http://api.tianditu.gov.cn/v4.0/image/map/maptype/satellitepoi.png",

         layer: TMAP_HYBRID_MAP,

       },

       {

         title: "地图", //地图控件上所要显示的图层名称

         icon: "http://api.tianditu.gov.cn/v4.0/image/map/maptype/vector.png", //地图控件上所要显示的图层图标(默认图标大小80x80)

         layer: TMAP_NORMAL_MAP, //地图类型对象,即MapType。

       },

       {

         title: "卫星",

         icon: "http://api.tianditu.gov.cn/v4.0/image/map/maptype/satellite.png",

         layer: TMAP_SATELLITE_MAP,

       },

       {

         title: "地形",

         icon: " http://api.tianditu.gov.cn/v4.0/image/map/maptype/terrain.png",

         layer: TMAP_TERRAIN_MAP,

       },

       {

         title: "地形混合",

         icon: " http://api.tianditu.gov.cn/v4.0/image/map/maptype/terrainpoi.png",

         layer: TMAP_TERRAIN_HYBRID_MAP,

       }

     ]);


     ctrl.setPosition(window.T_ANCHOR_BOTTOM_LEFT); //地图选择控件位置

     this.map.addControl(ctrl); //添加地图选择控件