在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:mapbox/mapbox-navigation-ios开源软件地址:https://github.com/mapbox/mapbox-navigation-ios开源编程语言:Swift 99.1%开源软件介绍:Mapbox Navigation SDK for iOSMapbox Navigation gives you all the tools you need to add turn-by-turn navigation to your iOS application. Get up and running in a few minutes with our drop-in turn-by-turn navigation Features
DocumentationRequirementsThe Mapbox Navigation SDK and Core Navigation are compatible with applications written in Swift 5 in Xcode 12.4 and above. The Mapbox Navigation and Mapbox Core Navigation frameworks run on iOS 11.0 and above. The Mapbox Navigation SDK is also available for Android. InstallationUsing Swift Package ManagerTo install the MapboxNavigation framework in an application using Swift Package Manager:
To install the MapboxNavigation framework in another package rather than an application, run // Latest stable release
.package(name: "MapboxNavigation", url: "https://github.com/mapbox/mapbox-navigation-ios.git", from: "2.5.0")
// Latest prerelease
.package(name: "MapboxNavigation", url: "https://github.com/mapbox/mapbox-navigation-ios.git", .exact("2.6.0-beta.2")) Using CocoaPodsTo install the MapboxNavigation framework using CocoaPods:
Using CarthageTo install the MapboxNavigation framework using Carthage v0.38 or above:
MapboxNavigation no longer supports Carthage as of v2.0.0-alpha.1. However, if you are building a user interface from scratch, you can install just the MapboxCoreNavigation framework using Carthage. Configuration
Now import the relevant modules and present a new import MapboxDirections
import MapboxCoreNavigation
import MapboxNavigation // Define two waypoints to travel between
let origin = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 38.9131752, longitude: -77.0324047), name: "Mapbox")
let destination = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 38.8977, longitude: -77.0365), name: "White House")
// Set options
let routeOptions = NavigationRouteOptions(waypoints: [origin, destination])
// Request a route using MapboxDirections
Directions.shared.calculate(routeOptions) { [weak self] (session, result) in
switch result {
case .failure(let error):
print(error.localizedDescription)
case .success(let response):
guard let strongSelf = self else {
return
}
// Pass the generated route response to the the NavigationViewController
let viewController = NavigationViewController(for: response, routeIndex: 0, routeOptions: routeOptions)
viewController.modalPresentationStyle = .fullScreen
strongSelf.present(viewController, animated: true, completion: nil)
}
} Consult the API reference for further details. ExamplesThe API reference includes example code for accomplishing common tasks. You can run these examples as part of the navigation-ios-examples project. This repository also contains a testbed application that exercises a variety of navigation SDK features. See the contributing guide for instructions on installing and running this application. CustomizationStylingYou can customize the appearance in order to blend in with the rest of your app. Checkout class CustomStyle: DayStyle {
required init() {
super.init()
mapStyleURL = URL(string: "mapbox://styles/mapbox/satellite-streets-v9")!
styleType = .nightStyle
}
override func apply() {
super.apply()
BottomBannerView.appearance().backgroundColor = .orange
}
} then initialize let navigationOptions = NavigationOptions(styles: [CustomStyle()])
NavigationViewController(for: routeResponse, routeIndex: routeIndex, routeOptions: routeOptions, navigationOptions: navigationOptions) Starting from scratchIf your application needs something totally custom, such as a voice-only experience or an unconventional user interface, consult the Core Navigation installation guide. ContributingWe welcome feedback and code contributions! Please see CONTRIBUTING.md for details. LicenseThe Mapbox Navigation SDK for iOS is released under the Mapbox Terms of Service. See LICENSE.md for details. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论