[ios] Fix camera paddings reset on map view gestures performing.#188
Merged
petr-pokorny-1 merged 3 commits intomaplibre:masterfrom Dec 2, 2021
Merged
Conversation
Contributor
Author
|
Here one can find the project with the fix demonstration. It's in the separate AsymmetricalPaddingsDemo.mov
|
| { | ||
| mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(self.contentInset); | ||
| mbgl::CameraOptions currentCameraOptions = self.mbglMap.getCameraOptions(padding); | ||
| mbgl::CameraOptions currentCameraOptions = self.mbglMap.getCameraOptions(); |
Contributor
Author
There was a problem hiding this comment.
Here and in similar places below the padding value passed in mbglMap.getCameraOptions() just replaces the camera edge insets. Although CameraOptions is a pure model class which doesn't have any computations and side effects, it doesn't make much sense to replace its padding value.
|
|
||
| contentInset = UIEdgeInsetsMake(20, 20, 20, 20); | ||
| [self.mapView setCamera:self.mapView.camera withDuration:0.1 animationTimingFunction:nil edgePadding:contentInset completionHandler:nil]; | ||
| [self.mapView setCamera:self.mapView.camera withDuration:0.0 animationTimingFunction:nil edgePadding:contentInset completionHandler:nil]; |
Contributor
Author
There was a problem hiding this comment.
The change must be immediate to take an effect while the test is running.
Contributor
|
This looks really good @OlexandrStepanov Thank you for the great work! |
petr-pokorny-1
approved these changes
Dec 2, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the issue with inconsistent padding reset of the map view camera after performing any gesture on the map other than pan.
The logic to reset camera paddings with pinch/rotation gesture was introduced in this commit altogether with gesture unit tests. Although I'm not sure what was the original intent, it seems wrong nowadays taking into account the current logic of edge insets handling in
MGLMapView.set...methods.Just to be clear, what I mean by "current logic":
contentInsetproperty ofMGLMapViewcontrols the global padding of the map view. This value persists between camera changes of the map and controls the map elements positioning, like compass, scale bar, logo view etc.edgePaddingvalue passed in the methods likesetCamera:,setVisibleCoordinatesBounds:,showAnnotations:etc. is the transient value for this particular camera update.contentInsetand passededgePadding. This value is passed to the internal_mbglMapas a part ofCameraOptions.contentInsetvalue.There is another PR which is reported to be fixing the same issue, but there are some new problems introduced there.
edgePaddingare interchangeable, so having both of them introduces some ambiguity.More discussions on the topic: