Skip to content

Commit

Permalink
Revert animated property to false
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthetechie committed Mar 13, 2024
1 parent 96919e4 commit cb3af3f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Sources/MapLibreSwiftUI/Examples/User Location.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down
9 changes: 6 additions & 3 deletions Sources/MapLibreSwiftUI/MapViewCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit cb3af3f

Please sign in to comment.