Skip to content

Commit 1e6f079

Browse files
committed
Flip automaticallyAdjustsContentInset to avoid contentInsets edit war
1 parent 5135853 commit 1e6f079

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Sources/MapLibreSwiftUI/MapView.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public struct MapView<T: MapViewHostViewController>: UIViewControllerRepresentab
1818
var onStyleLoaded: ((MLNStyle) -> Void)?
1919
var onViewPortChanged: ((MapViewPort) -> Void)?
2020

21-
public var mapViewContentInset: UIEdgeInsets = .zero
21+
var mapViewContentInset: UIEdgeInsets? = .zero
2222

2323
var unsafeMapViewControllerModifier: ((T) -> Void)?
2424

@@ -103,13 +103,16 @@ public struct MapView<T: MapViewHostViewController>: UIViewControllerRepresentab
103103

104104
if cameraDisabled == false {
105105
context.coordinator.updateCamera(mapView: uiViewController.mapView,
106-
camera: $camera.wrappedValue,
106+
camera: camera,
107107
animated: isStyleLoaded)
108108
}
109109
}
110110

111111
@MainActor private func applyModifiers(_ mapViewController: T, runUnsafe: Bool) {
112-
mapViewController.mapView.contentInset = mapViewContentInset
112+
if let mapViewContentInset {
113+
mapViewController.mapView.automaticallyAdjustsContentInset = false
114+
mapViewController.mapView.contentInset = mapViewContentInset
115+
}
113116

114117
// Assume all controls are hidden by default (so that an empty list returns a map with no controls)
115118
mapViewController.mapView.logoView.isHidden = true

0 commit comments

Comments
 (0)