-
-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS] add-camera-padding #1348
[iOS] add-camera-padding #1348
Changes from all commits
069b76f
90891ee
a97dcc6
dc42c1e
e656886
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3069,6 +3069,7 @@ - (void)resetPosition | |
double zoom = camera.zoom ? *camera.zoom : 0.0; | ||
mbgl::LatLng center = camera.center ? *camera.center : mbgl::LatLng(); | ||
|
||
|
||
CLLocationDirection heading = mbgl::util::wrap(bearing, 0., 360.); | ||
CLLocationDistance altitude = MLNAltitudeForZoomLevel(zoom, pitch, 0, self.frame.size); | ||
self.camera = [MLNMapCamera cameraLookingAtCenterCoordinate:MLNLocationCoordinate2DFromLatLng(center) | ||
|
@@ -4352,7 +4353,17 @@ - (MLNMapCamera *)cameraForCameraOptions:(const mbgl::CameraOptions &)cameraOpti | |
CLLocationDirection direction = cameraOptions.bearing ? mbgl::util::wrap(*cameraOptions.bearing, 0., 360.) : self.direction; | ||
CGFloat pitch = cameraOptions.pitch ? *cameraOptions.pitch : *mapCamera.pitch; | ||
CLLocationDistance altitude = MLNAltitudeForZoomLevel(zoomLevel, pitch, centerCoordinate.latitude, self.frame.size); | ||
return [MLNMapCamera cameraLookingAtCenterCoordinate:centerCoordinate altitude:altitude pitch:pitch heading:direction]; | ||
|
||
MGLEdgeInsets padding = MGLEdgeInsetsZero; | ||
if (cameraOptions.padding) { | ||
padding = MGLEdgeInsetsMake( | ||
cameraOptions.padding->top(), | ||
cameraOptions.padding->left(), | ||
cameraOptions.padding->bottom(), | ||
cameraOptions.padding->right() | ||
); | ||
} | ||
return [MLNMapCamera cameraLookingAtCenterCoordinate:centerCoordinate altitude:altitude pitch:pitch heading:direction padding:padding]; | ||
} | ||
|
||
/// Returns a CameraOptions object that specifies parameters for animating to | ||
|
@@ -4376,6 +4387,9 @@ - (MLNMapCamera *)cameraForCameraOptions:(const mbgl::CameraOptions &)cameraOpti | |
{ | ||
options.pitch = camera.pitch; | ||
} | ||
if (!MGLEdgeInsetsEqual(camera.padding, MGLEdgeInsetsZero)) { | ||
options.padding = MLNEdgeInsetsFromNSEdgeInsets(camera.padding); | ||
} | ||
Comment on lines
+4390
to
+4392
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving the discussion of the old PR over to this PR:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me do some more testing before we merge this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did my testing. However, since this is my first PR in maplibre native I would like to have feedback from someone that knows this part of the code well enough :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The library currently conflates two different concepts as “padding”:
In the original design in mapbox/mapbox-gl-native#3583, the Unfortunately, a change was made to mbgl that conflated these two concepts, creating quite a headache for iOS/macOS developers: mapbox/mapbox-gl-native#15232 mapbox/mapbox-gl-native#15233. I have recommended that None of this was taken into account on Android; this mbgl functionality was exposed more literally without much regard for the practical use cases. Unfortunately, this means cross-platform libraries like the Flutter library will need to reconcile the two approaches. |
||
return options; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that this adjustment on the example app is not perfect.
It's been a while since I wrote some objective-c so that's why I quickly adjusted an existing entry in the feature list instead of creating a new one.
If someone has a better idea and can maybe help me out then let me know 👍🏽