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.
[iOS] Clickable annotation image area to select annotation #3880
Hi, at some point in v.3.1.0 there was a change:
"Tapping now selects annotations more reliably. Tapping near the top of a large annotation image now selects that annotation. An annotation image’s alignment insets influence how far away the user can tap and still select the annotation."
According to above I try to change annotation image alignment rect like this:
but I did not notice any changes in clickable area which is too big in my case, I have to reduce clickable area to half of the annotation image.
I can add that dequeue method:
returns me annotations image with correct alignment rect: (0, 0, 60.0, 0)
Maybe I'm doing something wrong or misunderstand something... Can you show me an example how to set annotation image's alignment rect or what I'm doing wrong? Thanks!
("annotation image" I mean property "image" in MGLAnnotationImage)
This insets the bottom edge of the image by 60 pixels. If your image is 120 pixels tall, that would indeed exclude the bottom half of the image from the alignment rect.
However, what you’re observing sounds like the five-pixel slop area we place on all sides of the alignment rect, since taps can be quite imprecise. (In the OS X SDK, by contrast, we do exact hit-testing on the visible portion of the image, because mouse clicks are far more precise.) We’re definitely open to ideas about how to respect the alignment rect more literally while allowing for imprecise taps.
Thanks for quick response. What I am trying to achieve is to exclude bottom half of annotation image from being clickable. I have a lot annotations with image like the one below:
to be more accurate with position of our markers. As far as I know there is no API to set or change anchor point of annotation image yet.
Problem occurs with selectable annotations, when user taps below an image and transparent part of the image takes part in detection process if user click (or not) annotation.
And I thought that I can exclude transparent part by setting image alignment rect, but without success.
Activity
1ec5 commentedon Feb 10, 2016
This insets the bottom edge of the image by 60 pixels. If your image is 120 pixels tall, that would indeed exclude the bottom half of the image from the alignment rect.
However, what you’re observing sounds like the five-pixel slop area we place on all sides of the alignment rect, since taps can be quite imprecise. (In the OS X SDK, by contrast, we do exact hit-testing on the visible portion of the image, because mouse clicks are far more precise.) We’re definitely open to ideas about how to respect the alignment rect more literally while allowing for imprecise taps.
BFTE commentedon Feb 10, 2016
Thanks for quick response. What I am trying to achieve is to exclude bottom half of annotation image from being clickable. I have a lot annotations with image like the one below:

to be more accurate with position of our markers. As far as I know there is no API to set or change anchor point of annotation image yet.
Problem occurs with selectable annotations, when user taps below an image and transparent part of the image takes part in detection process if user click (or not) annotation.
And I thought that I can exclude transparent part by setting image alignment rect, but without success.
[ios, osx] Exclude misses from nearby annotations
1ec5 commentedon Feb 11, 2016
That’s correct, although if #3885 turns out to be the right solution for the Android SDK, we could easily port it over to the iOS SDK.
You’re right in expecting that to work. There is a bug in how we’re hit-testing annotations that you’re probably running into: #3898.
1ec5 commentedon Feb 11, 2016
Fixed in #3898, which will be in 3.1.1, to be released shortly.