-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
/sub |
28ff640
to
4aeb79e
Compare
To keep the diffs in this PR coherent, I split out #3589 to push the user puck downward in course tracking mode. |
|
||
void EdgeInsets::flip() { | ||
std::swap(top, bottom); | ||
std::swap(left, right); |
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.
Moved EdgeInsets to geo.hpp so CameraOptions and Transform can refer to it. Added a padding option to CameraOptions that alters the frame of reference for the center option. Added optional padding parameters to LatLng getters and setters. Working towards #2600.
Added a contentInsets property to MGLMapView that behaves similarly to NSScrollView.contentInsets. Adjust it according to the window’s content layout rectangle using KVO. Automatically apply the content insets whenever creating a CameraOptions or getting the center coordinates.
Methods that offer a convenient way to jump or ease now accept an optional padding parameter. MGLMapView specifies the padding to ensure that keyboard-based zooming and rotation respects the toolbar.
…(), Map::pixelForLatLng() Map and Transform methods assume an origin at the top-left corner of the view, like iOS, Android, and GLFW but unlike OS X. Transform is responsible for flipping coordinates between the top-left origin of Map and the bottom-left origin of TransformState. Fixes #3574.
The zoom level is already clamped by Transform. -currentMinimumZoom appears to be useful only as an unrotation threshold; it doesn’t correspond to the minimum allowed zoom level.
This version of setLatLng() can be expressed by constraining the viewport to a 0×0 viewport around the passed-in point.
dc97d3f
to
8dfba0e
Compare
@@ -770,6 +773,49 @@ - (void)layoutSubviews | |||
} | |||
} | |||
|
|||
/// Updates `contentInset` to reflect the current window geometry. | |||
- (void)adjustContentInset | |||
{ |
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.
Does this handle the case where MGLMapView is nested more than 2 level deep in the UIViewController view hierarchy?
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.
It doesn’t, for consistency with UIScrollView and UIViewController.automaticallyAdjustsScrollViewInsets
. (This is already more robust than the UIScrollView behavior; a UIScrollView has to be the first subview.) Regardless, a developer can manually set the contentInset
of a deeply nested MGLMapView.
Hi @1ec5, I have a question: are you (or someone else) planning to implement this on the android side ? |
@lgeromegnace feel free to take that up, it's on my list but currently not ranked in the top tier. |
This PR implements content insets on iOS and OS X. By default, the content insets automatically adjust to account for translucent chrome (on iOS, the top and bottom bars when there’s extended layout; on OS X, the translucent toolbar of a window that has the map view as a full-window content view). However, it can be configured for any purpose, such as excluding a Google-style floating search bar from the logical viewport.
I attempted to mimic UIScrollView and NSScrollView on iOS and OS X, respectively. Therefore, there are a few minor differences in the implementations between the two platforms. Whereas the map view itself has an
automaticallyAdjustsContentInsets
property on OS X, it’s the containing view controller that feeds the map view its insets on iOS.The underlying implementation in mbgl is designed to be usable by Android as well, and eventually course tracking mode will shift the center downward so that the user dot appears towards the bottom of the view.
Following this work, the rule is that
Map
andTransform
assume a view origin at the top-left corner of the view (consistent with iOS, Android, and GLFW), whileTransformState
assumes a view origin at the bottom-left corner of the view (more convenient for converting to geographic coordinates). (OS X natively assumes an origin at the bottom-left.)CameraOptions.padding
Map::latLngForPixel()
andMap::pixelForLatLng()
(fixes [core] Map::latLngForPixel and Map::pixelForLatLng are using bottom/left coordinates #3574)Shift the center downward during course tracking mode(split out into Affix user dot on screen in user tracking mode #3589)/ref #2600, #3574
/cc @friedbunny