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.
Can you get more specific about how close nearby annotations are visually, what point you are tapping (as logged in debug) and how that compares to the annotation you were trying to tap?
Because annotations are in GL and aren't actual tappable views, we are querying a fuzzy region around the user's tap to try to guess which annotations they are referring to, as well as iterating overlapping annotations like MapKit does to enable selection of obscured markers.
while (id <MGLAnnotation> annotation = enumerator.nextObject)
{
if ([[[self.annotationIDsByAnnotation objectForKey:annotation] objectForKey:MGLAnnotationIDKey] integerValue] == newSelectedAnnotationID)
{
// only change selection status if not the currently selected annotation
if ( ! [annotation isEqual:self.selectedAnnotation])
{
[selfselectAnnotation:annotation animated:YES];
}
// either way, we should stop enumerating
break;
}
}
}
else
{
// deselect any selected annotation
if (self.selectedAnnotation) [selfdeselectAnnotation:self.selectedAnnotation animated:YES];
}
}
}
In addition, this heuristic can vary depending on marker image size, as that affects the user's perceived tappable area while not changing the region query (though we do weight the region to account for top-heavy markers).
In short, this has felt good for months now, so I'm curious what changed and what the specific scenario is that is triggering this impression.
I'm testing on device using the Emerald style and "Add 100 Points", and zooming into an area where there is only one marker. It looks like the problem is that the hitbox for the marker is about half the size of the actual marker in Emerald, so only taps on the lower half of the marker image register.
Emerald's marker being so much bigger than Streets' (and Light/Dark's) - 86 vs. 50px high
Streets:
Emerald:
However, this highlights the difficult with the stopgap method of limiting marker imagery to the sprite sheet while simultaneously trying to minimize communications between the GL sprite parsing layer and the iOS code related to gestures.
Possible solutions:
Tweak annotation gesture algorithms
Come up with communications layer to better relate sprite sizing, but we will throw this away in b2 when we support runtime imagery (or will we?)
Punt for b1, for Emerald
Size down the Emerald marker imagery and document the limitation for users wanting their own sprite-based imagery /cc @peterqliu
The situation may’ve improved a little at lower zoom levels due to #1827. TransformState::latLngForPixel() was being used by -[MGLMapMap handleSingleTapGesture:] to compute a bounds (centered around the tap) to pass into Map::getAnnotationsInBounds().
Annotation images frequently have shadows or other ornamentation that shouldn’t be considered part of the hit target. The most natural way to handle this detail on iOS would be to set the image’s alignment rectangle; -[MGLMapView handleSingleTapGesture:] would then filter the results from getPointAnnotationsInBounds() by whether a given annotation’s image’s alignment rect intersects with the tap.
changed the title [-]annotation taps frequently don't work[/-][+]Annotation tap gesture recognizer queries hard-coded region, ignoring image sizes[/+]on Nov 30, 2015
Activity
incanus commentedon May 11, 2015
Can you get more specific about how close nearby annotations are visually, what point you are tapping (as logged in debug) and how that compares to the annotation you were trying to tap?
Because annotations are in GL and aren't actual tappable views, we are querying a fuzzy region around the user's tap to try to guess which annotations they are referring to, as well as iterating overlapping annotations like MapKit does to enable selection of obscured markers.
mapbox-gl-native/platform/ios/MGLMapView.mm
Lines 993 to 1117 in 44cb91c
In addition, this heuristic can vary depending on marker image size, as that affects the user's perceived tappable area while not changing the region query (though we do weight the region to account for top-heavy markers).
In short, this has felt good for months now, so I'm curious what changed and what the specific scenario is that is triggering this impression.
incanus commentedon May 11, 2015
More background: #1037 (comment)
jfirebaugh commentedon May 11, 2015
I'm testing on device using the Emerald style and "Add 100 Points", and zooming into an area where there is only one marker. It looks like the problem is that the hitbox for the marker is about half the size of the actual marker in Emerald, so only taps on the lower half of the marker image register.
incanus commentedon May 11, 2015
This is probably a result then of:
Streets:
Emerald:
However, this highlights the difficult with the stopgap method of limiting marker imagery to the sprite sheet while simultaneously trying to minimize communications between the GL sprite parsing layer and the iOS code related to gestures.
Possible solutions:
peterqliu commentedon May 11, 2015
I'm happy to size down the marker-- do we have a threshold in mind, both for the resizing and for the documentation?
1ec5 commentedon May 11, 2015
We’ve got a hardcoded 40×60 “tolerance” for tap recognition. It looks like the sprite is a bit taller than that.
(Eventually we’ll need to support markers of different sizes and enable
MGLMapViewto query for those sizes. That’ll really help make #1496 shine.)jfirebaugh commentedon May 11, 2015
I'm ok with punting on this for b1 for Emerald.
incanus commentedon May 11, 2015
I think this is an ok course of action. So: no further actions here for b1, assigning issue to b2.
incanus commentedon Jun 1, 2015
Again, b3 will feature point annotation improvements.
1ec5 commentedon Jul 2, 2015
The situation may’ve improved a little at lower zoom levels due to #1827.
TransformState::latLngForPixel()was being used by-[MGLMapMap handleSingleTapGesture:]to compute a bounds (centered around the tap) to pass intoMap::getAnnotationsInBounds().8 remaining items
ljbade commentedon Oct 30, 2015
For Android #2876 is the first part, it at least adjusts current hit box to be default marker + 10 dp on each side.
Next will be to change
getMarkersInBoundsto use the Bitmap size of each marker in mMarkers to determine if they are in the hit box.[android] Adjust annotation touch tolerance to match default marker
[android] Adjust annotation touch tolerance to match default marker
1ec5 commentedon Nov 29, 2015
Annotation images frequently have shadows or other ornamentation that shouldn’t be considered part of the hit target. The most natural way to handle this detail on iOS would be to set the image’s alignment rectangle;
-[MGLMapView handleSingleTapGesture:]would then filter the results fromgetPointAnnotationsInBounds()by whether a given annotation’s image’s alignment rect intersects with the tap.[-]annotation taps frequently don't work[/-][+]Annotation tap gesture recognizer queries hard-coded region, ignoring image sizes[/+]1ec5 commentedon Dec 1, 2015
The OS X port in #3135 has a fix for this issue, but porting the fix back to iOS is blocked by #3159.
1ec5 commentedon Dec 14, 2015
This will be fixed in #3261.