You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Missing option to disable onSymbolTapped event to get propagated to onMapClick event #348
I have a use case where I need to detect whether the map - but not a symbol - was clicked. As the onSymbolTapped event also propagates the event to the underlying map layer, the onMapClick event is also called when a symbol is clicked. I want this behaviour:
when I click on the map layer, then my onMapClick callback is called
when I click on a custom symbol, then only my custom onSymbolTapped callback is called
Is there a way to achieve this with the existing release?
Reacted by Alexander Makarov, Foti Dim and Philip Lindberg
@nheumann Not with the current release, unfortunately, but this has been fixed upstream (mapbox/mapbox-plugins-android#1124) and when that fix is released in the Mapbox Annotation plugin, we'll update our dependency and fix this.
@andrea689 Do you know how we could solve this for web? I've tried adding a stopPropagation() method to the Event, EventJsImpl, MapMouseEvent and MapMouseEventJsImpl classes in mapbox_gl_dart and calling that in mapbox_gl_web FeatureManager's click handler. That works (onMapClick is not fired anymore) but I'm also getting a TypeError: this.jsObject.stopPropagation is not a function in the debug console every time I click a symbol.
I went around this problem like this. Clicking on the symbol first fires onSymbolTapped and then onMapClick. After clicking the symbol, I immediately set a variable whose default is false to true. I set it to false after 100 milliseconds. I would ignore onMapClick if this value is true.
@nheumann Not with the current release, unfortunately, but this has been fixed upstream (mapbox/mapbox-plugins-android#1124) and when that fix is released in the Mapbox Annotation plugin, we'll update our dependency and fix this.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Activity
m0nac0 commentedon Jul 2, 2020
@nheumann Not with the current release, unfortunately, but this has been fixed upstream (mapbox/mapbox-plugins-android#1124) and when that fix is released in the Mapbox Annotation plugin, we'll update our dependency and fix this.
n-hauschild commentedon Jul 2, 2020
@m0nac0 Thank you for your quick reply. How about web and iOS?
m0nac0 commentedon Jul 2, 2020
@nheumann You're welcome. This bug has only been reported for Android so far, are you also experiencing this on web and iOS?
n-hauschild commentedon Jul 2, 2020
@m0nac0 I tested this in the sample app and it occurs for Android and also web. iOS works as expected.
m0nac0 commentedon Jul 2, 2020
@nheumann Thanks for testing it, we'll have to look into that as well then.
m0nac0 commentedon Jul 2, 2020
@andrea689 Do you know how we could solve this for web? I've tried adding a stopPropagation() method to the
Event,EventJsImpl,MapMouseEventandMapMouseEventJsImplclasses in mapbox_gl_dart and calling that in mapbox_gl_webFeatureManager's click handler. That works (onMapClick is not fired anymore) but I'm also getting aTypeError: this.jsObject.stopPropagation is not a functionin the debug console every time I click a symbol.GULERTOLGA commentedon Jul 2, 2020
I went around this problem like this. Clicking on the symbol first fires onSymbolTapped and then onMapClick. After clicking the symbol, I immediately set a variable whose default is false to true. I set it to false after 100 milliseconds. I would ignore onMapClick if this value is true.
Ph0tonic commentedon Aug 14, 2020
The fix has been released upstream 👍
m0nac0 commentedon Aug 14, 2020
@Ph0tonic Thank you for fixing it! I actually (and coincidentally 😄 ) just now finished testing and opened the PR .
fotiDim commentedon Sep 17, 2020
The issue is resolved on Android but still appears on web.
stale commentedon Jan 14, 2022
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.