修改地图路线

master
夜笙歌 2 years ago
parent 06a524436e
commit 7d62562575

@ -54,7 +54,7 @@ AMapLoader.load({
key: "ba8fb8d8bae1b280b93406d5959d492f", // WebKey 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
})
}
</script>

Loading…
Cancel
Save