diff --git a/Sources/MapLibreSwiftUI/Examples/User Location.swift b/Sources/MapLibreSwiftUI/Examples/User Location.swift index 68b28c8..aeaa838 100644 --- a/Sources/MapLibreSwiftUI/Examples/User Location.swift +++ b/Sources/MapLibreSwiftUI/Examples/User Location.swift @@ -14,7 +14,7 @@ private let locationManager = StaticLocationManager(initialLocation: CLLocation( #Preview("Track user location") { MapView( styleURL: demoTilesURL, - camera: .constant(.trackUserLocation(zoom: 8, pitch: .fixed(45))), + camera: .constant(.trackUserLocation(zoom: 4, pitch: .fixed(45))), locationManager: locationManager ) .mapViewContentInset(.init(top: 450, left: 0, bottom: 0, right: 0)) @@ -24,7 +24,7 @@ private let locationManager = StaticLocationManager(initialLocation: CLLocation( #Preview("Track user location with Course") { MapView( styleURL: demoTilesURL, - camera: .constant(.trackUserLocationWithCourse(zoom: 8, pitch: .fixed(45))), + camera: .constant(.trackUserLocationWithCourse(zoom: 4, pitch: .fixed(45))), locationManager: locationManager ) .mapViewContentInset(.init(top: 450, left: 0, bottom: 0, right: 0)) diff --git a/Sources/MapLibreSwiftUI/MapViewCoordinator.swift b/Sources/MapLibreSwiftUI/MapViewCoordinator.swift index 5259f0a..3ced014 100644 --- a/Sources/MapLibreSwiftUI/MapViewCoordinator.swift +++ b/Sources/MapLibreSwiftUI/MapViewCoordinator.swift @@ -58,17 +58,20 @@ public class MapViewCoordinator: NSObject { mapView.maximumPitch = pitch.rangeValue.upperBound case let .trackingUserLocation(zoom: zoom, pitch: pitch): mapView.userTrackingMode = .follow - mapView.setZoomLevel(zoom, animated: animated) + // Needs to be non-animated or else it messes up following + mapView.setZoomLevel(zoom, animated: false) mapView.minimumPitch = pitch.rangeValue.lowerBound mapView.maximumPitch = pitch.rangeValue.upperBound case let .trackingUserLocationWithHeading(zoom: zoom, pitch: pitch): mapView.userTrackingMode = .followWithHeading - mapView.setZoomLevel(zoom, animated: animated) + // Needs to be non-animated or else it messes up following + mapView.setZoomLevel(zoom, animated: false) mapView.minimumPitch = pitch.rangeValue.lowerBound mapView.maximumPitch = pitch.rangeValue.upperBound case let .trackingUserLocationWithCourse(zoom: zoom, pitch: pitch): mapView.userTrackingMode = .followWithCourse - mapView.setZoomLevel(zoom, animated: animated) + // Needs to be non-animated or else it messes up following + mapView.setZoomLevel(zoom, animated: false) mapView.minimumPitch = pitch.rangeValue.lowerBound mapView.maximumPitch = pitch.rangeValue.upperBound case let .rect(boundingBox, padding):