
import L from 'leaflet';
import * as esri from 'esri-leaflet';
let tdtKey = '0eab750b26cdeee155e8c4f2310b53ef'
const leMap ={
  map:'',
  initMap:function(){
    const tiandituMap =
     L.tileLayer(`http://t0.tianditu.gov.cn/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${tdtKey}`)
    //注记
    const tiandituText =
     L.tileLayer(`http://t0.tianditu.gov.cn/cia_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${tdtKey}`)
    const layers = L.layerGroup([tiandituMap,tiandituText])
    this.map = L.map('viewDiv',{  //需绑定地图容器div的id
      maxZoom:25, //最大缩放等级
      minZoom:0, //最小缩放等级
      zoomControl:false,//不显示缩放小控件
      layers:[layers],

    }).setView([ 33.2648527905986, 118.85722842688202], 18);
  },
  addLayer:function(e){
     let layer = esri
     .dynamicMapLayer({
      url:e.url,
     })
     layer.addTo(this.map)
  }
}
export default leMap
