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] Wrong map insets behavior while tracking user location #3778
Bug visible on current master (3.1.0 pre 3)
Show a map, set the map contentInset. The map moves accordingly. This is correct.
Then set the user tracking to follow. The map then "moves back" to its original position and only the user location is inset. This makes a double error : the map is not correctly inset and the user location is incorrect.
There are a number of possible reasons why the content inset might appear to be reverted. I’m unable to reproduce this issue by setting the content inset then setting the user tracking mode. Are you using the plain property setters or the animated: methods? Does the view controller have a top or bottom bar that might be overriding the content inset? Is the user tracking mode set immediately (synchronously) after setting the content inset, or is there some delay?
Hi. I'm trying to inset on the right and bottom.
The view controller managing the map is part of a navigation controller so there's a navigation bar.
I did some tests, it always behave the same : I'm setting the inset to the map. I tried both with animation api or directly with the setter. Then I set userTrackingMode to follow. Even if I set it after 2s, there is a map shift which leads to an incorrect position of the marker vs the map. The user marker is correctly centered in the inset area, but the map suffers from an extra offset.
I also just tried to set the user mode to follow on map appearance, then switch on/off the insets. Here are some screenshots to show the behavior.
Seems to be animation timing issue in MGLMapView.mm
in method - (void)locationManager:(__unused CLLocationManager *)manager didUpdateLocations:(NSArray *)locations animated:(BOOL)animated
the map view is updated, then the user view is updated ... under debug.
Funny to see that if you invert this logic (update user view then map), the user view is correctly positioned, but the map does not move to the inset !
@1ec5 I tested again on device, the bug is still there (3.1.1 + master)
In my view controller viewDidAppear I set the userTrackingMode to follow.
On a switch controller I set the map inset to inset.
Seems that - (UIEdgeInsets)edgePaddingForFollowing is no more useful.
All methods - (void)setCenterCoordinate:xxxxxx are using now self.contentInset as the edgePadding except one. Changing it make the user location + map centered correctly on the inset view.
Thanks for your contribution @RomainQuidet! I think you are correct that passing contentInset as the edgePadding parameter to _setCenterCoordinate is correct. Your change to do that is now in #6216 and should be merged soon.
Activity
1ec5 commentedon Feb 1, 2016
Does this bug reproduce in pre.2 or pre.1?
1ec5 commentedon Feb 2, 2016
There are a number of possible reasons why the content inset might appear to be reverted. I’m unable to reproduce this issue by setting the content inset then setting the user tracking mode. Are you using the plain property setters or the
animated:methods? Does the view controller have a top or bottom bar that might be overriding the content inset? Is the user tracking mode set immediately (synchronously) after setting the content inset, or is there some delay?RomainQuidet commentedon Feb 2, 2016
Hi. I'm trying to inset on the right and bottom.
The view controller managing the map is part of a navigation controller so there's a navigation bar.
I did some tests, it always behave the same : I'm setting the inset to the map. I tried both with animation api or directly with the setter. Then I set userTrackingMode to follow. Even if I set it after 2s, there is a map shift which leads to an incorrect position of the marker vs the map. The user marker is correctly centered in the inset area, but the map suffers from an extra offset.
I also just tried to set the user mode to follow on map appearance, then switch on/off the insets. Here are some screenshots to show the behavior.
RomainQuidet commentedon Feb 2, 2016
In case I just set the map region or center coordinate before setting / unsetting the insets, it works correctly.
RomainQuidet commentedon Feb 2, 2016
Seems to be animation timing issue in MGLMapView.mm
in method - (void)locationManager:(__unused CLLocationManager *)manager didUpdateLocations:(NSArray *)locations animated:(BOOL)animated
the map view is updated, then the user view is updated ... under debug.
Funny to see that if you invert this logic (update user view then map), the user view is correctly positioned, but the map does not move to the inset !
RomainQuidet commentedon Feb 3, 2016
@1ec5 On device the bug is not visible. I suspect the simulator to inject position too often and then an animation collision occur.
RomainQuidet commentedon Feb 18, 2016
@1ec5 I tested again on device, the bug is still there (3.1.1 + master)
In my view controller viewDidAppear I set the userTrackingMode to follow.
On a switch controller I set the map inset to inset.
RomainQuidet commentedon Feb 22, 2016
Seems that - (UIEdgeInsets)edgePaddingForFollowing is no more useful.
All methods - (void)setCenterCoordinate:xxxxxx are using now self.contentInset as the edgePadding except one. Changing it make the user location + map centered correctly on the inset view.
Pull request ongoing.
RomainQuidet commentedon Feb 22, 2016
created #4067
boundsj commentedon Aug 30, 2016
Thanks for your contribution @RomainQuidet! I think you are correct that passing
contentInsetas the edgePadding parameter to_setCenterCoordinateis correct. Your change to do that is now in #6216 and should be merged soon.