Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Marker clickable area #6761

Closed
Closed

Description

@mpuchala

Platform: Android
Mapbox SDK version: 4.2.0 SNAPSHOT

Steps to trigger behavior

  1. Create Map
  2. Click Markers

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!

Activity

  1. changed the title [-][Android] Markers problem[/-] [+][Android] Marker problems - too big clickable area[/+] on Oct 19, 2016
  2. changed the title [-][Android] Marker problems - too big clickable area[/-] [+][Android] Too big marker's clickable area[/+] on Oct 19, 2016
  3. added
    Android
    on Oct 20, 2016
  4. tobrun commented on Oct 25, 2016

    @tobrun
    Member

    @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.

    this is important issue when we have a lot of markers

    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.

  5. changed the title [-][Android] Too big marker's clickable area[/-] [+]Marker clickable area[/+] on Oct 25, 2016
  6. added this to the milestone on Oct 25, 2016
  7. mpuchala commented on Oct 25, 2016

    @mpuchala
    Author

    @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 loadIconForMarker(Marker marker) method we have:

            if (icon == null) {
                icon = IconFactory.getInstance(getContext()).defaultMarker();
                Bitmap bitmap = icon.getBitmap();
                averageIconHeight = averageIconHeight + (bitmap.getHeight() / 2 - averageIconHeight) / iconSize;
                averageIconWidth = averageIconHeight + (bitmap.getWidth() - averageIconHeight) / iconSize;
                marker.setIcon(icon);
            } else {
                Bitmap bitmap = icon.getBitmap();
                averageIconHeight = averageIconHeight + (bitmap.getHeight() - averageIconHeight) / iconSize;
                averageIconWidth = averageIconHeight + (bitmap.getWidth() - averageIconHeight) / iconSize;
            }
    

    averageIconWidth is mixed with averageIconHeight when you're setting it. I don't think it's kind of workaround more like oversight, isn't it?

  8. tobrun commented on Oct 25, 2016

    @tobrun
    Member

    I noticed the same thing today, I have a fix for that in #5639

  9. tobrun commented on Dec 7, 2016

    @tobrun
    Member

    Adding here that improving this system should also take in account anchoring as noted in #7307.

  10. pnull commented on Jan 31, 2017

    @pnull

    Any chance that this will be fixed soon? We have serious problems with this offset bug..

  11. MikeKasperlik commented on Feb 9, 2017

    @MikeKasperlik

    Yep we see this too in our App

  12. removed this from the android-v5.0.0 milestone on Mar 6, 2017
  13. galacticappster04 commented on Mar 17, 2017

    @galacticappster04

    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.

  14. mariusboepple commented on Mar 17, 2017

    @mariusboepple

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

  15. tobrun commented on Mar 17, 2017

    @tobrun
    Member

    Small update on this issue:

  16. galacticappster04 commented on Apr 7, 2017

    @galacticappster04

    Has this been implemented on the v5.0.2? Please confirm. If so close this issue.

  17. tobrun commented on Apr 7, 2017

    @tobrun
    Member

    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.

  18. tobrun commented on Apr 19, 2017

    @tobrun
    Member

    Tracking latest state in #8159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Android

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions