Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing option to disable onSymbolTapped event to get propagated to onMapClick event #348

Closed
nheumann opened this issue Jul 2, 2020 · 11 comments
Labels
bug Something isn't working stale web

Comments

@nheumann
Copy link

nheumann commented Jul 2, 2020

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?

@m0nac0
Copy link
Collaborator

m0nac0 commented 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.

@nheumann
Copy link
Author

nheumann commented Jul 2, 2020

@m0nac0 Thank you for your quick reply. How about web and iOS?

@m0nac0
Copy link
Collaborator

m0nac0 commented 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?

@nheumann
Copy link
Author

nheumann commented Jul 2, 2020

@m0nac0 I tested this in the sample app and it occurs for Android and also web. iOS works as expected.

@m0nac0 m0nac0 added android bug Something isn't working web labels Jul 2, 2020
@m0nac0
Copy link
Collaborator

m0nac0 commented Jul 2, 2020

@nheumann Thanks for testing it, we'll have to look into that as well then.

@m0nac0
Copy link
Collaborator

m0nac0 commented 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, 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.

@GULERTOLGA
Copy link
Contributor

GULERTOLGA commented 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
Copy link

Ph0tonic commented Aug 14, 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.

The fix has been released upstream 👍

@m0nac0
Copy link
Collaborator

m0nac0 commented Aug 14, 2020

@Ph0tonic Thank you for fixing it! I actually (and coincidentally 😄 ) just now finished testing and opened the PR .

@fotiDim
Copy link

fotiDim commented Sep 17, 2020

The issue is resolved on Android but still appears on web.

@m0nac0 m0nac0 removed the android label Feb 20, 2021
@stale
Copy link

stale bot commented 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.

@stale stale bot added the stale label Jan 14, 2022
@stale stale bot closed this as completed Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale web
Projects
None yet
Development

No branches or pull requests

5 participants