-
Notifications
You must be signed in to change notification settings - Fork 1.3k
setTargetCoordinate seems to be incompatible with mapViewUserLocationAnchorPoint #13570
Comments
Thanks for the bug report @stoeffn! Any chance you can share a video/gif of what you're seeing? Thanks! |
Hi, @stoeffn. Thank you for using Mapbox. I was trying to reproduce this error with no luck. My questions are:
|
Hello @fabian-guerra, thank you for investigating! |
I've put together a simple sample project. It draws a route on a map and simulates movements on this route. You can tap the map view and leave user tracking so you can verify that this works as it should. I omitted course information but it doesn't work with course information either. Thank you in advance! |
Hi, @stoeffn. Thank you for the test project. I will take a second look. |
Hi, @stoeffn. Thank you again for helping us track down the issue. After looking at the coordinate that is used as the target and the overall code structure I could tell you that the values that are passed cause this behavior. Let me explain: When you set: One solution may be precompute the view port for each route step so you can actually set the proper target coordinate. What's the problem you are trying to solve? Maybe I could advice a different approach. |
Hello @fabian-guerra, In my real app, which is a navigation app, I'm basically trying to show both the current position and the next turn on screen. So every time the user passes a turn, I'd set the target coordinate to the next one while the system keeps updating the current position. Just to clarify: I (currently) cannot set the target coordinate while the user is moving? |
Hi, @stoeffn.
The problem I see with that approach is that each route segment is not an average size, and as you already have seen you have this big changes in route's segment bounds that prompts the animation race conditions. Have you tried to compute an average route step visual bounds? For example have an average bounds size that you can set for small/medium/large route segments so you don't have this big changes. Although for large route segments you won't be able to visualize the turning point at glance it will get displayed as you approach. |
Hello @fabian-guerra, Related question: How do I change the altitude and pitch in an animated fashion while |
This is how Also note that you may see some yo-yoing of the camera when setting a target coordinate while the map is tilted, due to #2259. |
Hi,
I'm really glad that Mapbox recently introduced
func mapViewUserLocationAnchorPoint(_ mapView: MGLMapView) -> CGPoint
inMGLMapViewDelegate
. It really helps an important navigation use-case where we need to track the user but keep his/her position on the bottom of the screen.However, it does not currently seem to work with
func setTargetCoordinate(_ targetCoordinate: CLLocationCoordinate2D, animated: Bool)
, which sets a point of focus.Steps to reproduce
Expected behavior
Map view focuses on both the user location, which is at the bottom of the view, and the target coordinate.
Actual behavior
User location icon flickers between default center position and custom bottom position.
The screenshot below shows how the user location icon is displayed where it's supposed to be on the user's screen before switching back to the center where it's supposed to be on the map.
This is to say, that the map is not positioned correctly and the custom anchor and target coordinate seem to be "fighting" where to display the user location icon.
Configuration
Mapbox SDK versions: 4.6
iOS versions: 12.1
Device models: iPhone 6 Plus
Xcode version: 10.1
The text was updated successfully, but these errors were encountered: