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.

Doesn't respect height of view #4440

Closed
Closed

Description

@millenbop

In 3.2.0 beta 2 on iOS, the map view doesn't seem to respect the height of the view, meaning it doesn't show the full world map and the centre is off. So when zoomed in and you set the centre coordinate, it will not be visible.

The following screens illustrate the problem.

img_2117
3.0.1

img_2116
3.2.0 beta 2

The actual MGLMapView is of correct size in both instances according to frame.size.height.

Activity

  1. added
    iOS
    on Mar 23, 2016
  2. 1ec5 commented on Mar 23, 2016

    @1ec5
    Contributor

    What is the map view's contentInset at the time that this issue occurs? I wonder if it's incorrectly accounting for the top bar, even though the top bar doesn't overlap the map view.

    Also, is the map view initialized with a non-zero-area frame?

  3. millenbop commented on Mar 23, 2016

    @millenbop
    Author
    NSLog(@"%f", self.webView.frame.size.height);
    NSLog(@"%f", self.mapView.frame.size.height);
    UIEdgeInsets insets = self.mapView.contentInset;
    NSLog(@"%f %f %f %f", insets.top, insets.bottom, insets.left, insets.right);
    
    257.000000
    257.000000
    -297.000000 0.000000 0.000000 0.000000
    

    The map is initialized via IB.

  4. added this to the ios-v3.2.0 milestone on Mar 25, 2016
  5. 1ec5 commented on Mar 25, 2016

    @1ec5
    Contributor

    Tagging with 3.2.0 milestone per #4476.

  6. friedbunny commented on Mar 25, 2016

    @friedbunny
    Contributor

    This was introduced in v3.1.0.

  7. self-assigned this
    on Mar 25, 2016
  8. friedbunny commented on Mar 26, 2016

    @friedbunny
    Contributor

    This bug has to do with the map view’s .contentInset having negative values — only positive values should affect the positioning of features within the map. This bug affects centering, setting visible coordinates, tracking the user location annotation, and so on.

    simulator-screen-shot-mar-25 -2016 -7 52 41-pm

    I think we’re going to have to check every case where we use .contentInset and then discard negative values, where appropriate.

    diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
    index 9b094ec..3224b2b 100644
    --- a/platform/ios/src/MGLMapView.mm
    +++ b/platform/ios/src/MGLMapView.mm
    @@ -1918,7 +1918,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
    
         [self willChangeValueForKey:@"visibleCoordinateBounds"];
         mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(insets);
    -    padding += MGLEdgeInsetsFromNSEdgeInsets(self.contentInset);
    +    padding += MGLEdgeInsetsFromNSEdgeInsets([self edgePaddingForCoordinateBounds]);
         mbgl::AnnotationSegment segment;
         segment.reserve(count);
         for (NSUInteger i = 0; i < count; i++)
    @@ -1950,6 +1950,14 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
         [self didChangeValueForKey:@"visibleCoordinateBounds"];
     }
    
    +/// Returns the edge padding to apply when fitting the map to coordinate bounds.
    +- (UIEdgeInsets)edgePaddingForCoordinateBounds
    +{
    +    UIEdgeInsets insets = self.contentInset;
    +    return UIEdgeInsetsMake((insets.top > 0 ? insets.top : 0), (insets.left > 0 ? insets.left : 0),
    +                            (insets.bottom > 0 ? insets.bottom : 0), (insets.right > 0 ? insets.right : 0));
    +}
    +
  9. friedbunny commented on Mar 29, 2016

    @friedbunny
    Contributor

    Fixed by #4504 and its dozen rebases.

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