| | |
| | | const lastC = colors[i - 1]; |
| | | if (distance > 500 || c != lastC) { |
| | | let _path, _color; |
| | | _path = path.slice(sIndex, i); |
| | | _color = getHexColor( |
| | | lastC.map((v, index) => { |
| | | if (index < lastC.length - 1) { |
| | | return v * 255; |
| | | } else { |
| | | return v; |
| | | } |
| | | }) |
| | | ); |
| | | // 当两点距离超过500时,认为两点不连续,不绘制连线 |
| | | if (distance > 500) { |
| | | _path = path.slice(sIndex, i); |
| | | _color = getHexColor( |
| | | lastC.map((v, index) => { |
| | | if (index < lastC.length - 1) { |
| | | return v * 255; |
| | | } else { |
| | | return v; |
| | | } |
| | | }) |
| | | ); |
| | | sIndex = i; |
| | | } else { |
| | | _path = path.slice(sIndex, i + 1); |
| | | _color = getHexColor( |
| | | c.map((v, index) => { |
| | | if (index < c.length - 1) { |
| | | return v * 255; |
| | | } else { |
| | | return v; |
| | | } |
| | | }) |
| | | ); |
| | | sIndex = i - 1; |
| | | } |
| | | |
| | | // 创建折线实例 |
| | | const polyline = newPolyline(_path, _color); |
| | | _polylineArr.push(polyline); |
| | | |
| | | sIndex = i; |
| | | } |
| | | } |
| | | if (sIndex == 0) { |
| | | const c = colors[sIndex]; |
| | | if (sIndex < path.length - 1) { |
| | | const c = colors[path.length - 1]; |
| | | const _path = path.slice(sIndex, path.length); |
| | | const _color = getHexColor( |
| | | c.map((v, index) => { |
| | | if (index < c.length - 1) { |
| | |
| | | } |
| | | }) |
| | | ); |
| | | const polyline = newPolyline(path, _color); |
| | | const polyline = newPolyline(_path, _color); |
| | | _polylineArr.push(polyline); |
| | | } |
| | | // 将折线添加至地图实例 |