From 7bd53b71aaef7e7a729ca62c48c72ad3c4d9ba30 Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Mon, 14 Jul 2025 13:28:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=82=B9=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/maps/config.js | 2 +- src/components/maps/indexmaps.vue | 2 +- src/components/maps/maps.vue | 23 +++++++++++++++-------- src/components/maps/mapsbefore.vue | 2 +- src/views/car/location.vue | 9 +++++++-- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/components/maps/config.js b/src/components/maps/config.js index 1458dc7..fd3b4da 100644 --- a/src/components/maps/config.js +++ b/src/components/maps/config.js @@ -139,7 +139,7 @@ const MAPCONFIGS = { Map_axisOrientation: 'neu', // 轴 Map_global: false, // 全球 MAP_center: [120.6126391, 31.3029816], // 定义中心点 - // [113.85630301,22.63856214] + // [120.6126391, 31.3029816] [113.85630301,22.63856214] Map_Zooms: [12, 23, 10], // 定义地图初始层级、最大层级、最小层级 Map_ID: 'maps' // 地图标识ID } diff --git a/src/components/maps/indexmaps.vue b/src/components/maps/indexmaps.vue index 93f44eb..580b4ba 100644 --- a/src/components/maps/indexmaps.vue +++ b/src/components/maps/indexmaps.vue @@ -121,7 +121,7 @@ export default { this.map = map // 添加天地图 let url = 'http://t0.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}' - url = `${url}&T=vec_c&tk=2eecd3d615e01cf6dbe6d4b8b686d264` + url = `${url}&T=vec_c&tk=75488413aef20f190e5c7708347c3e56` const tdtLayer = new TileLayer({ title: '天地图', id: 'M2', diff --git a/src/components/maps/maps.vue b/src/components/maps/maps.vue index 395f74b..5fe89d1 100644 --- a/src/components/maps/maps.vue +++ b/src/components/maps/maps.vue @@ -365,17 +365,18 @@ export default { }) this.map = map // 添加天地图 - let url = 'http://t0.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}' - url = `${url}&T=vec_c&tk=2eecd3d615e01cf6dbe6d4b8b686d264` + let url = 'http://t1.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}' + url = `${url}&T=vec_c&tk=75488413aef20f190e5c7708347c3e56` // let sourceMark = `http://t0.tianditu.com/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=5a257cd2df1b3311723bd77b0de14baf` - const sourceMark = 'http://t3.tianditu.com/DataServer?T=cva_c&x={x}&y={y}&l={z}&tk=2eecd3d615e01cf6dbe6d4b8b686d264' + const sourceMark = 'http://t3.tianditu.com/DataServer?T=cva_c&x={x}&y={y}&l={z}&tk=75488413aef20f190e5c7708347c3e56' const tdtLayer = new TileLayer({ title: '天地图', id: 'M2', type: 'overlay', visible: true, layerType: 'TD地图', - opacity: 1, + opacity: 1, + preload: Infinity, source: new XYZ({ crossOrigin: 'anonymous', url: url, @@ -393,6 +394,7 @@ export default { layerType: 'TD地图1', opacity: 1, zIndex: 2, + preload: Infinity, source: new XYZ({ crossOrigin: 'anonymous', url: sourceMark, @@ -439,7 +441,8 @@ export default { tileGrid: tileGrid, url: result.url, projection: projection - }) + }), + preload: Infinity, }) this.map.addLayer(layer) } else { @@ -449,7 +452,8 @@ export default { type: result.type, visible: result.visible, layerType: result.layerType, - opacity: result.opacity, + opacity: result.opacity, + preload: Infinity, source: new TileArcGISRest({ url: result.url, projection: result.projection @@ -531,7 +535,9 @@ export default { this.flagLayer.getSource().addFeatures(this.featuresArr) this.$nextTick(function() { // 根据定位点 移动地图 - this.moveto(this.locationObj.location.longitude, this.locationObj.location.latitude) + // this.moveto(this.locationObj.location.longitude, this.locationObj.location.latitude) + this.moveto(this.locationObj.location.longitude, this.locationObj.location.latitude) + this.autoOpen(feature) }) }, @@ -719,7 +725,8 @@ export default { this.popup.setPosition(coordinates) }, // 移动地图 - moveto(longitude, latitude) { + moveto(longitude, latitude) { + console.log(longitude, latitude) this.map.getView().animate({ center: [longitude, latitude], // 中心点 rotation: undefined, diff --git a/src/components/maps/mapsbefore.vue b/src/components/maps/mapsbefore.vue index fc2fc5d..de0ab14 100644 --- a/src/components/maps/mapsbefore.vue +++ b/src/components/maps/mapsbefore.vue @@ -125,7 +125,7 @@ export default { console.log('开始执行2') const script = document.createElement('script') script.type = 'text/JavaScript' - script.src = 'http://api.tianditu.gov.cn/api?v=4.0&tk=2eecd3d615e01cf6dbe6d4b8b686d264' + script.src = 'http://api.tianditu.gov.cn/api?v=4.0&tk=75488413aef20f190e5c7708347c3e56' console.log('开始执行3') script.onload = function() { console.log('js加载完成') diff --git a/src/views/car/location.vue b/src/views/car/location.vue index 52e9e6c..46ea3db 100644 --- a/src/views/car/location.vue +++ b/src/views/car/location.vue @@ -198,12 +198,17 @@ export default { if (isSe) { this.list.push(data) console.log('data', data) - this.locationObj = data + this.locationObj = data + // this.locationObj.location.longitude="31.3029816" + // this.locationObj.location.latitude="120.6126391" + // [120.6126391, 31.3029816] } else { for (var i = 0; i < this.list.length; i++) { if (this.list[i].gps == data.gps) { this.list.splice(i, 1) - this.locationObj = data + this.locationObj = data + // this.locationObj.location.longitude="31.3029816" + // this.locationObj.location.latitude="120.6126391" } } // this.$refs.maps.removeLocation(data)