Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Force camera change when specifying edge padding #14790

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion platform/ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT

### Styles and rendering

* Implemented asymmetric center of perspective: fixed an issue that caused the focal point to be always based on the view's horizontal center when setting [MGLMapView contentInset](https://docs.mapbox.com/ios/api/maps/5.0.0/Classes/MGLMapView.html#/c:objc(cs)MGLMapView(py)contentInset). ([#14664](https://github.com/mapbox/mapbox-gl-native/pull/14664))
* Setting `MGLMapView.contentInset` now moves the map’s focal point to the center of the content frame after insetting. ([#14664](https://github.com/mapbox/mapbox-gl-native/pull/14664))

## 5.0.0 - May 22, 2019

Expand Down
2 changes: 1 addition & 1 deletion platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ - (void)setContentInset:(UIEdgeInsets)contentInset animated:(BOOL)animated
[self didUpdateLocationWithUserTrackingAnimated:animated];
}

// Compass, logo and attribution button constraints needs to be updated.z
// Compass, logo and attribution button constraints needs to be updated.
[self installConstraints];
}

Expand Down
2 changes: 1 addition & 1 deletion platform/macos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Styles and rendering

* Implemented asymmetric center of perspective: fixed an issue that caused the focal point to be always based on the view's horizontal center when setting [MGLMapView contentInset](https://docs.mapbox.com/ios/api/maps/5.0.0/Classes/MGLMapView.html#/c:objc(cs)MGLMapView(py)contentInset). ([#14664](https://github.com/mapbox/mapbox-gl-native/pull/14664))
* Setting `MGLMapView.contentInsets` now moves the map’s focal point to the center of the content frame after insetting. ([#14664](https://github.com/mapbox/mapbox-gl-native/pull/14664))

## 0.14.0 - May 22, 2018

Expand Down
4 changes: 2 additions & 2 deletions platform/macos/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration a
};
}

if ([self.camera isEqualToMapCamera:camera]) {
if ([self.camera isEqualToMapCamera:camera] && NSEdgeInsetsEqual(edgePadding, NSEdgeInsetsZero)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edgePadding specified here is self.contentInsets when specified in L.1181.
The documentation doesn't state that this is additional padding, like in #12818 (comment), additional to self.contentInsets.
I believe that we need to check NSEdgeInsetsEqual(edgePadding, self.contentInsets)) here instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof, thanks, somehow I missed that the macOS implementation is also affected by #12818.

if (completion) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
completion();
Expand Down Expand Up @@ -1311,7 +1311,7 @@ - (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(NSEd
}

MGLMapCamera *camera = [self cameraForCameraOptions:cameraOptions];
if ([self.camera isEqualToMapCamera:camera]) {
if ([self.camera isEqualToMapCamera:camera] && NSEdgeInsetsEqual(insets, NSEdgeInsetsZero)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no need for this change: cameraForLatLngBounds is still baking in specified paddingto cameraOptions adjusted center (that is ##14664 didn't fix cameraForLatLngBounds as we don't have padding in public MGLMapCamera API - padding is in view) and this should keep current behaviour since it is unchanged.

return;
}

Expand Down