import { map } from './index_old';
|
import calculate from './calculate';
|
import { getHexColor } from '../color';
|
|
var _polylineArr = [];
|
|
export default {
|
drawLine(fDatas, factor) {
|
const lnglats_GD = fDatas.lnglats_GD;
|
const colors = factor.colors;
|
|
if (_polylineArr) {
|
map.remove(_polylineArr);
|
_polylineArr = [];
|
}
|
var path = calculate.parse2LngLat(lnglats_GD);
|
|
let sIndex = 0;
|
for (let i = 1; i < path.length; i++) {
|
// if (colors[i] == colors[i - 1]) {
|
// } else {
|
// }
|
const _path = [path[i], path[i + 1]];
|
const _color = getHexColor(colors[i + 1].map((v) => v * 255));
|
// 创建折线实例
|
// eslint-disable-next-line no-undef
|
const polyline = new AMap.Polyline({
|
path: _path,
|
strokeStyle: 'solid',
|
isOutline: true,
|
borderWeight: 2,
|
outlineColor: 'white',
|
strokeWeight: 4, // 线条宽度,默认为 1
|
strokeColor: _color, // 线条颜色
|
lineJoin: 'round', // 折线拐点连接处样式
|
showDir: true
|
});
|
_polylineArr.push(polyline);
|
}
|
// 将折线添加至地图实例
|
map.add(_polylineArr);
|
return _polylineArr;
|
}
|
};
|