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 }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
The concept of a tap/click input event and the default response to that event (select the marker and show info window) seem conflated in the current implementation. This causes problems when the input events are important, but the "selection" state is not.
The most critical problem is that a tap/click on a marker always moves the marker into the "selected" state (regardless of the MarkerClick event handler's return value), and once in this state, additional tap/click input no longer raises the MarkerClick event. When selection state is not important/visible to the user, it is not obvious to them how to fix this. In addition, there is no easy way at the code level to prevent it from happening.
Some specifics contributing to the confusion:
A tap/click on an unselected marker always moves it to the "selected" state, even if mOnMarkerClickListener.onMarkerClick returns false, indicating the input event was "handled".
A tap/click on a selected marker does not raise the MarkerClick event, even though the associated input event clearly occurred.
Calling selectMarker raises the MarkerClick event, even though the method name doesn't say anything about simulating a particular input event, and the event name suggests a particular input event occurred (which it did not).
The default visual indicator of a marker's selection state is the presence or absence of an info window. However, this is not reliable because an info window may not be defined, it may be prevented from appearing due to the MarkerClick event returning false, and it may be shown and hidden independently by calling methods on the Marker object directly, none of which have any effect on the marker's selection state.
Unfortunately, because the current implementation is so confusing, one cannot be sure exactly how the code is currently being used, and therefore almost any fix could be considered a breaking change for some scenarios.
In the long term, though:
MapView.onSingleTapConfirmed should raise the MarkerClick event any time the input event occurs, regardless of the marker's selection state.
If the MarkerClick event handler returns false, the entire default response to that input, including any selection state change, should be skipped.
A new MarkerSelectionChanged event should be introduced to allow input events and selection state changes to be handled separately.
MapView.selectMarker should raise the new MarkerSelectionChanged event, and should not raise MarkerClick.
@bmeyers43
Thank you for reaching out and giving us such detailed feedback. The subject here is something that we are improving/documenting in #553. I'm going to close this one down in favour of that one. I linked this issue so we can pickup this up.
That's a pretty massive work item ("One does not simply imitate Google's robust gesture system!") and it sounds like it's entirely about gesture recognition, not about the API for handling gestures after they have been recognized. My issue is just about fixing the API for handling simple tap/click events and changes to marker selection state. You may want to follow a similar pattern when exposing other gesture events, but I really don't want to wait for you to reimplement your whole gesture recognition system before I can get a reliable marker click event!
Could you please consider fixing this separately (and sooner)?
--Bob
From: Tobrunmailto:[email protected]
Sent: 1/19/2016 4:39 AM
To: mapbox/mapbox-gl-nativemailto:[email protected]
Cc: bmeyers43mailto:[email protected]
Subject: Re: [mapbox-gl-native] MarkerClick event is only raised once (#3176)
@bmeyers43
Thank you for reaching out and giving us such detailed feedback. The subject here is something that we are improving/documenting in #553. I'm going to close this one down in favour of that one. I linked this issue so we can pickup this up.
Reply to this email directly or view it on GitHub: #3176 (comment)
@bmeyers43
You are right about that being about recognition vs selection state. Reopening and putting this issue on my priority list. Thank again for writing up this issue. This type of feedback is very valuable!
I'm seeing 2 actionable things here:
The general one is that onMarkerClick callback invocation is not correctly positioned.
Instead of in selectMarker it should be moved to onSingleTapConfirmed (now tapping a selected marker also results in a callback + solves is this method name/event appropriate problem).
The second one is introduce a new callback system around MarkerSelectionChanged
I'm not 💯 on the second one though, is this API you would use or ideally want? Google Maps SDK is currently not exposing this. I have no problem adding it but I would like to support this with a use-case that isn't solvable with a correctly working onMarkerClick integration.
The biggest issue currently is that no event is raised in response to a tap once the marker is selected. This issue could be resolved by either (or preferably both) of the following changes:
Call onMarkerClick in onSingleTapConfirmed so it gets raised regardless of selection state.
Don't call selectMarker if onMarkerClick returns false (indicating the event was handled).
In addition, I think you should consider adding an onMarkerSelectionChanged callback, but this is up to you. If someone is allowing the default behavior of click -> select, then they can probably use the onMarkerClick callback as a proxy in most cases. However it is common in general for controls that maintain selection state for a list of subitems to expose events around changes to the selection state. These callbacks would be invoked both in response to user input (e.g. a tap/click) and programmatic changes to selection state. If Google Maps doesn't expose anything like this and no one else is clamoring for it, I understand if it's not a high priority anytime soon. I myself don't need it at the moment either.
Would pop the toast every time. Notice I returned 'true' there. That's the cue to say that I've handled this event myself and I don't want default behaviour. Thing is, the default behaviour is still happening (though not showing the info window) and so the second tap doesn't pop a toast, only every second tap pops a toast.
@SilkSama hack is working.
Problem here is that the OnMarkerClickListener does not represent the task that it is doing.
At the moment OnMarkerClickListener should be called OnMarkerSelectedListener.
I focussed on resolving the business logic issues as set out in the OP:
MapView.onSingleTapConfirmed should raise the MarkerClick event any time the input event occurs, regardless of the marker's selection state.
If the MarkerClick event handler returns false true, the entire default response to that input, including any selection state change, should be skipped.
Related to the other items mentioned in the OP as OnMarkerSelectionChangeListener. I'm thinking of PR'ing current progress and handling that as a separate feature request.
@SilkSama Why do I need to use the "Handler().postDelayed(() -> mMapboxMap.deselectMarker(marker), 100);" rather than the “mMapboxMap.deselectMarker(marker)”? I know the latter is no effect, but I would like to know the reason.
Thank you very much!
@jwen1989 the workaround is no longer applicable, you should be able to get it your use-case working without it. Feel free to add more information or create a separate ticket.
Activity
tobrun commentedon Jan 19, 2016
@bmeyers43
Thank you for reaching out and giving us such detailed feedback. The subject here is something that we are improving/documenting in #553. I'm going to close this one down in favour of that one. I linked this issue so we can pickup this up.
bobmeyers5 commentedon Jan 19, 2016
That's a pretty massive work item ("One does not simply imitate Google's robust gesture system!") and it sounds like it's entirely about gesture recognition, not about the API for handling gestures after they have been recognized. My issue is just about fixing the API for handling simple tap/click events and changes to marker selection state. You may want to follow a similar pattern when exposing other gesture events, but I really don't want to wait for you to reimplement your whole gesture recognition system before I can get a reliable marker click event!
Could you please consider fixing this separately (and sooner)?
--Bob
From: Tobrunmailto:[email protected]
Sent: 1/19/2016 4:39 AM
To: mapbox/mapbox-gl-nativemailto:[email protected]
Cc: bmeyers43mailto:[email protected]
Subject: Re: [mapbox-gl-native] MarkerClick event is only raised once (#3176)
@bmeyers43
Thank you for reaching out and giving us such detailed feedback. The subject here is something that we are improving/documenting in #553. I'm going to close this one down in favour of that one. I linked this issue so we can pickup this up.
Reply to this email directly or view it on GitHub:
#3176 (comment)
tobrun commentedon Jan 20, 2016
@bmeyers43
You are right about that being about recognition vs selection state. Reopening and putting this issue on my priority list. Thank again for writing up this issue. This type of feedback is very valuable!
I'm seeing 2 actionable things here:
onMarkerClickcallback invocation is not correctly positioned.Instead of in
selectMarkerit should be moved toonSingleTapConfirmed(now tapping a selected marker also results in a callback + solves is this method name/event appropriate problem).MarkerSelectionChangedI'm not 💯 on the second one though, is this API you would use or ideally want? Google Maps SDK is currently not exposing this. I have no problem adding it but I would like to support this with a use-case that isn't solvable with a correctly working onMarkerClick integration.
bobmeyers5 commentedon Jan 20, 2016
The biggest issue currently is that no event is raised in response to a tap once the marker is selected. This issue could be resolved by either (or preferably both) of the following changes:
In addition, I think you should consider adding an onMarkerSelectionChanged callback, but this is up to you. If someone is allowing the default behavior of click -> select, then they can probably use the onMarkerClick callback as a proxy in most cases. However it is common in general for controls that maintain selection state for a list of subitems to expose events around changes to the selection state. These callbacks would be invoked both in response to user input (e.g. a tap/click) and programmatic changes to selection state. If Google Maps doesn't expose anything like this and no one else is clamoring for it, I understand if it's not a high priority anytime soon. I myself don't need it at the moment either.
9 remaining items
nealsanche commentedon May 11, 2016
I'd be completely happy with the current marker click functionality in 4.1.0-SNAPSHOT if this:
Would pop the toast every time. Notice I returned 'true' there. That's the cue to say that I've handled this event myself and I don't want default behaviour. Thing is, the default behaviour is still happening (though not showing the info window) and so the second tap doesn't pop a toast, only every second tap pops a toast.
SilkSama commentedon Jul 1, 2016
Ugly workaround but it work for me waiting a better solution
@OverRide
public boolean onMarkerClick(@nonnull Marker marker) {
...
new Handler().postDelayed(() -> mMapboxMap.deselectMarker(marker), 100);
return true;
}
TostF commentedon Jul 26, 2016
@SilkSama hack is working.
Problem here is that the OnMarkerClickListener does not represent the task that it is doing.
At the moment OnMarkerClickListener should be called OnMarkerSelectedListener.
jemshit commentedon Oct 19, 2016
@bobmeyers5 That is very nice description of problem 👍
tobrun commentedon Dec 6, 2016
I focussed on resolving the business logic issues as set out in the OP:
MapView.onSingleTapConfirmed should raise the MarkerClick event any time the input event occurs, regardless of the marker's selection state.
If the MarkerClick event handler returns
falsetrue, the entire default response to that input, including any selection state change, should be skipped.Related to the other items mentioned in the OP as OnMarkerSelectionChangeListener. I'm thinking of PR'ing current progress and handling that as a separate feature request.
FreedApe770 commentedon Mar 13, 2017
@SilkSama Why do I need to use the "Handler().postDelayed(() -> mMapboxMap.deselectMarker(marker), 100);" rather than the “mMapboxMap.deselectMarker(marker)”? I know the latter is no effect, but I would like to know the reason.
Thank you very much!
tobrun commentedon Mar 13, 2017
@jwen1989 the workaround is no longer applicable, you should be able to get it your use-case working without it. Feel free to add more information or create a separate ticket.
FreedApe770 commentedon Mar 23, 2017
@tobrun Thank you for your advice。