Turn-by-turn navigation logic and UI in Swift or Objective-C on iOS
Switch branches/tags
Clone or download
Latest commit e6153f6 Nov 12, 2018
Permalink
Failed to load latest commit information.
.github Eviscerate jazzy guides (#1552) Jul 12, 2018
.tx Update config Nov 9, 2018
Bench Set up second control route Nov 8, 2018
BenchTests Set up second control route Nov 8, 2018
BenchUITests Remove unused fixtures from Example Nov 8, 2018
Example Remove unused fixtures from Example Nov 8, 2018
MapboxCoreNavigation Reworded arrival rerouting check for clarity Nov 12, 2018
MapboxCoreNavigationTests Move test doubles to TestHelper framework Nov 8, 2018
MapboxNavigation.xcodeproj Fix Example-CarPlay bridging header path Nov 10, 2018
MapboxNavigation Example-Swift -> Example Nov 8, 2018
MapboxNavigationTests Fix TestHelper in MapboxNavigationTests Nov 8, 2018
TestHelper Add trace generator Nov 8, 2018
docs Revised cover document to reflect the changes to the CarPlayManager s… Oct 23, 2018
scripts Clean before generating snapshots Oct 15, 2018
.gitignore rm Jul 2, 2018
.swift-version swift 4 Nov 22, 2017
.swiftlint.yml Introduce swiftlint Jan 24, 2018
CHANGELOG.md Update CHANGELOG.md Nov 12, 2018
CONTRIBUTING.md Eviscerate jazzy guides (#1552) Jul 12, 2018
Cartfile Bump dependencies Oct 24, 2018
Cartfile.private Merge branch 'master' into carplay-merge-master Sep 16, 2018
Cartfile.resolved Bump dependencies Oct 24, 2018
Gemfile Run tests and examples on Xcode 9 and 10 on CircleCI Aug 31, 2018
LICENSE.md clarify the nav-native dependency Nov 2, 2018
MapboxCoreNavigation.podspec Releasing v0.24.0 Nov 8, 2018
MapboxNavigation-Documentation.podspec Releasing v0.24.0 Nov 8, 2018
MapboxNavigation.podspec Releasing v0.24.0 Nov 8, 2018
README.md Update README Nov 8, 2018
RELEASE.md Add post-release step to close out the milestone Nov 9, 2018
circle.yml Run bench on CI Nov 8, 2018
codecov.yml Ignore test directory Nov 8, 2018
custom-navigation.md Releasing v0.24.0 Nov 8, 2018

README.md

Mapbox Navigation SDK for iOS

CircleCI codecov Carthage compatible CocoaPods

Mapbox Navigation SDK

Mapbox 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 NavigationViewController, or build a completely custom turn-by-turn navigation app with our core components for routing and navigation.

Features

Documentation

Requirements

The Mapbox Navigation SDK and Core Navigation are compatible with applications written in Swift 4 or Objective-C in Xcode 9.0. The Mapbox Navigation and Mapbox Core Navigation frameworks run on iOS 9.0 and above.

The last release compatible with Swift 3.2 was v0.10.1.

The Mapbox Navigation SDK is also available for Android.

Installation

Using CocoaPods

To install Mapbox Navigation using CocoaPods:

  1. Create a Podfile with the following specification:

    pod 'MapboxNavigation', '~> 0.24.0'
  2. Run pod repo update && pod install and open the resulting Xcode workspace.

Using Carthage

Alternatively, to install Mapbox Navigation using Carthage:

  1. Create a Cartfile with the following dependency:

    github "mapbox/mapbox-navigation-ios" ~> 0.24
    
  2. Run carthage update --platform iOS to build just the iOS dependencies.

  3. Follow the rest of Carthage’s iOS integration instructions. Your application target’s Embedded Frameworks should include MapboxNavigation.framework, MapboxCoreNavigation.framework, and MapboxNavigationNative.framework.

Configuration

  1. Mapbox APIs and vector tiles require a Mapbox account and API access token. In the project editor, select the application target, then go to the Info tab. Under the “Custom iOS Target Properties” section, set MGLMapboxAccessToken to your access token. You can obtain an access token from the Mapbox account page.

  2. In order for the SDK to track the user’s location as they move along the route, set NSLocationWhenInUseUsageDescription to:

    Shows your location on the map and helps improve OpenStreetMap.

  3. Users expect the SDK to continue to track the user’s location and deliver audible instructions even while a different application is visible or the device is locked. Go to the Capabilities tab. Under the Background Modes section, enable “Audio, AirPlay, and Picture in Picture” and “Location updates”. (Alternatively, add the audio and location values to the UIBackgroundModes array in the Info tab.)

Now import the relevant modules and present a new NavigationViewController. You can also push to a navigation view controller from within a storyboard if your application’s UI is laid out in Interface Builder.

import MapboxDirections
import MapboxCoreNavigation
import MapboxNavigation
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")

let options = NavigationRouteOptions(waypoints: [origin, destination])

Directions.shared.calculate(options) { (waypoints, routes, error) in
    guard let route = routes?.first else { return }

    let viewController = NavigationViewController(for: route)
    present(viewController, animated: true, completion: nil)
}

Consult the API reference for further details.

Examples

The 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 Swift and Objective-C testbeds that exercise a variety of navigation SDK features:

  1. Clone the repository or download the .zip file
  2. Run carthage update --platform ios to build just the iOS dependencies.
  3. Open MapboxNavigation.xcodeproj.
  4. Sign up or log in to your Mapbox account and grab a Mapbox Access Token.
  5. Open the Info.plist in the Example target and paste your Mapbox Access Token into MGLMapboxAccessToken. (Alternatively, if you plan to use this project as the basis for a public project on GitHub, place the access token in a plain text file named .mapbox or mapbox in your home directory instead of adding it to Info.plist.)
  6. Build and run the Example target.

Customization

Styling

You can customize the appearance in order to blend in with the rest of your app. Checkout DayStyle.swift for all styleable elements.

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 NavigationViewController with your style or styles:

NavigationViewController(for: route, styles: [CustomStyle()])

Starting from scratch

If your application needs something totally custom, such as a voice-only experience or an unconventional user interface, consult the Core Navigation installation guide.

Contributing

We welcome feedback and code contributions! Please see CONTRIBUTING.md for details.

License

Mapbox Navigation SDK for iOS is released under the ISC License. See LICENSE.md for details.

Mapbox Navigation SDK uses Mapbox Navigator, a private binary, as a dependency. The Mapbox Navigator binary may be used with a Mapbox account and under the Mapbox TOS. If you do not wish to use this binary, make sure you swap out this dependency in ./Cartfile. Code in this repo falls under the MIT license.