Skip to content

Commit

Permalink
Added testing for many of the swiftui mapview behaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
Archdoog committed Feb 8, 2024
1 parent a076c35 commit a96821f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Sources/MapLibreSwiftUI/MapViewCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,13 @@ extension MapViewCoordinator: MLNMapViewDelegate {

// If any of these are a mismatch, we know the camera is no longer following a desired method, so we should detach and revert
// to a .centered camera.
// If any one of these is true, the desired camera state still matches the mapView's userTrackingMode
if isFollowing || isFollowingHeading || isFollowingCourse {
// User tracking, we can ignore camera updates until we unset this.
// User tracking is still active, we can ignore camera updates until we unset/fail this boolean check
return
}

// The user's desired camera is not a user tracking method, now we need to publish back the current mapView state to the camera binding.
// The user's desired camera is not a user tracking method, now we need to publish the MLNMapView's camera state to the MapView camera binding.
parent.camera = .center(mapView.centerCoordinate,
zoom: mapView.zoomLevel,
reason: CameraChangeReason(reason))
Expand Down
3 changes: 3 additions & 0 deletions Sources/MapLibreSwiftUI/Models/MapCamera/CameraState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ public enum CameraState: Hashable {
case centered(onCenter: CLLocationCoordinate2D)

/// Follow the user's location using the MapView's internal camera.
///
/// This feature uses the MLNMapView's userTrackingMode to .follow which automatically
/// follows the user from within the MLNMapView.
case trackingUserLocation

/// Follow the user's location using the MapView's internal camera with the user's heading.
Expand Down

0 comments on commit a96821f

Please sign in to comment.