mapbox / mapbox/mapbox-maps-flutter
Rendering Widgets on annotation click repeats on ios
Open
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 380
- Forks
- 204
- PR merge metrics
- No merged PRs in 30d
Description
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.');
}
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided AnnotationClickListener on the iOS emulator and compare its callback behavior with Android. Verify whether one annotation tap invokes the listener more than once, and consider the issue done when each tap produces exactly one bottom sheet without changing the Android behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter, ios
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100