-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
649a68c
commit 4053e51
Showing
16 changed files
with
157 additions
and
53 deletions.
There are no files selected for viewing
File renamed without changes.
30 changes: 30 additions & 0 deletions
30
apple/Sources/FerrostarMapLibreUI/Extensions/NavigationState.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,30 @@ | ||
import FerrostarCore | ||
import MapLibre | ||
import MapLibreSwiftUI | ||
|
||
extension NavigationState { | ||
var routeOverviewCamera: MapViewCamera? { | ||
guard let firstCoordinate = routeGeometry.first else { | ||
return nil | ||
} | ||
|
||
let initial = MLNCoordinateBounds( | ||
sw: firstCoordinate.clLocationCoordinate2D, | ||
ne: firstCoordinate.clLocationCoordinate2D | ||
) | ||
let bounds = routeGeometry.reduce(initial) { acc, coord in | ||
MLNCoordinateBounds( | ||
sw: CLLocationCoordinate2D(latitude: min(acc.sw.latitude, coord.lat), longitude: min( | ||
acc.sw.longitude, | ||
coord.lng | ||
)), | ||
ne: CLLocationCoordinate2D( | ||
latitude: max(acc.ne.latitude, coord.lat), | ||
longitude: max(acc.ne.longitude, coord.lng) | ||
) | ||
) | ||
} | ||
|
||
return MapViewCamera.boundingBox(bounds, edgePadding: UIEdgeInsets(top: 20, left: 100, bottom: 20, right: 100)) | ||
} | ||
} |
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
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
Oops, something went wrong.