Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
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

Closed

Description

@RomainQuidet

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.

Activity

  1. 1ec5 commented on Feb 1, 2016

    @1ec5
    Contributor

    Does this bug reproduce in pre.2 or pre.1?

  2. added
    iOS
    on Feb 2, 2016
  3. 1ec5 commented on Feb 2, 2016

    @1ec5
    Contributor

    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?

  4. RomainQuidet commented on Feb 2, 2016

    @RomainQuidet
    ContributorAuthor

    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.

    simulator screen shot 2 fevr 2016 10 39 54
    simulator screen shot 2 fevr 2016 10 40 00
    simulator screen shot 2 fevr 2016 10 40 38
    simulator screen shot 2 fevr 2016 10 40 42

  5. RomainQuidet commented on Feb 2, 2016

    @RomainQuidet
    ContributorAuthor

    In case I just set the map region or center coordinate before setting / unsetting the insets, it works correctly.

    simulator screen shot 2 fevr 2016 11 04 40
    simulator screen shot 2 fevr 2016 11 04 44

  6. RomainQuidet commented on Feb 2, 2016

    @RomainQuidet
    ContributorAuthor

    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 !

  7. RomainQuidet commented on Feb 3, 2016

    @RomainQuidet
    ContributorAuthor

    @1ec5 On device the bug is not visible. I suspect the simulator to inject position too often and then an animation collision occur.

  8. RomainQuidet commented on Feb 18, 2016

    @RomainQuidet
    ContributorAuthor

    @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.

  9. RomainQuidet commented on Feb 22, 2016

    @RomainQuidet
    ContributorAuthor

    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.

  10. RomainQuidet commented on Feb 22, 2016

    @RomainQuidet
    ContributorAuthor

    created #4067

  11. added this to the ios-v3.4.0 milestone on Aug 30, 2016
  12. self-assigned this
    on Aug 30, 2016
  13. boundsj commented on Aug 30, 2016

    @boundsj
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugiOS

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions