From 7d62562575cbd5bb131d34560b0498eabf66835e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com> Date: Wed, 29 Mar 2023 18:04:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=B0=E5=9B=BE=E8=B7=AF?= =?UTF-8?q?=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../historicalRoute/index.vue | 51 +++++++++++++++---- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/ruoyi-ui/src/views/realTimeMonitoring/historicalRoute/index.vue b/ruoyi-ui/src/views/realTimeMonitoring/historicalRoute/index.vue index 1af29f5..309b5b9 100644 --- a/ruoyi-ui/src/views/realTimeMonitoring/historicalRoute/index.vue +++ b/ruoyi-ui/src/views/realTimeMonitoring/historicalRoute/index.vue @@ -54,7 +54,7 @@ AMapLoader.load({ key: "ba8fb8d8bae1b280b93406d5959d492f", // 申请好的Web端开发者Key,首次调用 load 时必填 // version: "1.4.15", // version: "2.0", // - plugins: ['AMap.MouseTool', 'AMap.PolygonEditor', 'AMap.ToolBar', 'AMap.Scale', 'AMap.HawkEye', 'AMap.MapType', 'AMap.Marker'], + plugins: ['AMap.MouseTool', 'AMap.PolygonEditor', 'AMap.ToolBar', 'AMap.Scale', 'AMap.HawkEye', 'AMap.MapType', 'AMap.Marker', 'AMap.GraspRoad'], AMapUI: { version: '1.1', @@ -87,14 +87,47 @@ AMapLoader.load({ const handleQuery = () => { polyline ? map.remove([polyline]) : '' getTrack(proxy.addDateRange(queryParams.value, dateRange.value)).then(e => { - polylinePath.value = e.data.map(val => [val.longitude, val.latitude]) - polyline = new AMap.Polyline({ - strokeColor: '#00BBFF', // 线颜色-深蓝色 - path: polylinePath.value, - strokeWeight: 6 // 线宽 - }) - map.add(polyline); - map.setFitView() + let pathRow = e.data.map(val => [val.longitude, val.latitude]) + let grasp = new AMap.GraspRoad(); + AMap.convertFrom(pathRow, 'gps', function (status, result) { + if (result.info === 'ok') { + let lnglats = result.locations.map(e=>[e.lng,e.lat]); + + let GraspRoadPath = lnglats.map((res, i) => { + if (i === 0) { + return { + 'x': res[0], + 'y': res[1], + 'sp': 10, + 'ag': 0, + 'tm': 1478031031, + } + } + return { + 'x': res[0], + 'y': res[1], + 'sp': 10, + 'ag': 0, + 'tm': i, + } + }) + grasp.driving(GraspRoadPath, function (error, result) { + if (!error) { + var newPath = result.data.points;//纠偏后的轨迹 + var distance = result.data.distance;//里程 + let newPolylinePath = newPath.map(e => [e.x, e.y]) + polyline = new AMap.Polyline({ + strokeColor: '#00BBFF', // 线颜色-深蓝色 + path: newPolylinePath, + strokeWeight: 6 // 线宽 + }) + map.add(polyline); + map.setFitView() + } + }) + } + }); + polylinePath.value = pathRow }) }