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 }) }