From 626003e9beb59cf711f59f3b48087300070f121e Mon Sep 17 00:00:00 2001 From: lixuliang <lixuliang_hd@126.com> Date: 星期五, 15 三月 2024 09:49:31 +0800 Subject: [PATCH] 优化 --- src/utils/tool.js | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 51 insertions(+), 9 deletions(-) diff --git a/src/utils/tool.js b/src/utils/tool.js index a8e0345..736d888 100644 --- a/src/utils/tool.js +++ b/src/utils/tool.js @@ -1,7 +1,7 @@ import _GLOBAL from '@/assets/GLOBAL2' import gcj02Mecator from '@/utils/transform' -import { ceil } from 'lodash'; + //娓呴櫎 export function clearAll() { if (_GLOBAL.ImageLayer) { @@ -30,9 +30,12 @@ _GLOBAL.ImageLayer = new ol.layer.Tile({ source: new ol.source.XYZ({ url: `${'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer'}/tile/{z}/{y}/{x}`, + projection: "EPSG:3857", + tileSize: 512 }), }); - window.mapapi.addLayer(_GLOBAL.ImageLayer); + // window.mapapi.addLayer(_GLOBAL.ImageLayer); + layersArray.insertAt(1, _GLOBAL.ImageLayer); } //鍔犺浇鐧借壊鍦板浘 @@ -43,14 +46,15 @@ url: "https://skyzt.bda.gov.cn/gisserver/wmsserver/shiliangditu_baisexi_wms", //鍥惧眰鍦板潃 params: { VERSION: "1.1.1", - SRS: "EPSG:4326", + SRS: "EPSG:3857", FORMAT: "image/png", TILED: true, LAYERS: "", }, }), }); - window.mapapi.addLayer(_GLOBAL.baseMap) + // window.mapapi.addLayer(_GLOBAL.baseMap) + layersArray.insertAt(1, _GLOBAL.baseMap); } @@ -63,8 +67,8 @@ url: ` https://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}`, }), }); - window.mapapi.addLayer(_GLOBAL.geoMap); - + // window.mapapi.addLayer(_GLOBAL.geoMap); + layersArray.insertAt(1, _GLOBAL.geoMap); } @@ -88,7 +92,7 @@ url: 'https://skyzt.bda.gov.cn/gisserver/wmsserver/YZ_BJ60', params: { 'VERSION': '1.1.1', - 'SRS': 'EPSG:4326', + 'SRS': 'EPSG:3857', 'FORMAT': 'image/png', 'TILED': true, "LAYERS": '' @@ -106,7 +110,7 @@ url: 'https://skyzt.bda.gov.cn/gisserver/wmsserver/YZ_BJ',//鍥惧眰鍦板潃 params: { 'VERSION': '1.1.1', - 'SRS': 'EPSG:4326', + 'SRS': 'EPSG:3857', 'FORMAT': 'image/png', 'TILED': true, "LAYERS": '' @@ -124,10 +128,45 @@ } _GLOBAL.historyLayer = new ol.layer.Tile({ source: new ol.source.XYZ({ + projection: "EPSG:3857", url: `https://skyzt.bda.gov.cn/yzAdapter/Vector/?request=1&year=${layerName}&type=Sate&level={z}&x={x}&y={y}`, }) }); window.mapapi.addLayer(_GLOBAL.historyLayer); +} +var topResolution = 896.0859375; +var resolutions = []; +let matrixIds = []; + +for (let zoom = 0; zoom < 13; zoom++) { + resolutions.push(topResolution / Math.pow(2, zoom)); + matrixIds[zoom] = zoom; +} +// +// 鍔犺浇鍘嗗彶褰卞儚璺綉 +export function addHistoryLW(name) { + const layerName = name; + if (_GLOBAL.historyLW) { + window.mapapi.removeLayer(_GLOBAL.historyLW) + } + + _GLOBAL.historyLW = new ol.layer.Tile({ + source: new ol.source.WMTS({ + url: "https://skyzt.bda.gov.cn/service/ImageEngine/picdis/abc?", + layer: "Shiliang_Lw_2019", + style: "", + format: "image/png", + // 鎶曞奖鍧愭爣绯� + tileGrid: new ol.tilegrid.WMTS({ + extent: [371987.18334, 252920.58593, 624459.12036, 423400.07714], + origin: [0, 688194], + resolutions: resolutions, + matrixIds: matrixIds, + tileSize: 256, + }), + }), + }); + window.mapapi.addLayer(_GLOBAL.historyLW); } //瀹炴椂鑾峰彇瀹氫綅 @@ -149,12 +188,15 @@ //鍒涘缓褰撳墠瀹氫綅鐐� export function createGPSMarker(position, rotate) { + let GPSPOI_3857 = ol.proj.fromLonLat(position); + // 璁板綍褰撳墠浣嶇疆(瀹氫綅鐢�) + window.personalPoi = GPSPOI_3857; const GPSMarkerLayer = new ol.layer.Vector({ id: 'LocationPoint', name: '瀹氫綅鐐�', source: new ol.source.Vector({ features: [new ol.Feature({ - geometry: new ol.geom.Point(position), + geometry: new ol.geom.Point(GPSPOI_3857), })] }), style: new ol.style.Style({ -- Gitblit v1.9.3