add marker red

This commit is contained in:
2025-09-04 18:11:12 +02:00
parent 9989aebc32
commit 86f81ff009

View File

@@ -231,14 +231,12 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
iconSize: 0.4, iconSize: 0.4,
)); ));
// Add event marker // Ajoute directement la flèche rouge à la position de lévénement
final eventIcon = await _loadMarkerImage('images/marker-red.png'); final eventIcon = await _loadMarkerImage('images/marker-red.png');
await pointAnnotationManager!.create(mapbox.PointAnnotationOptions( await pointAnnotationManager!.create(mapbox.PointAnnotationOptions(
geometry: mapbox.Point( geometry: mapbox.Point(coordinates: mapbox.Position(longitude, latitude)),
coordinates: mapbox.Position(
destination.coordinates.lng, destination.coordinates.lat)),
image: eventIcon, image: eventIcon,
iconSize: 0.4, iconSize: 0.2,
)); ));
// Fetch and draw route // Fetch and draw route
@@ -296,8 +294,23 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
), ),
Expanded( Expanded(
child: mapbox.MapWidget( child: mapbox.MapWidget(
onMapCreated: (controller) { onMapCreated: (controller) async {
mapboxMap = controller; mapboxMap = controller;
// Crée un manager si nécessaire
pointAnnotationManager ??= await mapboxMap!.annotations
.createPointAnnotationManager();
// Ajoute directement la flèche rouge à la position de lévénement
final eventIcon =
await _loadMarkerImage('images/marker-red.png');
await pointAnnotationManager!
.create(mapbox.PointAnnotationOptions(
geometry: mapbox.Point(
coordinates: mapbox.Position(longitude, latitude)),
image: eventIcon,
iconSize: 0.2,
));
}, },
cameraOptions: mapbox.CameraOptions( cameraOptions: mapbox.CameraOptions(
center: mapbox.Point( center: mapbox.Point(