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

PointAnnotationManager.update() breaks click handlers on updated annotations

Open samstamper33 opened this issue 3 months ago • 15 comments

After calling PointAnnotationManager.update() on a PointAnnotation, that specific annotation loses its ability to receive click events through the registered click listener. The annotation remains visually present on the map but becomes unresponsive to user taps.

Environment:

Flutter version: 3.32.7 mapbox_maps_flutter version: 2.10.0 Platform: iOS Minimum reproduction: Any app using PointAnnotations with click listeners

Steps to Reproduce:

Create a PointAnnotation and add it to a PointAnnotationManager Register a click listener using addOnPointAnnotationClickListener() Click the annotation - it responds correctly Call mapPointAnnotationManager.update(annotation) with modified properties (e.g., iconSize, iconImage) Attempt to click the same annotation again

Expected Behavior:

The annotation should remain clickable after being updated.

Actual Behavior:

The annotation becomes unresponsive to click events. The click listener is no longer triggered for that specific annotation. Code Sample:

dart// This works the first time
annotation.iconImage = "selected_icon";
annotation.iconSize = 0.5;

// After this call, the annotation loses click responsiveness
await mapPointAnnotationManager?.update(annotation);

// Subsequent clicks on this annotation are ignored

Additional Context:

Other annotations remain clickable The issue persists across both deprecated OnPointAnnotationClickListener and newer tapEvents APIs Visual updates are applied correctly - only click handling is affected Tested on multiple devices with consistent reproduction

I recently updated from 0.4.4, so very likely user error, but I've been messing around with this for a few hours without success now. Removing the .update() function has it working correctly but without updating the size or icon

samstamper33 avatar Sep 15 '25 03:09 samstamper33

I seem to see the same on iOS (can no longer click on my annotations), Flutter 3.35.3, mmf: 2.10.0

I've tried both the deprecated addOnPointAnnotationClickListener and the new .tapEvents (onTap)

albright999 avatar Sep 17 '25 21:09 albright999

same problem。Flutter 3.32.7 mapbox_maps_flutter: ^2.11.0

buxiaojiong avatar Sep 19 '25 02:09 buxiaojiong

Same here:

[✓] Flutter (Channel stable, 3.35.3, on macOS 15.6.1 24G90 darwin-arm64, locale fr-FR)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.4)
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.97.1)

wavs avatar Sep 22 '25 13:09 wavs

Facing the same issue on iOS, using PointAnnotationManager.tapEvents(onTap). Mapbox 2.10, Flutter 3.29.1, Dart SDK version: 3.7.0.

On Android this issue does not exist. I have tried re-assigning the tap event listening before and after each update annotation call and that did not resolve it either. Annotations on map remain unclickable, unless I delete and add again then it is clickable.

george536 avatar Oct 05 '25 20:10 george536

Hello @evil159 Do you have any information regarding this, thank you very much

george536 avatar Oct 15 '25 23:10 george536

Facing the same issue after switching to the latest version mapbox_maps_flutter: ^2.11.0.

manukumarsb7 avatar Oct 20 '25 19:10 manukumarsb7

Hello @maios, do you know which version would include a fix for this bug? Thank you

george536 avatar Oct 31 '25 02:10 george536

I'm facing the same issue as well

arvindshastri avatar Nov 05 '25 03:11 arvindshastri

Same Issue, seems like the new 'Tap Annotation' functionality does not work compared to the 'deprecated' AnnotationOnClickListener unfortunately this commit removed the ability to access the old working version before any testing was done on this updated api!

https://github.com/mapbox/mapbox-maps-flutter/commit/bc592b1eacf678d1bc59a83eabbe74618881e23c

xortuna avatar Nov 09 '25 22:11 xortuna

I switched back to the previous version mapbox_maps_flutter: ^2.7.0, and everything is working fine now. I’ll upgrade to the latest version once these issues are addressed and fixed.

manukumarsb7 avatar Nov 09 '25 22:11 manukumarsb7

Hello @maios and @evil159 , while still waiting on a resolution for this, I looked through the comment @xortuna left in which he linked a commit, and I see a difference between the implementation of AnnotationController class in Android and iOS, for Android, the tapEvents is registered twice, while the dragEvents is not, however, in iOS that seems to be correct. Could this be related?

in Android: AnnotationInteractionEventsStreamHandler.register(messenger, tapEvents, "$channelName/tap") AnnotationInteractionEventsStreamHandler.register(messenger, tapEvents, "$channelName/drag") AnnotationInteractionEventsStreamHandler.register(messenger, longPressEvents, "$channelName/long_press")

in iOS: AnnotationInteractionEventsStreamHandler.register( with: binaryMessenger.messenger, instanceName: binaryMessenger.suffix + "/" + id + "/tap", streamHandler: tapStream) AnnotationInteractionEventsStreamHandler.register( with: binaryMessenger.messenger, instanceName: binaryMessenger.suffix + "/" + id + "/drag", streamHandler: dragStream) AnnotationInteractionEventsStreamHandler.register( with: binaryMessenger.messenger, instanceName: binaryMessenger.suffix + "/" + id + "/long_press", streamHandler: longPressStream)

Thank you, hoping to get more info on the above bug soon.

george536 avatar Nov 10 '25 22:11 george536

Hi all, thank you for the detailed reports and triaging, sorry for the delay, https://github.com/mapbox/mapbox-maps-flutter/pull/1063 should address this

evil159 avatar Nov 11 '25 11:11 evil159

Hi all, thank you for the detailed reports and triaging, sorry for the delay, #1063 should address this

@evil159 Thank you very much. Would you know which version will include this fix? will it be soon? thanks again

george536 avatar Nov 18 '25 03:11 george536

@george536 The fix is a part of 2.17.0-rc.1 that is scheduled to be released tomorrow, the stable version is scheduled two weeks after.

evil159 avatar Nov 18 '25 03:11 evil159

Just tried 2.17.0-rc.1 and it does not seem to be resolved for me? Has anyone else been able to test?

xortuna avatar Nov 23 '25 19:11 xortuna

Just tested the official 2.17 release and annotation taps are still not working for me

xortuna avatar Dec 09 '25 08:12 xortuna

Apologies, I can confirm the issue is resolved, and it was a bug on my end. The behaviour of the annotation call back has changed slightly if you have multiple annotation managers now.

Previously if you hooked a tap event to an annotation manager you'd get events for all annotation managers regardless:

var manager1 = await _mapController?.annotations.createPointAnnotationManager(id: 'manager1');
var manager2= await _mapController?.annotations.createPointAnnotationManager(id: 'manager2');
manager1?.tapEvents(onTap: _onPointAnnotationClicked); // this callback got 1 and 2

Now the API is fixed, it each manager only raises events for the annotations it owns, so you now need to subscribe to each manager individually:

var manager1 = await _mapController?.annotations.createPointAnnotationManager(id: 'manager1');
var manager2= await _mapController?.annotations.createPointAnnotationManager(id: 'manager2');
manager1?.tapEvents(onTap: _onPointAnnotationClicked); // this callback gets 1 
manager2?.tapEvents(onTap: _onPointAnnotationClicked);  // this callback gets 2

I was testing the fix with annotations in created in manager 2 - doh

xortuna avatar Dec 15 '25 21:12 xortuna