MapService.js 代码
/*
各种地图服务的公共接口
*/
import TileLayer from 'ol/layer/Tile';
import XYZ from 'ol/source/XYZ';
import WMTS from 'ol/source/WMTS';
import TileWMS from 'ol/source/TileWMS';
import TileImage from "ol/source/TileImage";
import WMTSTileGrid from 'ol/tilegrid/WMTS';
import TileGrid from "ol/tilegrid/TileGrid";
import {
get as getProjection
} from 'ol/proj';
import {
getTopLeft,
getWidth
} from 'ol/extent';
// 定义一些常量
const projection = getProjection('EPSG:3857');
const projectionExtent = projection.getExtent();
const size = getWidth(projectionExtent) / 256;
const resolutions = new Array(18);
const matrixIds = new Array(19);
for (let z = 0; z < 19; ++z) {
resolutions[z] = size / Math.pow(2, z);
matrixIds[z] = z;
}
// 天地图的tk
const tk = '7786923a385369346d56b966bb6ad62f';
// 百度地图参数
const resolutions2 = [];
for (let z = 0; z < 19; ++z) {