-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Added cameraThatFitsShape: direction: pitch: edgePadding: method #13007
Conversation
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 made a minor comment. Just make sure everything works correctly in:
cameraThatFitsShape:direction:edgePadding:
platform/ios/src/MGLMapView.mm
Outdated
@@ -3457,10 +3457,14 @@ - (MGLMapCamera *)camera:(MGLMapCamera *)camera fittingShape:(MGLShape *)shape e | |||
} | |||
|
|||
- (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction edgePadding:(UIEdgeInsets)insets { | |||
return [self cameraThatFitsShape:shape direction:direction pitch:0 edgePadding:insets]; |
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 may be wrong but if you pass 0
in this method it will ignore the current transformation state and calculate a 0 based pitch. Could you please test and confirm that this is not the case.
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.
That would be true. I'll fix that
platform/macos/src/MGLMapView.mm
Outdated
padding += MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets); | ||
|
||
mbgl::CameraOptions cameraOptions = _mbglMap->cameraForGeometry([shape geometryObject], padding, direction); | ||
return [self cameraThatFitsShape:shape direction:direction pitch:0 edgePadding:insets]; |
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.
Same as above:
I may be wrong but if you pass
0
in this method it will ignore the current transformation state and calculate a 0 based pitch. Could you please test and confirm that this is not the case.
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.
good catch
@fabian-guerra Thanks for catching those issues. I've updated the files. |
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.
Looks good
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.
Before this PR can be merged, I think there would need to be a test or at least screenshots demonstrating that the returned camera actually fits the given shape snugly. I don’t see how this method accomplishes that task given that #2259 is still outstanding.
@1ec5 This will behave the same way as the current |
So... there's already a method called |
Aha! I thought I remembered @bsudekum implemented that but couldn’t find #12213 for some reason. Thanks for digging it up. If I recall correctly, we gave it that awkward name in part because it doesn’t necessarily fit all the parameters that are passed in – it just tries to fit as many as possible. We felt that #2259 wouldn’t be a blocker because it makes no guarantees about actually fitting anything precisely. It sounds like this PR is unnecessary given #12213. |
Closed in favor of using the existing |
Fixes #13005
The current implementation uses the current pitch of the map to calculate the altitude. This addition allows for getting the proper altitude of the camera for an upcoming pitch change which allows for a smooth animation to the new pitch and altitude.
/cc @1ec5 @fabian-guerra @friedbunny @julianrex