From 7182e0e3244a45b2de3246cc3454a0c1c84e3125 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Fri, 15 Nov 2024 22:48:05 +0100 Subject: [PATCH] fix add marker style --- covas_mobile/lib/pages/MapboxPages.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/covas_mobile/lib/pages/MapboxPages.dart b/covas_mobile/lib/pages/MapboxPages.dart index bfa8049..edb56dc 100644 --- a/covas_mobile/lib/pages/MapboxPages.dart +++ b/covas_mobile/lib/pages/MapboxPages.dart @@ -42,7 +42,7 @@ class Mapboxpages extends StatefulWidget { class _MapboxpagesState extends State with ShowErrorDialog { late String mapboxAccessToken; - MapboxMapController? mapController; // Mark mapController as nullable + late MapboxMapController mapController; // Mark mapController as nullable double longitude = 0.0; double latitude = 0.0; bool isLoading = true; @@ -100,10 +100,12 @@ class _MapboxpagesState extends State with ShowErrorDialog { return data.buffer.asUint8List(); } - // Called when the map is created - void _onMapCreated(MapboxMapController controller) async { + void _onMapCreated(MapboxMapController controller) { mapController = controller; + } + // Called when the map is created + void _onStyleLoaded() async { // Log the map controller and coordinates print("Mapbox controller initialized: $mapController"); print("lat - long : $latitude - $longitude"); @@ -152,6 +154,7 @@ class _MapboxpagesState extends State with ShowErrorDialog { : MapboxMap( accessToken: mapboxAccessToken, // Your Mapbox API key onMapCreated: _onMapCreated, + onStyleLoadedCallback: _onStyleLoaded, initialCameraPosition: CameraPosition( target: LatLng(latitude, longitude), zoom: 14.0,