|
|
@@ -115,54 +115,54 @@ export function useGMapTrajectory() {
|
|
|
strokeWeight: 6,//线宽
|
|
|
strokeStyle: 'solid',
|
|
|
})
|
|
|
- const serialList = list.filter((item) => item.type === 1);
|
|
|
- // 序号
|
|
|
- const text = serialList.map((item, index) => {
|
|
|
- return new AMap.Text({
|
|
|
- position: new AMap.LngLat(item.paths[0], item.paths[1]),
|
|
|
- offset: new AMap.Pixel(-8, -30),
|
|
|
- text: index + 1,
|
|
|
- style: {
|
|
|
- backgroundColor: 'transparent',
|
|
|
- borderColor: 'transparent',
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- // 序号下方圆形标记
|
|
|
- const circles = serialList.map((item, index) => {
|
|
|
- return new AMap.Circle({
|
|
|
- center: new AMap.LngLat(item.paths[0], item.paths[1]),
|
|
|
- radius: 0.5, // 半径
|
|
|
- // strokeColor: 'white',
|
|
|
- fillColor: 'white',
|
|
|
- fillOpacity: 1,
|
|
|
- strokeWeight: 2,
|
|
|
- });
|
|
|
- })
|
|
|
- // 计算并显示每段线的距离
|
|
|
- const distances = [];
|
|
|
- const serialPaths = serialList.map(item => item.paths)
|
|
|
- for (let i = 0; i < serialPaths.length - 1; i++) {
|
|
|
- const distance = AMap.GeometryUtil.distance(new AMap.LngLat(serialPaths[i][0], serialPaths[i][1]), new AMap.LngLat(serialPaths[i + 1][0], serialPaths[i + 1][1]));
|
|
|
- // 计算两个点之间的中点坐标
|
|
|
- const midLng = (serialPaths[i][0] + serialPaths[i + 1][0]) / 2;
|
|
|
- const midLat = (serialPaths[i][1] + serialPaths[i + 1][1]) / 2;
|
|
|
- const midPoint = new AMap.LngLat(midLng, midLat);
|
|
|
- // 在中点位置放置文本以显示距离
|
|
|
- const distanceText = new AMap.Text({
|
|
|
- position: midPoint,
|
|
|
- offset: new AMap.Pixel(-16, 10),
|
|
|
- text: `${distance.toFixed(1)} m`,// 距离
|
|
|
- style: {
|
|
|
- fontSize: '10px',
|
|
|
- color: '#FFFFFF',
|
|
|
- backgroundColor: 'rgba(0, 0, 0, 0.75)',
|
|
|
- borderColor: 'transparent',
|
|
|
- },
|
|
|
- });
|
|
|
- distances.push(distanceText);
|
|
|
- }
|
|
|
- const other = [polyline, ...text, ...circles, ...distances]
|
|
|
+ // const serialList = list.filter((item) => item.type === 1);
|
|
|
+ // // 序号
|
|
|
+ // const text = serialList.map((item, index) => {
|
|
|
+ // return new AMap.Text({
|
|
|
+ // position: new AMap.LngLat(item.paths[0], item.paths[1]),
|
|
|
+ // offset: new AMap.Pixel(-8, -30),
|
|
|
+ // text: index + 1,
|
|
|
+ // style: {
|
|
|
+ // backgroundColor: 'transparent',
|
|
|
+ // borderColor: 'transparent',
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ // // 序号下方圆形标记
|
|
|
+ // const circles = serialList.map((item, index) => {
|
|
|
+ // return new AMap.Circle({
|
|
|
+ // center: new AMap.LngLat(item.paths[0], item.paths[1]),
|
|
|
+ // radius: 0.5, // 半径
|
|
|
+ // // strokeColor: 'white',
|
|
|
+ // fillColor: 'white',
|
|
|
+ // fillOpacity: 1,
|
|
|
+ // strokeWeight: 2,
|
|
|
+ // });
|
|
|
+ // })
|
|
|
+ // // 计算并显示每段线的距离
|
|
|
+ // const distances = [];
|
|
|
+ // const serialPaths = serialList.map(item => item.paths)
|
|
|
+ // for (let i = 0; i < serialPaths.length - 1; i++) {
|
|
|
+ // const distance = AMap.GeometryUtil.distance(new AMap.LngLat(serialPaths[i][0], serialPaths[i][1]), new AMap.LngLat(serialPaths[i + 1][0], serialPaths[i + 1][1]));
|
|
|
+ // // 计算两个点之间的中点坐标
|
|
|
+ // const midLng = (serialPaths[i][0] + serialPaths[i + 1][0]) / 2;
|
|
|
+ // const midLat = (serialPaths[i][1] + serialPaths[i + 1][1]) / 2;
|
|
|
+ // const midPoint = new AMap.LngLat(midLng, midLat);
|
|
|
+ // // 在中点位置放置文本以显示距离
|
|
|
+ // const distanceText = new AMap.Text({
|
|
|
+ // position: midPoint,
|
|
|
+ // offset: new AMap.Pixel(-16, 10),
|
|
|
+ // text: `${distance.toFixed(1)} m`,// 距离
|
|
|
+ // style: {
|
|
|
+ // fontSize: '10px',
|
|
|
+ // color: '#FFFFFF',
|
|
|
+ // backgroundColor: 'rgba(0, 0, 0, 0.75)',
|
|
|
+ // borderColor: 'transparent',
|
|
|
+ // },
|
|
|
+ // });
|
|
|
+ // distances.push(distanceText);
|
|
|
+ // }
|
|
|
+ const other = [polyline]
|
|
|
// 获取起飞点
|
|
|
const homeList = list.filter(item => item.type === 0);
|
|
|
if (homeList.length) {
|