一个 Swift 包,可以轻松地在 MKMapView 上执行飞行操作。
import SwiftUI
import FlyoverKit
struct ContentView: View {
var body: some View {
FlyoverMap(
latitude: 37.3348,
longitude: -122.0090
)
}
}
要使用 Apple 的 Swift Package Manager 集成,请将以下内容作为依赖项添加到您的 Package.swift
中
dependencies: [
.package(url: "https://github.com/SvenTiigi/FlyoverKit.git", from: "2.0.0")
]
或者导航到您的 Xcode 项目,然后选择 Swift Packages
,点击“+”图标并搜索 FlyoverKit
。
查看示例应用程序以了解 FlyoverKit 的实际应用。只需打开 Example/Example.xcodeproj
并运行“Example” scheme。
使用 SwiftUI 时,可以使用 FlyoverMap
来渲染和控制飞行。
var body: some View {
FlyoverMap(
// Bool value if flyover is started or stopped
isStarted: true,
// The coordinate to perform the flyover on
coordinate: CLLocationCoordinate2D(
latitude: 37.8023,
longitude: -122.4057
),
configuration: Flyover.Configuration(
// The animation curve
animationCurve: .linear,
// The altitude in meter
altitude: 900,
// The pitch in degree
pitch: 45.0,
// The heading
heading: .incremented(by: 1.5)
),
// The map type e.g. .standard, .satellite, .hybrid
mapType: .standard
)
}
let flyoverMapView = FlyoverMapView()
if flyoverMapView.isFlyoverStarted {
// ...
}
flyoverMapView.startFlyover(
at: CLLocationCoordinate2D(
latitude: 37.8023,
longitude: -122.4057
),
configuration: .default
)
flyoverMapView.stopFlyover()
flyoverMapView.resumeFlyover()
Flyover
对象代表在 MKMapView
实例上启动、停止和恢复飞行的核心对象。
let flyover = Flyover(
mapView: self.mapView
)
注意:提供的 MKMapView 始终被弱引用
FlyoverKit
Copyright (c) 2022 Sven Tiigi sven.tiigi@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.