Update: 2026-07-10 03:04:06

This commit is contained in:
Hamza-Ayed
2026-07-10 03:04:06 +03:00
parent 2ff7450d0b
commit b18fd027b6
22 changed files with 2661 additions and 96 deletions
@@ -381,8 +381,11 @@ class NavigationController extends GetxController
Future<void> onStyleLoaded() async {
Log.print("DEBUG: NavigationController.onStyleLoaded called");
isStyleLoaded = true;
// Register the custom icons (car/start/dest) BEFORE marking the style as
// ready. Otherwise a location tick can fire _updateCarMarker() in the gap
// and reference 'car_icon' before it exists in the style → blank marker.
await _loadCustomIcons();
isStyleLoaded = true;
WidgetsBinding.instance.addPostFrameCallback((_) async {
await Future.delayed(const Duration(milliseconds: 300));
@@ -490,8 +493,7 @@ class NavigationController extends GetxController
_isProcessing = true;
try {
currentSpeed =
locSpeed; // Convert m/s to km/h already done by location controller if needed, wait location_controller sends raw speed or km/h? It sends raw speed. So we should * 3.6
// LocationController forwards raw speed in m/s; convert to km/h.
currentSpeed = locSpeed * 3.6;
// Skip if movement is too small
@@ -674,7 +676,21 @@ class NavigationController extends GetxController
}
Future<void> _updateCarMarker() async {
// Car marker is now handled natively by myLocationEnabled: true.
if (myLocation == null || !isStyleLoaded || mapController == null) return;
// Draw the driver's car as a single imperatively-managed puck. It moves on
// every location tick, so it must NOT live in the declarative `markers` set
// (in-place mutation of that Set is invisible to the map widget's diff and
// makes the car freeze or never render). setUserMarker updates one native
// symbol in place instead.
await mapController!.setUserMarker(Marker(
markerId: const MarkerId('car'),
position: myLocation!,
icon: InlqBitmap.fromStyleImage('car_icon'),
anchor: const Offset(0.5, 0.5),
flat: true,
rotation: _smoothedHeading,
zIndex: 100,
));
}
void animateCameraToPosition(LatLng position,
@@ -1053,8 +1069,9 @@ class NavigationController extends GetxController
_finalDestination = destination;
await clearRoute(isNewRoute: true);
// Preserve car marker if it exists
markers = markers.where((m) => m.markerId.value == 'car').toSet();
// The car puck is managed imperatively (setUserMarker), not via this set,
// so start from a clean declarative set holding only origin/destination.
markers = <Marker>{};
markers.add(Marker(
markerId: const MarkerId('destination'),