GithubHelp home page GithubHelp logo

gerdc / karte Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kiliankoe/karte

0.0 0.0 0.0 192 KB

๐Ÿ—บ Conveniently launch directions in other iOS apps

License: MIT License

Swift 100.00%

karte's Introduction

Karte

Travis GitHub tag (latest SemVer)

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.

if Karte.isInstalled(.citymapper) {
    print("Citymapper is installed ๐ŸŽ‰")
}

Launch a specific app with directions.

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.

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.

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 for more info on this. The necessary URL schemes can be found here. 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:

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>comgooglemaps</string>
        <string>citymapper</string>
        <string>transit</string>
        <string>lyft</string>
        <string>uber</string>
        <string>navigon</string>
        <string>waze</string>
        <string>dbnavigator</string>
        <string>yandexnavi</string>
        <string>moovit</string>
    </array>

Installation

Karte is available through SwiftPM. Just copy https://github.com/kiliankoe/Karte into Xcode โœŒ๏ธ

Credits

This library is based on 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

"Karte"?

It's German for "Map" and that seemed fitting ๐Ÿคทโ€โ™€๏ธ

karte's People

Contributors

kiliankoe avatar inickt avatar guykogus avatar lightsprint09 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.