Я анимирую маркер вдоль маршрута с путевыми точками и пытаюсь определить, когда маркер достигает/пересекает путевую точку.
Мне удалось получить анимационную часть, но, похоже, не удалось обнаружить
вот мой код
Я создаю маршрут
p = data.map(function(o){ return o.steps.map(function(g) { return g.geometry.coordinates }) });
const locations = p.reduce(function(arr, val){
arr = arr.concat(val); return arr ;
}, [] ),
route = new MultiLineString(locations);
Я получаю путевые точки
intersections = data.reduce(function(s,c){ s=(!s?[]:s); return s = s.concat(c.steps.reduce(
function(e,a){
e = (!e? [] : e);
e.push(a.maneuver.location);
return e; },[])); return s;
},[]),
Я создаю экстент из путевой точки по "щелчку правой стрелки"
waypoint = fromLonLat(intersections[0])
.concat(fromLonLat(intersections[1]));
Затем, пытаясь определить, когда маркер анимируется, пройдите через путевую точку
function moveFeature(event) {
const speed = 60;
const time = event.frameState.time;
const elapsedTime = time - lastTime;
distance = (distance + (speed * elapsedTime) / 1e6) % 2;
lastTime = time;
const currentCoordinate = route.getLineString(distance).getCoordinateAt(distance);
if(isNaN(currentCoordinate[0]) || (distance > 1) || Extent.containsCoordinate(waypoint, currentCoordinate) ) return stopAnimation();
position.setCoordinates(currentCoordinate);
const vectorContext = getVectorContext(event);
vectorContext.setStyle(styles.geoMarker);
vectorContext.drawGeometry(position);
map.getView().setCenter(currentCoordinate);
map.render();
}
Но это не похоже на правду. Есть ли другой способ определить, когда маркер проходит определенную точку/радиус?