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.
MGLMapView setCamera( <camera fitting content>() ) doesn't work correctly with MGLMapView.contentInset #15574
use currently set MGLMapView.contentInset when computing camera that would fit desired content to an area defined by MGLMapView.contentInset + optional padding, as if contentInset in MGLMapView would not additionally move the content when
I agree that there’s a difference in behavior between the -camera… getters and the -setCamera… setters and that it’s confusing and unexpected. To be clear, the desired behavior is that the getters’ use of content insets cancel out the setters’ use of content insets. For example, this code should have no effect even when there’s a content inset:
mapView.camera=mapView.camera
equivalently:
[mapView setCamera:[mapView camera]];
At the same time, if you pass the return value of -cameraThatFitsCoordinateBounds:edgePadding: into -setCamera:withDuration:animationTimingFunction:edgePadding:completionHandler:, you would have to pass the same edge padding into both methods in order for the -cameraThatFitsCoordinateBounds:edgePadding: return value to be accurate. At least that’s how I’d expect the methods to behave based on their naming.
@1ec5 thanks for clarifying, it's unfortunate that this part of the API is a often misunderstood. Finding these illuminating threads sure feels like collecting golden nuggets.
I am currently setting my camera with the following to prevent any sudden jumps:
Sometimes, though, the edgePadding is not preserved and the camera jumps. Could you suggest some way to fix this? It happens when the user changes the map zoom level by panning. It looks like this resets the edgePadding on the camera, and setting a camera with added edge padding again will cause it's viewport to jump.
Activity
Work around mapbox-gl-native/15574. Avoid re-setting content inset to…
1ec5 commentedon Sep 16, 2019
I agree that there’s a difference in behavior between the
-camera…getters and the-setCamera…setters and that it’s confusing and unexpected. To be clear, the desired behavior is that the getters’ use of content insets cancel out the setters’ use of content insets. For example, this code should have no effect even when there’s a content inset:equivalently:
At the same time, if you pass the return value of
-cameraThatFitsCoordinateBounds:edgePadding:into-setCamera:withDuration:animationTimingFunction:edgePadding:completionHandler:, you would have to pass the same edge padding into both methods in order for the-cameraThatFitsCoordinateBounds:edgePadding:return value to be accurate. At least that’s how I’d expect the methods to behave based on their naming.Work around mapbox-gl-native/15574. Avoid re-setting content inset to…
oleksii-aleksandrovych commentedon Feb 11, 2020
I spended near 8h try to resolve bug related to this behaviour
ferologics commentedon May 19, 2021
@1ec5 thanks for clarifying, it's unfortunate that this part of the API is a often misunderstood. Finding these illuminating threads sure feels like collecting golden nuggets.
I am currently setting my camera with the following to prevent any sudden jumps:
Sometimes, though, the
edgePaddingis not preserved and the camera jumps. Could you suggest some way to fix this? It happens when the user changes the map zoom level by panning. It looks like this resets theedgePaddingon the camera, and setting a camera with added edge padding again will cause it's viewport to jump.