From 7aa5e3e485dc9d85e0fe68bcb7fe508bc1fcbd1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com> Date: Tue, 16 May 2023 16:31:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=90=9C=E7=B4=A2=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/realTimeMonitoring/historicalRoute/index.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ruoyi-ui/src/views/realTimeMonitoring/historicalRoute/index.vue b/ruoyi-ui/src/views/realTimeMonitoring/historicalRoute/index.vue index e8e15e4..c3040eb 100644 --- a/ruoyi-ui/src/views/realTimeMonitoring/historicalRoute/index.vue +++ b/ruoyi-ui/src/views/realTimeMonitoring/historicalRoute/index.vue @@ -46,6 +46,8 @@ const dateRange = ref([]) let map = null let polyline = null let polylinePath = ref([]) +let distance = null +let text = null let mouseTool = null @@ -108,6 +110,7 @@ const convertFrom = (LngLatArray, success) =>{ const handleQuery = () => { polyline ? map.remove([polyline]) : '' getTrack(proxy.addDateRange(queryParams.value, dateRange.value)).then(e => { + text&&text.remove() let pathRow = e.data.map(val => [val.longitude, val.latitude]) convertFrom(pathRow,(result)=>{ let lnglats = result.map(e => [e.lng, e.lat]); @@ -118,8 +121,8 @@ const handleQuery = () => { strokeWeight: 6 // 线宽 }) map.add(polyline); - let distance = Math.round(AMap.GeometryUtil.distanceOfLine(lnglats)); - let text = new AMap.Text({ + distance = Math.round(AMap.GeometryUtil.distanceOfLine(lnglats)); + text = new AMap.Text({ position: lnglats.at(-1), text: '行驶路径' + distance + '米', offset: new AMap.Pixel(-20, -20)