Skip to content

Commit 02f5a62

Browse files
authored
Merge pull request maplibre#43 from stadiamaps/fix-camera-binding-issues
Fix camera binding issues
2 parents e958f2e + 1e6f079 commit 02f5a62

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Sources/MapLibreSwiftUI/MapView.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import SwiftUI
55

66
public struct MapView<T: MapViewHostViewController>: UIViewControllerRepresentable {
77
public typealias UIViewControllerType = T
8-
var cameraDisabled: Bool = true
8+
var cameraDisabled: Bool = false
99

1010
@Binding var camera: MapViewCamera
1111

@@ -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)