-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Marker clickable area #6761
Comments
@mpuchala thank you for reaching out. To give you a some background on marker click handling. Currently we take Android motionEvent and calculate a rectangle from it. The rectangle size is based on the average icon width/height and some additional tolerance: float left = (tapPoint.x - averageIconWidth / 2 - toleranceSides);
float top = (tapPoint.y - averageIconHeight / 2 - toleranceTopBottom);
float right = (tapPoint.x + averageIconWidth / 2 + toleranceSides);
float bottom = (tapPoint.y + averageIconHeight / 2 + toleranceTopBottom);
RectF tapRect = new RectF(left / screenDensity, top / screenDensity, right / screenDensity, bottom / screenDensity); This rectangle is passed into cpp code and we will be returned all the markers in that rectangle. Using averages here is a very basic way of solving this issue and we could definitely use a more complex approach here.
If possible I would advice you to look into using markers of a similar size. This will improve the clickable area issue but imo also improve consistency in your map design. |
@tobrun thanks for clarification. Despite the fact I have usually same size icons sometimes it works unstable. When I was analyzing your code I found potential bug. Please take a look on MapView class. In
|
I noticed the same thing today, I have a fix for that in #5639 |
Adding here that improving this system should also take in account anchoring as noted in #7307. |
Any chance that this will be fixed soon? We have serious problems with this offset bug.. |
Yep we see this too in our App |
when tobrun explained how the code works I was really scratching my head. I just don't really know how everything works under the hood. I was thinking that the pin has width and height and position forming a rect, i tapped the map, I clicked on a pin (touch/mouse position x and y) and then check if that (x,y) is within the bounds of that pin. I just realized, this works fine on a very very small environment just like on video games. But we are talking about a very very large map and we can't just check all pins on the map if the touch location is within a rect. So at least how it originally works made sense to me. |
This thing is a severe bug... Anyone who is using clickable markers, which are anchored at the bottom (that's a really common case) must accept the bad user experience (#7307). This should be of higher priority... |
Small update on this issue:
|
Has this been implemented on the v5.0.2? Please confirm. If so close this issue. |
Apologies @neonwarge04, I still had to update this issue to the latest state. With 5.0.2 we reverted the changes made for onTouch in the migration of 4.x -> 5.x (#8585). This issue is still applicable for both Markers as MarkerViews. |
Tracking latest state in #8159 |
Platform: Android
Mapbox SDK version: 4.2.0 SNAPSHOT
Steps to trigger behavior
Actual behavior
I'm using resources without transparency. Clickable region seems to be much more bigger than image and this is important issue when we have a lot of markers. Also, on 4.1.0 it works fine and area contains only marker.
Example:
https://www.dropbox.com/s/6zin9c8guvrcy6y/clickable_area.mp4?dl=0
Regards!
The text was updated successfully, but these errors were encountered: