forked from maplibre/swiftui-dsl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revisions for camera behavior, added basic gesture methods, separated…
… out core MapView
- Loading branch information
Showing
12 changed files
with
548 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Sources/MapLibreSwiftUI/Extensions/CoreLocation/CLLocationCoordinate2D.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import CoreLocation | ||
|
||
// TODO: We can delete chat about this. I'm not 100% on it, even though I want Hashable | ||
// on the MapCameraView (so we can let a user present a MapView with a designated camera from NavigationLink) | ||
extension CLLocationCoordinate2D: Hashable { | ||
public static func == (lhs: CLLocationCoordinate2D, rhs: CLLocationCoordinate2D) -> Bool { | ||
return lhs.latitude == rhs.latitude | ||
&& lhs.longitude == rhs.longitude | ||
} | ||
|
||
public func hash(into hasher: inout Hasher) { | ||
hasher.combine(latitude) | ||
hasher.combine(longitude) | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
Sources/MapLibreSwiftUI/Extensions/MapLibre/MLNCameraChangeReason.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import Foundation | ||
import MapLibre | ||
|
||
extension MLNCameraChangeReason: CustomDebugStringConvertible { | ||
public var debugDescription: String { | ||
switch self.lastValue { | ||
|
||
case .programmatic: return ".programmatic" | ||
case .resetNorth: return ".resetNorth" | ||
case .gesturePan: return ".gesturePan" | ||
case .gesturePinch: return ".gesturePinch" | ||
case .gestureRotate: return ".gestureRotate" | ||
case .gestureZoomIn: return ".gestureZoomIn" | ||
case .gestureZoomOut: return ".gestureZoomOut" | ||
case .gestureOneFingerZoom: return ".gestureOneFingerZoom" | ||
case .gestureTilt: return ".gestureTilt" | ||
case .transitionCancelled: return ".transitionCancelled" | ||
default: return "none" | ||
} | ||
} | ||
|
||
/// Get the last value from the MLNCameraChangeReason option set. | ||
public var lastValue: MLNCameraChangeReason { | ||
// Start at 1 | ||
var mask: UInt = 1 | ||
var result: UInt = 0 | ||
|
||
while mask <= self.rawValue { | ||
// If the raw value matches the remaining mask. | ||
if self.rawValue & mask != 0 { | ||
result = mask | ||
} | ||
// Shift all the way until the rawValue has been allocated and we have the true last value. | ||
mask <<= 1 | ||
} | ||
|
||
return MLNCameraChangeReason(rawValue: result) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.