* @private * @function WebMap.prototype.createWMTSSource * @description 获取WMTS类型图层的source。 * @param {Object} layerInfo - 图层信息。 * @returns {ol.source.WMTS} wmts的souce
(layerInfo)
| 1865 | * @returns {ol.source.WMTS} wmts的souce |
| 1866 | */ |
| 1867 | createWMTSSource(layerInfo) { |
| 1868 | let extent = layerInfo.extent || olProj.get(layerInfo.projection).getExtent(); |
| 1869 | |
| 1870 | // 单位通过坐标系获取 (PS: 以前代码非4326 都默认是米) |
| 1871 | let unit = olProj.get(this.baseProjection).getUnits(); |
| 1872 | const that = this; |
| 1873 | return new WMTS({ |
| 1874 | url: layerInfo.tileUrl || layerInfo.url, |
| 1875 | layer: layerInfo.layer, |
| 1876 | format: layerInfo.layerFormat, |
| 1877 | style: layerInfo.style, |
| 1878 | matrixSet: layerInfo.tileMatrixSet, |
| 1879 | requestEncoding: layerInfo.requestEncoding || 'KVP', |
| 1880 | tileGrid: this.getWMTSTileGrid( |
| 1881 | extent, |
| 1882 | layerInfo.scales, |
| 1883 | unit, |
| 1884 | layerInfo.dpi, |
| 1885 | layerInfo.origin, |
| 1886 | layerInfo.matrixIds |
| 1887 | ), |
| 1888 | tileLoadFunction: this.getCustomTileLoadFunction(function (src) { |
| 1889 | if (src.indexOf('tianditu.gov.cn') >= 0) { |
| 1890 | return `${src}&tk=${CommonUtil.getParameters(layerInfo.url)['tk']}`; |
| 1891 | } |
| 1892 | if(that.isAddProxy(src, layerInfo.proxy)) { |
| 1893 | return `${that.getProxy('png')}${encodeURIComponent(src)}`; |
| 1894 | } |
| 1895 | return src; |
| 1896 | }) |
| 1897 | }); |
| 1898 | } |
| 1899 | |
| 1900 | /** |
| 1901 | * @private |
no test coverage detected