-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from Rallista/feat/map-view-port
MapViewPort implementation to listen to raw values of 'camera'
- Loading branch information
Showing
5 changed files
with
77 additions
and
2 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
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
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
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,41 @@ | ||
import CoreLocation | ||
import Foundation | ||
|
||
/// A representation of the MapView's current ViewPort. | ||
/// | ||
/// This includes similar data to the MapViewCamera, but represents the raw | ||
/// values associated with the MapView. This information could used to prepare | ||
/// a new MapViewCamera on a scene, to cache the camera state, etc. | ||
public struct MapViewPort: Hashable, Equatable { | ||
/// The current center coordinate of the MapView | ||
public let center: CLLocationCoordinate2D | ||
|
||
/// The current zoom value of the MapView | ||
public let zoom: Double | ||
|
||
/// The current compass direction of the MapView | ||
public let direction: CLLocationDirection | ||
|
||
public init(center: CLLocationCoordinate2D, zoom: Double, direction: CLLocationDirection) { | ||
self.center = center | ||
self.zoom = zoom | ||
self.direction = direction | ||
} | ||
|
||
public static func zero(zoom: Double = 10) -> MapViewPort { | ||
MapViewPort(center: CLLocationCoordinate2D(latitude: 0, longitude: 0), | ||
zoom: zoom, | ||
direction: 0) | ||
} | ||
} | ||
|
||
public extension MapViewPort { | ||
/// Generate a basic MapViewCamera that represents the MapViewPort | ||
/// | ||
/// - Returns: The calculated MapViewCamera | ||
func asMapViewCamera() -> MapViewCamera { | ||
.center(center, | ||
zoom: zoom, | ||
direction: direction) | ||
} | ||
} |
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