Моя цель проста, я хочу добавить маркеры направления на пути (как так).
Код, который я реализовал, дает результат при начальной нагрузке. < /p>
lineCoords.forEach(coords => {
for (let i = 1; i < coords.length; i++) {
const A = (coords);
const B = (coords);
const interpolateA = d3.interpolate(A[0], B[0]);
const interpolateB = d3.interpolate(A[1], B[1]);
const spacing = 3;
const distance = Math.hypot(A[0] - B[0], A[1] - B[1]);
const numPoints = Math.max(1, Math.floor(distance / spacing));
const range = d3.range(1, numPoints + 1);
const points = range.map(j => {
const t = j / (numPoints + 1);
const interpolatedA = interpolateA(t);
const interpolatedB = interpolateB(t);
return [interpolatedA, interpolatedB];
});
onewayCoords.push(points);
}
})
< /code>
Однако, когда я увеличиваю карту, маркеры образуют дугу вместо прямой.>
Подробнее здесь: https://stackoverflow.com/questions/795 ... d-of-a-str