-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add delegate methods for tapping route duration. #4133
Conversation
88cb6ad
to
26b7517
Compare
863a6a3
to
fad1796
Compare
for layerId in layerIds { | ||
group.enter() | ||
let options = RenderedQueryOptions(layerIds: [layerId], filter: nil) | ||
routeIndexFromMapQuery(with: options, at: point) { [weak self] (routeIndex) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user would tap on what visuallly appears to be the callout bubble. However, the callout bubble is offset from the actual feature data. This call queries for feature data located at the tap point, which would be some distance away from where the feature data is actually located.
For this approach to be more reliable than routes(closeTo:)
, we’d technically need to figure out the callout bubble’s screen rect. Alternatively, since we’re filtering to just the annotation layers, we could query for all the features in the current viewport, then select the result that’s closest to the tap point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ShanMa1991 confirmed that these days, MapboxMap.queryRenderedFeatures(at:options:completion:)
actually does account for label bounds and offsets. That’s a big deal. I think it resolves this concern and probably also some other issues in our backlog.
/ref #4165 (comment)
aca0ddd
to
9a4c323
Compare
3b9528b
to
b955ec0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple things that’ll prevent confusion down the line, but otherwise good to go.
@@ -2120,12 +2120,60 @@ open class NavigationMapView: UIView { | |||
if let selected = waypointTest?.first { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method becomes more complex with time, I wonder if we could cover it with unit-tests to make sure that delegate methods are called based on expected priority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now it still follows the previous sequence, but between the waypoints and route, it would check the duration annotation. I'll add test for this one later.
b955ec0
to
49d50ee
Compare
Description
This PR is to fix #3847 by adding the ability for users to detect the taps on duration annotations for routes and continuous alternative routes.
Implementation
When users tapped the
NavigationMapView
, theNavigationMapView
will check whether duration annotations for routes and continuous alternative routes have been tapped. If users tapped duration annotations, it will notify theNavigationMapViewDelegate.navigationMapView(_: didTap:)
about the taps. If not, it will check the taps on Waypoints, the closest route and the closest continuous alternative route.The
NavigationMapViewDelegate.navigationMapView(_: didTap:)
provides the route or continuous alternative route whose duration annotation has been tapped.Screenshots or Gifs