(mapInfo)
| 2898 | } |
| 2899 | |
| 2900 | _getTiandituUrl(mapInfo) { |
| 2901 | const re = /t0/gi; |
| 2902 | const tiandituUrls = { tiandituUrl: [], labelUrl: [] }; |
| 2903 | |
| 2904 | const layerType = mapInfo.baseLayer.layerType.split('_')[1].toLowerCase(); |
| 2905 | const isLabel = Boolean(mapInfo.baseLayer.labelLayerVisible); |
| 2906 | const token = this.tiandituKey || mapInfo.baseLayer.tk; |
| 2907 | let url = `https://t0.tianditu.gov.cn/{layer}_{proj}/wmts?tk=${token}`; |
| 2908 | let labelUrl = url; |
| 2909 | |
| 2910 | const layerLabelMap = { |
| 2911 | vec: 'cva', |
| 2912 | ter: 'cta', |
| 2913 | img: 'cia' |
| 2914 | }; |
| 2915 | |
| 2916 | const tilematrixSet = this.baseProjection === 'EPSG:4326' ? 'c' : 'w'; |
| 2917 | const options = { |
| 2918 | service: 'WMTS', |
| 2919 | request: 'GetTile', |
| 2920 | style: 'default', |
| 2921 | version: '1.0.0', |
| 2922 | layer: layerType, |
| 2923 | tilematrixSet: tilematrixSet, |
| 2924 | format: 'tiles', |
| 2925 | width: 256, |
| 2926 | height: 256 |
| 2927 | }; |
| 2928 | |
| 2929 | url = Util.urlAppend(url, this._getParamString(options, url) + '&tilematrix={z}&tilerow={y}&tilecol={x}') |
| 2930 | |
| 2931 | const tiandituUrl = url.replace('{layer}', layerType).replace('{proj}', tilematrixSet); |
| 2932 | const tiandituUrlArr = []; |
| 2933 | |
| 2934 | for (let i = 0; i < 8; i++) { |
| 2935 | tiandituUrlArr.push(tiandituUrl.replace(re, `t${i}`)); |
| 2936 | } |
| 2937 | tiandituUrls.tiandituUrl = tiandituUrlArr; |
| 2938 | |
| 2939 | // 如果有 label 图层 |
| 2940 | if (isLabel) { |
| 2941 | const labelLayer = layerLabelMap[layerType]; |
| 2942 | options.layer = labelLayer; |
| 2943 | labelUrl = Util.urlAppend(labelUrl, this._getParamString(options, labelUrl) + '&tilematrix={z}&tilerow={y}&tilecol={x}'); |
| 2944 | labelUrl = labelUrl.replace('{layer}', labelLayer).replace('{proj}', tilematrixSet); |
| 2945 | const labelUrlArr = []; |
| 2946 | for (let i = 0; i < 8; i++) { |
| 2947 | labelUrlArr.push(labelUrl.replace(re, `t${i}`)); |
| 2948 | } |
| 2949 | tiandituUrls.labelUrl = labelUrlArr; |
| 2950 | } |
| 2951 | |
| 2952 | return tiandituUrls; |
| 2953 | } |
| 2954 | |
| 2955 | _getProjectionWKT(projection) { |
| 2956 | let epsgCode = toEpsgCode(projection); |
no test coverage detected