美文网首页
加载天地图-new

加载天地图-new

作者: xueyueshuai | 来源:发表于2023-07-25 23:13 被阅读0次
    import {get as getProjection} from 'ol/proj'
    import TileLayer from "ol/layer/Tile";
    import {XYZ} from "ol/source";
    
    let typeObj = {
      'vec': '矢量底图',
      'cva': '矢量注记',
    
      'img': '影像底图',
      'cia': '影像注记',
    
      'ter': '地形晕渲',
      'cta': '地形注记',
    
      'ibo': '全球境界',
    
      'eva': '矢量英文注记',
    
      'eia': '影像英文注记',
    }
    let projectionWayObj = {
      'c': '经纬度投影',
      'w': '球面墨卡托投影',
    }
    
    let xysGetTDT = (epsg = 'EPSG:4326', type = 'vec', projectionWay = 'w', layerOption = {}) => {
      let sourceOption = {}
      if (projectionWay === 'c') {
        sourceOption.projection = getProjection(epsg)
      }
    
    
      if(epsg === 'EPSG:3857' && projectionWay==='c'){
        projectionWay = 'w'
      }
    
      return new TileLayer({
        name: '天地图-' + typeObj[type] + '-' + projectionWayObj[projectionWay],
        source: new XYZ({
          url: 'http://t0.tianditu.gov.cn/DataServer?T=' + type + '_' + projectionWay + '&x={x}&y={y}&l={z}&tk=6d6732d7f432d1a70b3c0c9fc0e4d8fd',
          ...sourceOption
        }),
        ...layerOption
      })
    }
    
    export default xysGetTDT
    
    

    相关文章

      网友评论

          本文标题:加载天地图-new

          本文链接:https://www.haomeiwen.com/subject/yaohpdtx.html