-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import Foundation | ||
|
||
extension MapViewCamera { | ||
|
||
// MARK: Zoom | ||
|
||
/// Set a new zoom for the current camera state. | ||
/// | ||
/// - Parameter newZoom: The new zoom value. | ||
public mutating func setZoom(_ newZoom: Double) { | ||
switch self.state { | ||
case .centered(let onCoordinate, _, let pitch, let direction): | ||
self.state = .centered(onCoordinate: onCoordinate, | ||
zoom: newZoom, | ||
pitch: pitch, | ||
direction: direction) | ||
case .trackingUserLocation(_, let pitch, let direction): | ||
self.state = .trackingUserLocation(zoom: newZoom, pitch: pitch, direction: direction) | ||
case .trackingUserLocationWithHeading(_, let pitch): | ||
self.state = .trackingUserLocationWithHeading(zoom: newZoom, pitch: pitch) | ||
case .trackingUserLocationWithCourse(_, let pitch): | ||
self.state = .trackingUserLocationWithCourse(zoom: newZoom, pitch: pitch) | ||
case .rect(let boundingBox, let edgePadding): | ||
Check warning on line 23 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)
Check warning on line 23 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)
|
||
return | ||
case .showcase(let shapeCollection): | ||
Check warning on line 25 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)
|
||
return | ||
} | ||
|
||
self.lastReasonForChange = .programmatic | ||
} | ||
|
||
/// Increment the zoom of the current camera state. | ||
/// | ||
/// - Parameter newZoom: The value to increment the zoom by. Negative decrements the value. | ||
public mutating func incrementZoom(by increment: Double) { | ||
switch self.state { | ||
case .centered(let onCoordinate, let zoom, let pitch, let direction): | ||
self.state = .centered(onCoordinate: onCoordinate, | ||
zoom: zoom + increment, | ||
pitch: pitch, | ||
direction: direction) | ||
case .trackingUserLocation(let zoom, let pitch, let direction): | ||
self.state = .trackingUserLocation(zoom: zoom + increment, pitch: pitch, direction: direction) | ||
case .trackingUserLocationWithHeading(let zoom, let pitch): | ||
self.state = .trackingUserLocationWithHeading(zoom: zoom + increment, pitch: pitch) | ||
case .trackingUserLocationWithCourse(let zoom, let pitch): | ||
self.state = .trackingUserLocationWithCourse(zoom: zoom + increment, pitch: pitch) | ||
case .rect(let boundingBox, let edgePadding): | ||
Check warning on line 48 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)
Check warning on line 48 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)
|
||
return | ||
case .showcase(let shapeCollection): | ||
Check warning on line 50 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)
|
||
return | ||
} | ||
|
||
self.lastReasonForChange = .programmatic | ||
} | ||
|
||
// MARK: Pitch | ||
|
||
/// Set a new pitch for the current camera state. | ||
/// | ||
/// - Parameter newPitch: The new pitch value. | ||
public mutating func setPitch(_ newPitch: CameraPitch) { | ||
switch self.state { | ||
case .centered(let onCoordinate, let zoom, let pitch, let direction): | ||
Check warning on line 64 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)
|
||
self.state = .centered(onCoordinate: onCoordinate, | ||
zoom: zoom, | ||
pitch: newPitch, | ||
direction: direction) | ||
case .trackingUserLocation(let zoom, _, let direction): | ||
self.state = .trackingUserLocation(zoom: zoom, pitch: newPitch, direction: direction) | ||
case .trackingUserLocationWithHeading(let zoom, _): | ||
self.state = .trackingUserLocationWithHeading(zoom: zoom, pitch: newPitch) | ||
case .trackingUserLocationWithCourse(let zoom, _): | ||
self.state = .trackingUserLocationWithCourse(zoom: zoom, pitch: newPitch) | ||
case .rect(let boundingBox, let edgePadding): | ||
Check warning on line 75 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)
Check warning on line 75 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)
|
||
return | ||
case .showcase(let shapeCollection): | ||
Check warning on line 77 in Sources/MapLibreSwiftUI/Extensions/MapViewCamera/MapViewCameraOperations.swift GitHub Actions / test (MapLibreSwiftUI-Package, platform=iOS Simulator,name=iPhone 15,OS=17.2)
|
||
return | ||
} | ||
|
||
self.lastReasonForChange = .programmatic | ||
} | ||
|
||
// TODO: Add direction set | ||
|
||
} |