Reported center coordinate of MKMapView is 8pt off the visual center - why?
up vote
0
down vote
favorite
I have an MKMapView
taking up the entire screen above the tab-bar.
On top of the map, I have added another overlay UIView
which draws a dot in the center of the view. The constraints of the overlay are set to match the top, bottom, leading and trailing anchors of the map view.
But when I move the map view around, the reported center position of the map view is not the position below the dot in the center of the overlay.
To make it align, I have to apply -8 pt constant to the top and bottom constraints.
I tried looking into margins, insets etc of the map view but found nothing that looked like the number 8 on the Y axis.
let overlayYoffset: CGFloat = -8
NSLayoutConstraint.activate([
view.overlayView.topAnchor.constraint(equalTo: mapView.topAnchor, constant: overlayYoffset),
view.overlayView.bottomAnchor.constraint(equalTo: mapView.bottomAnchor, constant: overlayYoffset),
Debugging the view hierarchy also shows that the overlay view and the map view has the same size and positions on top of each other.
So what is causing this issue? Have I overlooked anything, or is it "by design" that the MKMapview
is not showing its centerCoordinate
in the exact center of its view?
ios autolayout uikit mapkit nslayoutconstraint
add a comment |
up vote
0
down vote
favorite
I have an MKMapView
taking up the entire screen above the tab-bar.
On top of the map, I have added another overlay UIView
which draws a dot in the center of the view. The constraints of the overlay are set to match the top, bottom, leading and trailing anchors of the map view.
But when I move the map view around, the reported center position of the map view is not the position below the dot in the center of the overlay.
To make it align, I have to apply -8 pt constant to the top and bottom constraints.
I tried looking into margins, insets etc of the map view but found nothing that looked like the number 8 on the Y axis.
let overlayYoffset: CGFloat = -8
NSLayoutConstraint.activate([
view.overlayView.topAnchor.constraint(equalTo: mapView.topAnchor, constant: overlayYoffset),
view.overlayView.bottomAnchor.constraint(equalTo: mapView.bottomAnchor, constant: overlayYoffset),
Debugging the view hierarchy also shows that the overlay view and the map view has the same size and positions on top of each other.
So what is causing this issue? Have I overlooked anything, or is it "by design" that the MKMapview
is not showing its centerCoordinate
in the exact center of its view?
ios autolayout uikit mapkit nslayoutconstraint
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have an MKMapView
taking up the entire screen above the tab-bar.
On top of the map, I have added another overlay UIView
which draws a dot in the center of the view. The constraints of the overlay are set to match the top, bottom, leading and trailing anchors of the map view.
But when I move the map view around, the reported center position of the map view is not the position below the dot in the center of the overlay.
To make it align, I have to apply -8 pt constant to the top and bottom constraints.
I tried looking into margins, insets etc of the map view but found nothing that looked like the number 8 on the Y axis.
let overlayYoffset: CGFloat = -8
NSLayoutConstraint.activate([
view.overlayView.topAnchor.constraint(equalTo: mapView.topAnchor, constant: overlayYoffset),
view.overlayView.bottomAnchor.constraint(equalTo: mapView.bottomAnchor, constant: overlayYoffset),
Debugging the view hierarchy also shows that the overlay view and the map view has the same size and positions on top of each other.
So what is causing this issue? Have I overlooked anything, or is it "by design" that the MKMapview
is not showing its centerCoordinate
in the exact center of its view?
ios autolayout uikit mapkit nslayoutconstraint
I have an MKMapView
taking up the entire screen above the tab-bar.
On top of the map, I have added another overlay UIView
which draws a dot in the center of the view. The constraints of the overlay are set to match the top, bottom, leading and trailing anchors of the map view.
But when I move the map view around, the reported center position of the map view is not the position below the dot in the center of the overlay.
To make it align, I have to apply -8 pt constant to the top and bottom constraints.
I tried looking into margins, insets etc of the map view but found nothing that looked like the number 8 on the Y axis.
let overlayYoffset: CGFloat = -8
NSLayoutConstraint.activate([
view.overlayView.topAnchor.constraint(equalTo: mapView.topAnchor, constant: overlayYoffset),
view.overlayView.bottomAnchor.constraint(equalTo: mapView.bottomAnchor, constant: overlayYoffset),
Debugging the view hierarchy also shows that the overlay view and the map view has the same size and positions on top of each other.
So what is causing this issue? Have I overlooked anything, or is it "by design" that the MKMapview
is not showing its centerCoordinate
in the exact center of its view?
ios autolayout uikit mapkit nslayoutconstraint
ios autolayout uikit mapkit nslayoutconstraint
edited 15 hours ago
asked 15 hours ago
Esben von Buchwald
386213
386213
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Regarding top you may need +8 instead of -8
view.overlayView.topAnchor.constraint(equalTo: mapView.topAnchor, constant: -1 * overlayYoffset)
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Regarding top you may need +8 instead of -8
view.overlayView.topAnchor.constraint(equalTo: mapView.topAnchor, constant: -1 * overlayYoffset)
add a comment |
up vote
0
down vote
Regarding top you may need +8 instead of -8
view.overlayView.topAnchor.constraint(equalTo: mapView.topAnchor, constant: -1 * overlayYoffset)
add a comment |
up vote
0
down vote
up vote
0
down vote
Regarding top you may need +8 instead of -8
view.overlayView.topAnchor.constraint(equalTo: mapView.topAnchor, constant: -1 * overlayYoffset)
Regarding top you may need +8 instead of -8
view.overlayView.topAnchor.constraint(equalTo: mapView.topAnchor, constant: -1 * overlayYoffset)
answered 15 hours ago
Sh_Khan
33.4k41124
33.4k41124
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265975%2freported-center-coordinate-of-mkmapview-is-8pt-off-the-visual-center-why%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password