mapbox-maps-flutter icon indicating copy to clipboard operation
mapbox-maps-flutter copied to clipboard

Rendering Widgets on annotation click repeats on ios

Open maxiggle opened this issue 1 year ago • 2 comments

When I tap an annotation, I expect a bottomsheet to show some details about the annotation clicked. It works fine on android but triggers multiple bottomsheet in ios emulator.

See my code:

class AnnotationClickListener extends OnPointAnnotationClickListener {
  final BuildContext context;
  final List<AirPorts> places;
  final MapboxMap? mapboxMap;

  AnnotationClickListener(this.context, this.places, this.mapboxMap);

  @override
  void onPointAnnotationClick(PointAnnotation annotation) {
    handleAnnotationClick(annotation);
  }

  void handleAnnotationClick(PointAnnotation annotation) {
    String? src;
    String? state;
    Country? country;
    if (annotation.id.isNotEmpty && annotation.geometry != null) {
      final coordinates = annotation.geometry!['coordinates'] as List<dynamic>?;
      if (coordinates != null && coordinates.length >= 2) {
        final double latitude = (coordinates.elementAt(1) as double?) ?? 0.0;
        final double longitude = (coordinates.elementAt(0) as double?) ?? 0.0;

        // Fly to the clicked annotation's coordinates
        mapboxMap?.flyTo(
          CameraOptions(
            zoom: 12.0,
            center: Point(
              coordinates: Position(longitude, latitude),
            ).toJson(),
          ),
          MapAnimationOptions(),
        );

        for (var place in places) {
          if (place.lon == longitude.toString() &&
              place.lat == latitude.toString()) {
            src = place.thumbImage!;
            state = place.state!;
            country = place.country!;
          }
        }

        print('this');

        showModalBottomSheet(
            context: context,
            builder: (BuildContext context) {
              return DiscoverMarkerPopup(
                country: country!,
                src: src!,
                state: state!,
              );
            });
      }
    } else {
      debugPrint('Annotation is null or represents URL images.');
    }
  }
}

maxiggle avatar Feb 26 '24 12:02 maxiggle

maxiggle Is it possible that this has the same root as this issue?

dko-orion avatar Feb 29 '24 12:02 dko-orion

@dko-orion no I don't think so. I do not have issues with the maplistner being triggered. The annotation when clicked on ios just triggers multiple bottomsheet

maxiggle avatar Feb 29 '24 13:02 maxiggle