Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kiliankoe/Karte
🗺 Conveniently launch directions in other iOS apps
https://github.com/kiliankoe/Karte
action-sheet apple-maps cocoapod navigation navigation-apps transport url-scheme url-schemes
Last synced: 6 days ago
JSON representation
🗺 Conveniently launch directions in other iOS apps
- Host: GitHub
- URL: https://github.com/kiliankoe/Karte
- Owner: kiliankoe
- License: mit
- Created: 2017-04-13T08:26:01.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-02-01T10:27:31.000Z (10 months ago)
- Last Synced: 2024-10-31T19:05:15.942Z (12 days ago)
- Topics: action-sheet, apple-maps, cocoapod, navigation, navigation-apps, transport, url-scheme, url-schemes
- Language: Swift
- Homepage:
- Size: 188 KB
- Stars: 109
- Watchers: 4
- Forks: 13
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Karte
[![Travis](https://img.shields.io/travis/kiliankoe/Karte.svg?style=flat-square)](https://travis-ci.org/kiliankoe/Karte)
[![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/kiliankoe/karte?style=flat-square)](https://github.com/kiliankoe/Karte/releases)Small library for opening a location or route in other popular iOS navigation apps.
Currently supported are **Apple Maps, Google Maps, Citymapper, Transit, Lyft, Uber, Navigon, Waze, DB Navigator, Yandex.Navi and Moovit**.
Know of any other navigation apps that can be opened via URL scheme or universal link? Please open an issue and/or PR 🙃
## Quick Start
Check if an app is installed.
```swift
if Karte.isInstalled(.citymapper) {
print("Citymapper is installed 🎉")
}
```Launch a specific app with directions.
```swift
let coordinate = CLLocationCoordinate2D(latitude: 52.5162746, longitude: 13.3755153)
let berlin = Karte.Location(name: "Brandenburger Tor Berlin", coordinate: coordinate)
Karte.launch(app: .googleMaps, destination: berlin)
```Or directly present the user with an action sheet listing all installed navigation apps to pick from.
```swift
Karte.presentPicker(destination: location, presentOn: viewController)
```If you need more control in how to present the action sheet (e.g. on an iPad), you can get a configured one from Karte without having it presented directly.
```swift
let alert = Karte.createPicker(destination: location)
````.launch()`, `.presentPicker()` and `.createPicker()` have a few extra parameters with default values set that you can change to your liking. Most important to note would be an origin location, which can of course also be specified. Leaving it blank defaults to the user's current location in most apps.
A mode of transport can also be specified, which would then filter unsupported apps from the picker. Be aware that trying to launch an app directly with a specific mode of transport will verify if the app supports that mode and throw a `Karte.Error.unsupportedMode` otherwise.
## Caveat
Please be aware that for `.isInstalled()`, `.presentPicker()` and `.createPicker()` to work you will have to have added the necessary URL schemes to your app's `Info.plist` beforehand. See [Apple's Docs](https://developer.apple.com/reference/uikit/uiapplication/1622952-canopenurl#discussion) for more info on this. The necessary URL schemes can be found [here](https://github.com/kiliankoe/Karte/blob/master/Sources/App.swift#L24). You're still free to try and launch apps via `Karte.launch(app:to:)` regardless of registered URL schemes, although that obviously might result in nothing happening if the app isn't there. Don't forget that even Apple Maps can be "uninstalled" now 😉
The section to add to your `Info.plist` should look like this:
```xml
LSApplicationQueriesSchemes
comgooglemaps
citymapper
transit
lyft
uber
navigon
waze
dbnavigator
yandexnavi
moovit
```## Installation
Karte is available through SwiftPM. Just copy `https://github.com/kiliankoe/Karte` into Xcode ✌️
## Credits
This library is based on [CMMapLauncher](https://github.com/citymapper/CMMapLauncher). Unfortunately development on that library seems to have been stopped, so this is a reimplementation in Swift including a few changes and other apps to make usage even more pleasant 😊
## Authors
Kilian Koeltzsch, [@kiliankoe](https://github.com/kiliankoe)
## "Karte"?
It's German for "Map" and that seemed fitting 🤷♀️