Update: 2026-07-10 03:04:06
This commit is contained in:
@@ -407,8 +407,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));
|
||||
@@ -715,9 +718,12 @@ class NavigationController extends GetxController
|
||||
}
|
||||
|
||||
Future<void> _updateCarMarker() async {
|
||||
if (myLocation == null || !isStyleLoaded) return;
|
||||
markers.removeWhere((m) => m.markerId.value == 'car');
|
||||
markers.add(Marker(
|
||||
if (myLocation == null || !isStyleLoaded || mapController == null) return;
|
||||
// The car puck moves on every GPS/animation tick. Driving it through the
|
||||
// declarative `markers` set means mutating the same Set in place, which the
|
||||
// map widget's diff can't see (old == new reference) — so the puck would
|
||||
// freeze or never appear. Update it imperatively as a single native symbol.
|
||||
await mapController!.setUserMarker(Marker(
|
||||
markerId: const MarkerId('car'),
|
||||
position: myLocation!,
|
||||
icon: InlqBitmap.fromStyleImage('car_icon'),
|
||||
@@ -1113,8 +1119,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'),
|
||||
|
||||
Reference in New Issue
Block a user