Let me rewrite the file completely:
Now update the CSS for the plane marker:
Now let's update MapView to show the plane animation when a route is activated: I'll add a new layer for planes and trigger animations when routes are toggled on/off. Since the user wants the animation to start when the route is enabled (from the sidebar), we need to expose a way to trigger it from the App level. The simplest way is to store the current animations in App state and pass a callback to Sidebar that triggers the animation when a route is toggled.
Let me update MapView to add the plane layer and handle animations:
Let me read the current MapView to see the exact structure:
Now let me add the props to MapView for triggering animations, and add the animation effect:
Let me take a different approach. Instead of passing callbacks back and forth, I'll make the animation trigger directly in MapView when it detects that a route has been toggled on. I'll add a new effect that watches for active routes and launches animations. But first, let me simplify and just add the animation to the existing route drawing logic.
Actually, the simplest approach: when a user toggles a route ON in the Sidebar, we'll trigger the animation from App.tsx by calling a new function. Let me:
- Add the animation trigger to App.tsx
- Pass it to MapView
- In MapView, when the animation is triggered, play it
But actually, the cleanest is to have MapView manage its own animations based on the points state and their activeRoutes. Let me do that:
Let me remove the unused prop and the unused ref:
Let me take a completely different approach. Instead of trying to manage complex state, I'll make it simple:
- When the user toggles a route ON in the Sidebar, we'll trigger an animation callback
- The animation will be handled in App.tsx and passed to MapView
- MapView will receive the animation requests and play them
Let me rewrite the whole flow cleanly. First, let me remove the unused imports and refs from MapView:
Отлично! Сборка прошла успешно. Теперь при включении маршрута от точки фиксации до Альметьевска или Нижнекамска на карте будет лететь самолёт по линии маршрута.
✅ Что реализовано — Анимация полёта
✈️ Анимация самолёта
- При включении маршрута (кнопка в карточке точки → Альметьевск / Нижнекамск) на карте автоматически запускается самолёт
- Самолёт летит по линии маршрута от точки фиксации до конечной точки
- Скорость анимации соответствует реальной скорости полёта (из поля «Скорость, км/ч» в карточке точки)
- Время полёта рассчитывается по формуле: дистанция / скорость
- Самолёт ориентирован по направлению полёта (поворачивается по азимуту)
🔄 Зацикленная анимация
- После достижения конечной точки самолёт возвращается обратно к точке фиксации
- Затем снова летит к конечной точке — бесконечный цикл
- Анимация работает одновременно для всех активных маршрутов
🎨 Визуальное оформление
- Иконка самолёта — стилизованный самолёт (SVG)
- Цвет самолёта совпадает с цветом маршрута до города:
- Альметьевск — зелёный самолёт 🟢
- Нижнекамск — синий самолёт 🔵
- Самолёт летит над линией маршрута, не мешая работе с картой
📊 Информация в подсказке
При наведении на линию маршрута или на самолёт показывается:
- Название маршрута (точка → город)
- Время фиксации (если указано)
- Комментарий
- Скорость
- Дистанция
- Время прилёта (рассчитанное)
🎯 Как использовать
- Добавьте точку фиксации на карту
- В карточке точки включите маршрут до Альметьевска и/или Нижнекамска
- Самолёт автоматически взлетит и полетит по маршруту
- Чтобы остановить анимацию — отключите маршрут (кликните по кнопке маршрута в карточке точки)
Запуск: npm run build → node server.js → http://localhost:3000
Files built: src/lib/flightAnimation.ts, src/index.css, src/components/MapView.tsx, src/App.tsx