Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving Camera Conversion #54

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Sources/MapLibreSwiftUI/MapViewCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,20 @@ public class MapViewCoordinator<T: MapViewHostViewController>: NSObject, MLNMapV
// Publish the MLNMapView's "raw" camera state to the MapView camera binding.
// This path only executes when the map view diverges from the parent state, so this is a "matter of fact"
// state propagation.

// Determine camera pitch range based on current MapView settings
let pitchRange: CameraPitchRange = if mapView.minimumPitch == 0 && mapView.maximumPitch > 59.9 {
.free
} else if mapView.minimumPitch == mapView.maximumPitch {
.fixed(mapView.minimumPitch)
} else {
.freeWithinRange(minimum: mapView.minimumPitch, maximum: mapView.maximumPitch)
}

let newCamera: MapViewCamera = .center(mapView.centerCoordinate,
zoom: mapView.zoomLevel,
pitch: mapView.camera.pitch,
pitchRange: .freeWithinRange(
minimum: mapView.minimumPitch,
maximum: mapView.maximumPitch
),
pitchRange: pitchRange,
direction: mapView.direction,
reason: CameraChangeReason(reason))
snapshotCamera = newCamera
Expand Down
Loading