diff --git a/Sources/MapLibreSwiftUI/MapView.swift b/Sources/MapLibreSwiftUI/MapView.swift index 8ed40eb..7fe949e 100644 --- a/Sources/MapLibreSwiftUI/MapView.swift +++ b/Sources/MapLibreSwiftUI/MapView.swift @@ -5,7 +5,7 @@ import SwiftUI public struct MapView: UIViewControllerRepresentable { public typealias UIViewControllerType = T - var cameraDisabled: Bool = true + var cameraDisabled: Bool = false @Binding var camera: MapViewCamera @@ -18,7 +18,7 @@ public struct MapView: UIViewControllerRepresentab var onStyleLoaded: ((MLNStyle) -> Void)? var onViewPortChanged: ((MapViewPort) -> Void)? - public var mapViewContentInset: UIEdgeInsets = .zero + var mapViewContentInset: UIEdgeInsets? = .zero var unsafeMapViewControllerModifier: ((T) -> Void)? @@ -103,13 +103,16 @@ public struct MapView: UIViewControllerRepresentab if cameraDisabled == false { context.coordinator.updateCamera(mapView: uiViewController.mapView, - camera: $camera.wrappedValue, + camera: camera, animated: isStyleLoaded) } } @MainActor private func applyModifiers(_ mapViewController: T, runUnsafe: Bool) { - mapViewController.mapView.contentInset = mapViewContentInset + if let mapViewContentInset { + mapViewController.mapView.automaticallyAdjustsContentInset = false + mapViewController.mapView.contentInset = mapViewContentInset + } // Assume all controls are hidden by default (so that an empty list returns a map with no controls) mapViewController.mapView.logoView.isHidden = true