mapbox / mapbox-maps-flutter

Interactive, thoroughly customizable maps for Flutter powered by Mapbox Maps SDK
https://www.mapbox.com/mobile-maps-sdk
Other
292 stars 120 forks source link

Unable to establish connection on channel: "dev.flutter.pigeon.mapbox_maps_flutter._PointAnnotationMessenger.createMulti #734

Open MarsTheMan opened 1 month ago

MarsTheMan commented 1 month ago

Hello. When await pointAnnotationManager?.createMulti(pointAnnotationList) is executed, I get the following error: PlatformException(channel-error, Unable to establish connection on channel: "dev.flutter.pigeon.mapbox_maps_flutter._PointAnnotationMessenger.createMulti"., null, null)

Future<void> generateCarPinMapBox() async {
    if (mapboxMapController == null || pointAnnotationManager == null) {
      // You may want to add some retry logic or error handling here in case it's null
      print("Mapbox controller or annotation manager is not ready yet.");
      return;
    }

    var pointAnnotationList = <mapbox.PointAnnotationOptions>[];
    for (var car in cars) {
      if (car.isAvailable! && !car.isRiding! && car.inversQNR == "ARISTEST") {
        continue;
      } else if (car.isAvailable! && !car.isRiding!) {
        final ByteData bytes = await rootBundle.load(Get.isDarkMode ? carooPinDark : carooPinLight);
        final Uint8List imageData = bytes.buffer.asUint8List();
        // pointAnnotationManager?.create(mapbox.PointAnnotationOptions(geometry: mapbox.Point(coordinates: mapbox.Position(car.latitude as num, car.longitude as num)), image: imageData, iconSize: 1.0,));
        final annotation =  mapbox.PointAnnotationOptions(geometry: mapbox.Point(coordinates: mapbox.Position(car.latitude as num, car.longitude as num)), image: imageData, iconSize: 3.0,);
        pointAnnotationList.add(annotation);
      }
    }
    await pointAnnotationManager?.createMulti(pointAnnotationList);
  }
evil159 commented 1 month ago

Hello @MarsTheMan,

Thank you for reaching out. I’m unable to reproduce the issue on my side. Could you please provide more details about your environment and setup? Specifically:

  1. The version of the Mapbox SDK you’re using.
  2. The platform (iOS/Android) where this issue occurs.
  3. Any specific steps or conditions to replicate the issue.
  4. If possible, a simplified piece of code that reproduces the problem.

This information would help us investigate further. Thank you!

bhavinmdesai commented 1 month ago

@evil159 I am also getting logs of a similar error on my crash reporting tool:

PlatformException(channel-error, Unable to establish connection on channel: "dev.flutter.pigeon.mapbox_maps_flutter._PointAnnotationMessenger.update"., null, null)

This happens when I am doing:

PointAnnotationManager.update(PointAnnotation);

Here are the answers to your questions:

  1. The version of the Mapbox SDK you’re using.

    • 2.2.0 (Flutter)
  2. The platform (iOS/Android) where this issue occurs.

    • Android
  3. Any specific steps or conditions to replicate the issue.

    • No. We can see it in on our crash reporting tool
bhavinmdesai commented 1 month ago

@evil159 We've also received similar crash reports on these methods as well:

MapboxMap.flyTo

PointAnnotationManager.setIconRotationAlignment
PointAnnotationManager.setIconAllowOverlap
PointAnnotationManager.create
MissingLinkDev commented 3 weeks ago

I have a similar issue with streaming data from firestore to use for the marker and polyline annotations. Code is a little long to include everything but will try and do a sudo code synopsis of what Im doing:

Map screen listens to a riverpod stream provider in the build method: ` ref.listen<AsyncValue<List>>(mapCrumbsProvider, (previous, next) async { next.when( data: (breadcrumbs) async { //Clear annotations and add in the new ones await timelineMapController.addBreadcrumbAnnotations( breadcrumbs, pointAnnotationManager!, );

        // Update polylines
        await timelineMapController.drawBreadcrumbPolylines(
          breadcrumbs,
          polylineAnnotationManager!,
        );
      }
    },
    loading: () {
      // Optionally handle loading state
      debugPrint('Breadcrumbs are loading...');
    },
    error: (error, stack) {
      // Optionally handle error state
      debugPrint('Error in mapCrumbsProvider: $error');
    },
  );
});

`

Here is my MapWidget

` mapbox.MapWidget( onMapCreated: (mapbox.MapboxMap mapboxMap) async { debugPrint('Map created!'); // assign controller to widget // Assign controller to widget mapController = mapboxMap;

                  // Configure map settings
                  mapController?.location.updateSettings(
                    mapbox.LocationComponentSettings(
                      enabled: true,
                    ),
                  );
                  mapController?.compass.updateSettings(
                    mapbox.CompassSettings(
                      enabled: false,
                    ),
                  );
                  mapController?.scaleBar.updateSettings(
                    mapbox.ScaleBarSettings(
                      enabled: false,
                    ),
                  );
                  mapController?.gestures.updateSettings(
                    mapbox.GesturesSettings(
                      rotateEnabled: false,
                    ),
                  );

                  // Initialize Annotation Managers once
                  pointAnnotationManager ??= await mapController!
                      .annotations
                      .createPointAnnotationManager();
                  polylineAnnotationManager ??= await mapController!
                      .annotations
                      .createPolylineAnnotationManager();
                  activityPointAnnotationManager ??= await mapController!
                      .annotations
                      .createPointAnnotationManager();
                  activityPolylineAnnotationManager ??= await mapController!
                      .annotations
                      .createPolylineAnnotationManager();

                  // Add Breadcrumb Annotations
                  timelineMapController.addBreadcrumbAnnotations(
                    breadcrumbs,
                    pointAnnotationManager!,
                  );

                  // Draw Polylines
                  timelineMapController.drawBreadcrumbPolylines(
                    breadcrumbs,
                    polylineAnnotationManager!,
                  );

                  // Listen to annotation taps
                  pointAnnotationManager!.addOnPointAnnotationClickListener(
                    BreadcrumbPointAnnotationClickListener(
                      timelineMapController.annotationToBreadcrumbMap,
                      (Breadcrumb crumb) {
                        timelineMapController.setBreadcrumb(crumb);
                      },
                    ),
                  );

                  // Initialize map location after setting up the map
                  timelineMapController.initializeMapLocation(
                    breadcrumbs,
                    mapController!,
                    currentLocationAsync.value,
                  );
                },
              ),

`

The annotation managers are state variables. Ive tried so many things and really just looking for a workaround at this point

GabrielSamojlo commented 1 week ago

hey @evil159 , any updates on this?