All Projects → mapbox → Mapbox Navigation Ios

mapbox / Mapbox Navigation Ios

Licence: other
Turn-by-turn navigation logic and UI in Swift on iOS

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Mapbox Navigation Ios

gito
⚡ git helper tool to clone/open/auto-install/edit with a one-liner
Stars: ✭ 26 (-96.16%)
Mutual labels:  carthage, swift-package-manager
Web3.swift
A pure swift Ethereum Web3 library
Stars: ✭ 295 (-56.43%)
Mutual labels:  carthage, swift-package-manager
Swiftytexttable
A lightweight library for generating text tables.
Stars: ✭ 252 (-62.78%)
Mutual labels:  carthage, swift-package-manager
VisualDebugger
The most elegant and easiest way to visual you data in playground
Stars: ✭ 22 (-96.75%)
Mutual labels:  carthage, swift-package-manager
Guitar
A Cross-Platform String and Regular Expression Library written in Swift.
Stars: ✭ 641 (-5.32%)
Mutual labels:  carthage, swift-package-manager
Hippolyte
HTTP Stubbing in Swift
Stars: ✭ 109 (-83.9%)
Mutual labels:  carthage, swift-package-manager
Stepperview
SwiftUI iOS component for Step Indications.
Stars: ✭ 281 (-58.49%)
Mutual labels:  carthage, swift-package-manager
SwiftFCXRefresh
Pull to refresh in Swift.
Stars: ✭ 29 (-95.72%)
Mutual labels:  carthage, swift-package-manager
Keyboardshortcuts
Add user-customizable global keyboard shortcuts to your macOS app in minutes
Stars: ✭ 500 (-26.14%)
Mutual labels:  carthage, swift-package-manager
Tweetextfield
Lightweight set of text fields with nice animation and functionality. 🚀 Inspired by https://uimovement.com/ui/2524/input-field-help/
Stars: ✭ 421 (-37.81%)
Mutual labels:  carthage, swift-package-manager
BetterMappable
Better Mappable through Property Wrappers using ObjectMapper
Stars: ✭ 26 (-96.16%)
Mutual labels:  carthage, swift-package-manager
Swiftframeworktemplate
A template for new Swift iOS / macOS / tvOS / watchOS Framework project ready with travis-ci, cocoapods, Carthage, SwiftPM and a Readme file
Stars: ✭ 527 (-22.16%)
Mutual labels:  carthage, swift-package-manager
SwiftGradients
Useful extensions for UIViews and CALayer classes to add beautiful color gradients.
Stars: ✭ 15 (-97.78%)
Mutual labels:  carthage, swift-package-manager
EllipticCurve
An elliptic curve library written in Swift 4
Stars: ✭ 18 (-97.34%)
Mutual labels:  carthage, swift-package-manager
Mechanica
A cross-platform library of Swift utils to ease your iOS | macOS | watchOS | tvOS and Linux development.
Stars: ✭ 27 (-96.01%)
Mutual labels:  carthage, swift-package-manager
Corestore
Unleashing the real power of Core Data with the elegance and safety of Swift
Stars: ✭ 3,254 (+380.65%)
Mutual labels:  carthage, swift-package-manager
Dots
Lightweight Concurrent Networking Framework
Stars: ✭ 35 (-94.83%)
Mutual labels:  carthage, swift-package-manager
Sqlable
Swift library for making storing data in a SQLite database simple and magic-free
Stars: ✭ 83 (-87.74%)
Mutual labels:  carthage, swift-package-manager
Functionkit
A framework for functional types and operations designed to fit naturally into Swift.
Stars: ✭ 302 (-55.39%)
Mutual labels:  carthage, swift-package-manager
Openssl
OpenSSL package for SPM, CocoaPod, and Carthage, for iOS and macOS
Stars: ✭ 515 (-23.93%)
Mutual labels:  carthage, swift-package-manager

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 5 in Xcode 11.4.1 and above. The Mapbox Navigation and Mapbox Core Navigation frameworks run on iOS 10.0 and above.

The Mapbox Navigation SDK is also available for Android.

Installation

Using CocoaPods

To install Mapbox Navigation using CocoaPods:

  1. Go to your Mapbox account dashboard and create an access token that has the DOWNLOADS:READ scope. PLEASE NOTE: This is not the same as your production Mapbox API token. Make sure to keep it private and do not insert it into any Info.plist file. Create a file named .netrc in your home directory if it doesn’t already exist, then add the following lines to the end of the file:

    machine api.mapbox.com 
      login mapbox
      password PRIVATE_MAPBOX_API_TOKEN
    

    where PRIVATE_MAPBOX_API_TOKEN is your Mapbox API token with the DOWNLOADS:READ scope.

  2. Create a Podfile with the following specification:

    # Latest stable release
    pod 'MapboxNavigation', '~> 1.3'
    # Latest prerelease
    pod 'MapboxCoreNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :tag => 'v1.3.0-beta.1'
    pod 'MapboxNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :tag => 'v1.3.0-beta.1'
    # Latest prerelease
    pod 'MapboxCoreNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :tag => 'v2.0.0-beta.1'
    pod 'MapboxNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :tag => 'v2.0.0-beta.1'
    
  3. Run pod repo update && pod install and open the resulting Xcode workspace.

Using Carthage

To install Mapbox Navigation using Carthage v0.35 or above:

  1. Go to your Mapbox account dashboard and create an access token that has the DOWNLOADS:READ scope. PLEASE NOTE: This is not the same as your production Mapbox API token. Make sure to keep it private and do not insert it into any Info.plist file. Create a file named .netrc in your home directory if it doesn’t already exist, then add the following lines to the end of the file:

    machine api.mapbox.com
      login mapbox
      password PRIVATE_MAPBOX_API_TOKEN
    

    where PRIVATE_MAPBOX_API_TOKEN is your Mapbox API token with the DOWNLOADS:READ scope.

  2. (Optional) Clear your Carthage caches:

    rm -rf ~/Library/Caches/carthage/ ~/Library/Caches/org.carthage.CarthageKit/binaries/{MapboxAccounts,MapboxCommon-ios,MapboxNavigationNative,mapbox-ios-sdk-dynamic}
    
  3. Create a Cartfile with the following dependency:

    # Latest stable release
    github "mapbox/mapbox-navigation-ios" ~> 1.3
    # Latest prerelease
    github "mapbox/mapbox-navigation-ios" "v1.3.0-beta.1"
    
  4. Run ./Carthage/Checkouts/mapbox-navigation-ios/scripts/wcarthage.sh bootstrap --platform iOS --cache-builds --use-netrc. (wcarthage.sh is a temporary replacement for carthage to work around a linker error in Xcode 12.)

  5. Follow the rest of Carthage’s iOS integration instructions. Your application target’s Embed Frameworks build phase should include MapboxNavigation.framework, MapboxCoreNavigation.framework, MapboxNavigationNative.framework, MapboxCommon.framework, and MapboxAccounts.framework.

Using Swift Package Manager

The MapboxNavigation framework does not yet support Swift Package Manager either on the command line or in Xcode. However, if you are building a user interface from scratch, you can install just the MapboxCoreNavigation framework using SPM.

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 the map.

  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 Signing & 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
// 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 route = response.routes?.first, let strongSelf = self else {
            return
        }
        // Pass the generated route to the the NavigationViewController
        let viewController = NavigationViewController(for: route, routeIndex: 0, routeOptions: routeOptions)
        viewController.modalPresentationStyle = .fullScreen
        strongSelf.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 a testbed that exercises a variety of navigation SDK features:

  1. Clone the repository or download the .zip file
  2. Run carthage update --platform ios --use-netrc 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:

let navigationOptions = NavigationOptions(styles: [CustomStyle()])
NavigationViewController(for: route, routeOptions: routeOptions, navigationOptions: navigationOptions)

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

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

The Mapbox Navigation SDK for iOS depends on private binary distributions of the Mapbox Maps SDK for iOS and MapboxNavigationNative. These binaries may be used with a Mapbox account and under the Mapbox Terms of Service. If you do not wish to use these binaries, make sure you swap out these dependencies in the Cartfile or override them in your Podfile.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].