GithubHelp home page GithubHelp logo

dpa99c / phonegap-launch-navigator Goto Github PK

View Code? Open in Web Editor NEW
369.0 28.0 129.0 1.43 MB

Phonegap/Cordova plugin which launches native route navigation apps for Android, iOS and Windows

Java 34.52% JavaScript 29.07% Objective-C 36.41%

phonegap-launch-navigator's Introduction

Launch Navigator Cordova/Phonegap Plugin Latest Stable Version Total Downloads

Cordova/Phonegap plugin for launching today's most popular navigation/ride apps to navigate to a destination.

Platforms: Android, iOS and Windows.

Key features:

  • Single, clean API to abstract away the gory details of each 3rd party app's custom URI scheme
  • Detects which supported apps are installed/available on the user's device
  • API to detect which features are supported by which apps on which platforms
  • Out-of-the-box UI for app selection which remembers user choice
  • Growing list of supported apps

Launch Navigator is also available as a React Native module.

 

donate

I dedicate a considerable amount of my free time to developing and maintaining this Cordova plugin, along with my other Open Source software. To help ensure this plugin is kept updated, new features are added and bugfixes are implemented quickly, please donate a couple of dollars (or a little more if you can stretch) as this will help me to afford to dedicate time to its maintenance. Please consider donating if you're using this plugin in an app that makes you money, if you're being paid to make the app, if you're asking for new features or priority bug fixes.

Table of Contents

General concepts

App detection, selection and launching

  • The plugin will detect which supported navigation apps are available on the device.
  • By default, where this is more than one choice, it will display a list of these to the user to select for navigation.
    • This is done using native UI elements
  • However, the plugin API allows you to programmatically:
    • check which apps are available on the current device
    • check which apps support which navigation options
    • launch a specific app for navigation

Geocoding and input format of start/destination locations

  • Some navigation apps require that destination/start locations be specified as coordinates, and others require an address.
  • By default, this plugin will appropriately geocode or reverse-geocode the locations you provide to ensure the app receives the location in the required format.
  • However, geocoding requires use of a remote service, so an internet connection is required.
  • If navigate() is passed a location type which the selected app doesn't support, the error callback will be invoked if:
    • geocoding is disabled by passing enableGeocoding: false in the options object
    • there is no internet connection to perform the remote geocode operation
    • geocoding fails (e.g. an address cannot be found for the given lat/long coords)
  • Note that for geocoding to work on Android, a Google API key must be specified in order to use the Google Geocoder API service (see installation instructions below).

Remember user's choice of navigation app

  • If the built-in app selection mechanism is used, the plugin enables the user's choice of app to be locally persisted, meaning they don't have to choose every time.
  • By default, this as the user to confirm they wish their choice to be remembered.
  • See the appSelection section of options for the navigate() function for more details.
  • See the "Advanced Example" project] in the example repo for an illustrated example.

Supported navigation apps

The plugin currently supports launching the following navigation apps:

Android

iOS

Windows

Adding support for more apps

This plugin is a work in progress. I'd like it to support launching of as many popular navigation apps as possible.

If there's another navigation app which you think should be explicitly supported and it provides a mechanism to externally launch it, open an issue containing a link or details of how the app should be invoked.

Don't just open an issue saying "Add support for Blah" without first finding out if/how it can be externally launched. I don't have time to research launch mechanisms for every suggested app, so I will close such issues immediately.

Installing

The plugin is registered on npm as uk.co.workingedge.phonegap.plugin.launchnavigator

IMPORTANT: Note that the plugin will NOT work in a browser-emulated Cordova environment, for example by running cordova serve or using the Ripple emulator. This plugin is intended to launch native navigation apps and therefore will only work on native mobile platforms (i.e. Android/iOS/Windows).

Using the CLI

$ cordova plugin add uk.co.workingedge.phonegap.plugin.launchnavigator --variable GOOGLE_API_KEY_FOR_ANDROID="{your_api_key}"
$ phonegap plugin add uk.co.workingedge.phonegap.plugin.launchnavigator --variable GOOGLE_API_KEY_FOR_ANDROID="{your_api_key}"
$ ionic cordova plugin add uk.co.workingedge.phonegap.plugin.launchnavigator --variable GOOGLE_API_KEY_FOR_ANDROID="{your_api_key}"

Note: GOOGLE_API_KEY_FOR_ANDROID="" is safe to use if navigation is only being performed with latitude/longitude coordinates.

PhoneGap Build

Add the following xml to your config.xml to use the latest version of this plugin from npm:

<plugin name="uk.co.workingedge.phonegap.plugin.launchnavigator" source="npm" >
    <variable name="GOOGLE_API_KEY_FOR_ANDROID" value="{your_api_key}" />
</plugin>

Google API key for Android

  • On Android, this plugin uses Google's Geocoding API to geocode input addresses to lat/lon coordinates in order to support navigation apps which only allow input locations to be specified as lat/lon coordinates.
  • Google now requires that an API key be specified in order to use the Geocoding API
    • For more information on how to obtain an API key, see the Google documentation.
    • Don't place any application restrictions on the key, otherwise geocoding will fail.
  • You can provide your Google API key to the plugin by either:
    • setting the GOOGLE_API_KEY_FOR_ANDROID plugin variable during plugin installation
      • Note: this method places your API in the AndroidManifest.xml in cleartext so carries the possible security risk of a malicious party decompiling your app to obtain your API key (see #249)
    • setting it at runtime by calling the setApiKey() function
      • this method is secure from a security perspective.
      • you must call this method in each app session (e.g. at app startup) before attempting to use the plugin's geocoding features on Android.
  • If you are only navigating via latitude/longitude coordinates and therefore not using Google's Geocoding API, you can safely set the API Key to an empty string.

OKHTTP Library

  • This plugin uses the OKHTTP library on Android to access Google's remote Geocoding API service
  • The library is included at Android build time via Gradle
  • If another plugin in your Cordova project specifies a different version of the OKHTTP library than this plugin, this can cause a Gradle version collision leading to build failure. See #193.
  • You can override the default version of the library specified by this plugin by specifying the OKHTTP_VERSION plugin variable during plugin installation:
    • cordova plugin add uk.co.workingedge.phonegap.plugin.launchnavigator --variable GOOGLE_API_KEY_FOR_ANDROID="{your_api_key}" --variable OKHTTP_VERSION=1.2.3
  • You can find the version of the library currently specified by this plugin in the plugin.xml

Usage examples

Simple usage

Navigate to a destination address from current location.

User is prompted to choose from available installed navigation apps.

launchnavigator.navigate("London, UK");

Navigate to a destination with specified start location

launchnavigator.navigate("London, UK", {
    start: "Manchester, UK"
});

Navigate using latitude/longitude coordinates

Coordinates can be specified as a string or array

launchnavigator.navigate([50.279306, -5.163158], {
    start: "50.342847, -4.749904"
});

Advanced usage

Navigate using a specific app

launchnavigator.isAppAvailable(launchnavigator.APP.GOOGLE_MAPS, function(isAvailable){
    var app;
    if(isAvailable){
        app = launchnavigator.APP.GOOGLE_MAPS;
    }else{
        console.warn("Google Maps not available - falling back to user selection");
        app = launchnavigator.APP.USER_SELECT;
    }
    launchnavigator.navigate("London, UK", {
        app: app
    });
});

List all of the apps supported by the current platform

var platform = device.platform.toLowerCase();
if(platform == "android"){
    platform = launchnavigator.PLATFORM.ANDROID;
}else if(platform == "ios"){
    platform = launchnavigator.PLATFORM.IOS;
}else if(platform.match(/win/)){
    platform = launchnavigator.PLATFORM.WINDOWS;
}

launchnavigator.getAppsForPlatform(platform).forEach(function(app){
    console.log(launchnavigator.getAppDisplayName(app) + " is supported");
});

List apps available on the current device

launchnavigator.availableApps(function(results){
    for(var app in results){
        console.log(launchnavigator.getAppDisplayName(app) + (results[app] ? " is" : " isn't") +" available");
    }
});

Reporting issues

IMPORTANT: Please read the following carefully. Failure to follow the issue template guidelines below will result in the issue being immediately closed.

Reporting a bug or problem

Before opening a bug issue, please do the following:

  • DO NOT open issues asking for support in using/integrating the plugin into your project
    • Only open issues for suspected bugs/issues with the plugin that are generic and will affect other users
    • I don't have time to offer free technical support: this is free open-source software
    • Ask for help on StackOverflow, Ionic Forums, etc.
    • Use the example project as a known working reference
    • Any issues requesting support will be closed immediately.
  • DO NOT open issues related to the Ionic Typescript wrapper for this plugin
    • This is owned/maintained by Ionic and is not part of this plugin
    • Please raise such issues/PRs against Ionic Native instead.
    • To verify an if an issue is caused by this plugin or its Typescript wrapper, please re-test using the vanilla Javascript plugin interface (without the Ionic Native wrapper).
    • Any issue opened here which is obviously an Ionic Typescript wrapper issue will be closed immediately.
  • Read the above documentation thoroughly
  • Check your target country is supported for turn-by-turn by the native navigation app
  • Check the CHANGELOG for any breaking changes that may be causing your issue.
  • Check a similar issue (open or closed) does not already exist against this plugin.
    • Duplicates or near-duplicates will be closed immediately.
  • When creating a new issue
    • Choose the "Bug report" template
    • Fill out the relevant sections of the template and delete irrelevant sections
    • WARNING: Failure to complete the issue template will result in the issue being closed immediately.
  • Reproduce the issue using the example project
    • This will eliminate bugs in your code or conflicts with other code as possible causes of the issue
    • This will also validate your development environment using a known working codebase
    • If reproducing the issue using the example project is not possible, create an isolated test project that you are able to share
  • Include full verbose console output when reporting build issues
    • If the full console output is too large to insert directly into the Github issue, then post it on an external site such as Pastebin and link to it from the issue
    • Often the details of an error causing a build failure is hidden away when building with the CLI
      • To get the full detailed console output, append the --verbose flag to CLI build commands
      • e.g. cordova build ios --verbose
    • Failure to include the full console output will result in the issue being closed immediately
  • If the issue relates to the plugin documentation (and not the code), please of a documentation issue

Requesting a new feature

Before opening a feature request issue, please do the following:

  • Check the above documentation to ensure the feature you are requesting doesn't already exist
  • Check the list if open/closed issues to check if there's a reason that feature hasn't been included already
  • Ensure the feature you are requesting is actually possible to implement and generically useful to other users than yourself
  • Where possible, post a link to the documentation related to the feature you are requesting
  • Include other relevant links, e.g.
    • Stack Overflow post illustrating a solution
    • Code within another Github repo that illustrates a solution

Supported parameters

Different apps support different input parameters on different platforms. Any input parameters not supported by a specified app will be ignored.

The following table enumerates which apps support which parameters.

Platform App Dest Dest name Start Start name Transport mode Free
Android Google Maps (Map mode) X X X
Android Google Maps (Turn-by-turn mode) X X X
Android Waze X X
Android CityMapper X X X X X
Android Uber X X X X X
Android Yandex X X X
Android Sygic X X X
Android HERE Maps X X X X X
Android Moovit X X X X X
Android Lyft X X X
Android MAPS.ME X X X X
Android Geo: URI scheme X X N/A
Android Cabify X X X X X
Android Baidu Maps X X[1] X X[1] X X
Android 99 Taxi X X X X X
Android Gaode Maps X X X X X X
iOS Apple Maps - URI scheme X X X X
iOS Apple Maps - MapKit class X X X X X X
iOS Google Maps X X X X
iOS Waze X X
iOS Citymapper X X X X X
iOS Navigon X X
iOS Transit App X X X
iOS Yandex X X X
iOS Uber X X X X
iOS Tomtom X X
iOS Sygic X X X
iOS HERE Maps X X X X X
iOS Moovit X X X X X
iOS Lyft X X X
iOS MAPS.ME X X X X
iOS Cabify X X X X X
iOS Baidu Maps X X[1] X X[1] X X
iOS 99 Taxi X X X X X
iOS Gaode Maps X X X X X X
Windows Bing Maps X X X X X X

[1]: Only supported when Start or Dest is specified as lat/lon (e.g. "50,-4")

Table columns:

  • Dest - destination location specified as lat/lon (e.g. "50,-4") or address (e.g. "London")
  • Dest name - nickname for destination location (e.g. "Bob's house")
  • Start - start location specified as lat/lon (e.g. "50,-4") or address (e.g. "London")
  • Start name - nickname for start location (e.g. "Bob's house")
  • Transport mode - mode of transport to use for route planning (e.g. "walking")
  • Free - is the app free or does it cost money?

Transport modes

Apps that support specifying transport mode.

Platform App Driving Walking Bicycling Transit
Android Google Maps (Turn-by-turn mode) X X X X
Android Sygic X X
Android MAPS.ME X X X X
Android Baidu Maps X X X X
Android Gaode Maps X X X X
iOS Apple Maps X X
iOS Google Maps X X X X
iOS Sygic X X
iOS MAPS.ME X X X X
iOS Baidu Maps X X X X
iOS Gaode Maps X X X X
Windows Bing Maps X X X

Plugin API

All of the following constants and functions should be referenced from the global launchnavigator namespace. For example:

launchnavigator.PLATFORM.ANDROID

Constants

PLATFORM

Supported platforms:

  • launchnavigator.PLATFORM.ANDROID
  • launchnavigator.PLATFORM.IOS
  • launchnavigator.PLATFORM.WINDOWS

APP

Supported apps:

  • launchnavigator.APP.USER_SELECT (Android & iOS) - invokes native UI for user to select available navigation app
  • launchnavigator.APP.GEO (Android) - invokes a native chooser, allowing users to select an app which supports the geo: URI scheme for navigation
  • launchnavigator.APP.GOOGLE_MAPS (Android & iOS)
  • launchnavigator.APP.WAZE (Android & iOS)
  • launchnavigator.APP.CITYMAPPER (Android & iOS)
  • launchnavigator.APP.UBER (Android & iOS)
  • launchnavigator.APP.APPLE_MAPS (iOS)
  • launchnavigator.APP.NAVIGON (iOS)
  • launchnavigator.APP.TRANSIT_APP (iOS)
  • launchnavigator.APP.YANDEX (Android & iOS)
  • launchnavigator.APP.TOMTOM (iOS)
  • launchnavigator.APP.BING_MAPS (Windows)
  • launchnavigator.APP.SYGIC (Android & iOS)
  • launchnavigator.APP.HERE_MAPS (Android & iOS)
  • launchnavigator.APP.MOOVIT (Android & iOS)
  • launchnavigator.APP.LYFT (Android & iOS)
  • launchnavigator.APP.MAPS_ME (Android & iOS)
  • launchnavigator.APP.CABIFY (Android & iOS)
  • launchnavigator.APP.BAIDU (Android & iOS)
  • launchnavigator.APP.TAXIS_99 (Android & iOS)
  • launchnavigator.APP.GAODE (Android & iOS)

APP_NAMES

Display names for supported apps, referenced by launchnavigator.APP.

e.g. launchnavigator.APP_NAMES[launchnavigator.APP.GOOGLE_MAPS] == "Google Maps" x

TRANSPORT_MODE

Transport modes for navigation:

  • launchnavigator.TRANSPORT_MODE.DRIVING
  • launchnavigator.TRANSPORT_MODE.WALKING
  • launchnavigator.TRANSPORT_MODE.BICYCLING
  • launchnavigator.TRANSPORT_MODE.TRANSIT

LAUNCH_MODE

Android only: launch modes supported by Google Maps on Android

  • launchnavigator.LAUNCH_MODE.MAPS - Maps view
  • launchnavigator.LAUNCH_MODE.TURN_BY_TURN - Navigation view
  • launchnavigator.LAUNCH_MODE.GEO - Navigation view via geo: URI scheme

API methods

navigate()

The plugin's primary API method. Launches a navigation app with a specified destination. Also takes optional parameters.

launchnavigator.navigate(destination, options);

OR

launchnavigator.navigate(destination, successCallback, errorCallback, options);

Parameters

  • destination (required): destination location to use for navigation. Either:
    • a {string} containing the address. e.g. "Buckingham Palace, London"
    • a {string} containing a latitude/longitude coordinate. e.g. "50.1. -4.0"
    • an {array}, where the first element is the latitude and the second element is a longitude, as decimal numbers. e.g. [50.1, -4.0]
  • options - optional parameters:
    • successCallback (optional): A callback to invoke when the navigation app is successfully launched.
    • errorCallback (optional): A callback to invoke if an error is encountered while launching the app. A single string argument containing the error message will be passed in.
    • {string} app - name of the navigation app to use for directions. Specify using launchnavigator.APP constants. e.g. launchnavigator.APP.GOOGLE_MAPS. If not specified, defaults to user selection via native picker UI.
    • {string} destinationName - nickname to display in app for destination. e.g. "Bob's House".
    • start (optional): start location to use for navigation. If not specified, the current device location will be used. Either:
      • a {string} containing the address. e.g. "Buckingham Palace, London"
      • a {string} containing a latitude/longitude coordinate. e.g. "50.1. -4.0"
      • an {array}, where the first element is the latitude and the second element is a longitude, as decimal numbers. e.g. [50.1, -4.0]
    • {string} startName - nickname to display in app for start. e.g. "My Place".
    • {string} transportMode - transportation mode for navigation. Defaults to "driving" if not specified. Specify using launchnavigator.TRANSPORT_MODE constants.
    • {boolean} enableGeocoding - (Android and iOS only) if true, and input location type(s) doesn't match those required by the app, use geocoding to obtain the address/coords as required. Defaults to true.
    • {boolean} enableGeolocation - (Windows only) if false, the plugin will NOT attempt to use the geolocation plugin to determine the current device position when the start location parameter is omitted. Defaults to true.
    • {object} extras - a key/value map of extra app-specific parameters. For example, to tell Google Maps on Android to display Satellite view in "maps" launch mode: {"t": "k"}
    • {string} launchModeGoogleMaps - (Android only) mode in which to open Google Maps app
      • launchnavigator.LAUNCH_MODE.MAPS or launchnavigator.LAUNCH_MODE.TURN_BY_TURN
      • Defaults to launchnavigator.LAUNCH_MODE.MAPS if not specified.
    • {string} launchModeAppleMaps - (iOS only) method to use to open Apple Maps app - launchnavigator.LAUNCH_MODE.URI_SCHEME or launchnavigator.LAUNCH_MODE.MAPKIT - Defaults to launchnavigator.LAUNCH_MODE.URI_SCHEME if not specified.
    • {object} - appSelection - options related to the default native actionsheet picker which enables user to select which navigation app to launch if app is not specified.
      • {string} dialogHeaderText - text to display in the native picker body, above the app buttons.
        • Defaults to "Select app for navigation" if not specified.
      • {string} cancelButtonText - text to display for the cancel button.
        • Defaults to "Cancel" if not specified.
      • {number} dialogPositionX - [iPad only] x position for the dialog
        • Defaults to 550 if not specified
      • {number} dialogPositionY - [iPad only] y position for the dialog
        • Defaults to 500 if not specified
      • {array} list - list of apps, defined as launchnavigator.APP constants, which should be displayed in the picker if the app is available. This can be used to restrict which apps are displayed, even if they are installed. By default, all available apps will be displayed.
      • {function} callback - a callback to invoke when the user selects an app in the native picker.
        • A single string argument is passed which is the app what was selected defined as a launchnavigator.APP constant.
      • {integer} androidTheme - (Android only) native picker theme. Specify using actionsheet.ANDROID_THEMES constants. Default actionsheet.ANDROID_THEMES.THEME_HOLO_LIGHT
      • {object} - rememberChoice - options related to whether to remember user choice of app for next time, instead of asking again for user choice.
        • {string/boolean} enabled - whether to remember user choice of app for next time, instead of asking again for user choice.
          • "prompt" - Prompt user to decide whether to remember choice.
            • Default value if unspecified.
            • If promptFn is defined, this will be used for user confirmation.
            • Otherwise (by default), a native dialog will be displayed to ask user.
          • false - Do not remember user choice.
          • true - Remember user choice.
        • {function} promptFn - a function which asks the user whether to remember their choice of app.
          • If this is defined, then the default dialog prompt will not be shown, allowing for a custom UI for asking the user.
          • This will be passed a callback function which should be invoked with a single boolean argument which indicates the user's decision to remember their choice.
        • {object} - prompt - options related to the default dialog prompt used to ask the user whether to remember their choice of app.
          • {function} callback - a function to pass the user's decision whether to remember their choice of app.
            • This will be passed a single boolean value indicating the user's decision.
          • {string} headerText - text to display in the native prompt header asking user whether to remember their choice.
            • Defaults to "Remember your choice?" if not specified.
          • {string} bodyText - text to display in the native prompt body asking user whether to remember their choice.
            • Defaults to "Use the same app for navigating next time?" if not specified.
          • {string} yesButtonText - text to display for the Yes button.
            • Defaults to "Yes" if not specified.
          • {string} noButtonText - text to display for the No button.
            • Defaults to "No" if not specified.

enableDebug()

Enables debug log output from the plugin to the JS and native consoles. By default debug is disabled.

launchnavigator.enableDebug(true, success, error);

Parameters

  • {boolean} enabled - Whether to enable debug.
  • {function} success - callback to invoke on successfully setting debug.
  • {function} error - callback to invoke on error while setting debug. Will be passed a single string argument containing the error message.

isAppAvailable()

Determines if the given app is installed and available on the current device.

launchnavigator.isAppAvailable(appName, function(isAvailable){
    console.log(appName + " is available: " + isAvaialble);
}, error);

Parameters

  • {string} appName - name of the app to check availability for. Define as a constant using ln.APP.
  • {function} success - callback to invoke on successful determination of availability. Will be passed a single boolean argument indicating the availability of the app.
  • {function} error - callback to invoke on error while determining availability. Will be passed a single string argument containing the error message.

availableApps()

Returns a list indicating which apps are installed and available on the current device.

launchnavigator.availableApps(function(apps){
    apps.forEach(function(app){
        console.log(app + " is available");
    });
}, error);

Parameters

  • {function} success - callback to invoke on successful determination of availability. Will be passed a key/value object where the key is the app name and the value is a boolean indicating whether the app is available.
  • {function} error - callback to invoke on error while determining availability. Will be passed a single string argument containing the error message.

getAppDisplayName()

Returns the display name of the specified app.

let displayName = launchnavigator.getAppDisplayName(app);

Parameters

  • {string} app - specified as a constant in launchnavigator.APP. e.g. launchnavigator.APP.GOOGLE_MAPS. whether the app is available.
  • returns {string} - app display name. e.g. "Google Maps".

getAppsForPlatform()

Returns list of supported apps on a given platform.

let apps = launchnavigator.getAppsForPlatform(platform);

Parameters

  • {string} platform - specified as a constant in launchnavigator.PLATFORM. e.g. launchnavigator.PLATFORM.IOS.
  • returns {array} of {string} - apps supported on specified platform as a list of launchnavigator.APP constants.

supportsTransportMode()

Indicates if an app on a given platform supports specification of transport mode.

let transportModeIsSupported = launchnavigator.supportsTransportMode(app, platform, launchMode);

Parameters

  • {string} app - specified as a constant in launchnavigator.APP. e.g. launchnavigator.APP.GOOGLE_MAPS.
  • {string} platform - specified as a constant in launchnavigator.PLATFORM. e.g. launchnavigator.PLATFORM.IOS.
  • {string} launchMode (optional) - Android only. Only applies to Google Maps on Android. Specified as a constant in launchnavigator.LAUNCH_MODE. e.g. launchnavigator.LAUNCH_MODE.MAPS.
  • returns {boolean} - true if app/platform combination supports specification of transport mode.

getTransportModes()

Returns the list of transport modes supported by an app on a given platform.

let modes = launchnavigator.getTransportModes(app, platform, launchMode);

Parameters

  • {string} app - specified as a constant in launchnavigator.APP. e.g. launchnavigator.APP.GOOGLE_MAPS.
  • {string} platform - specified as a constant in launchnavigator.PLATFORM. e.g. launchnavigator.PLATFORM.IOS.
  • {string} launchMode (optional) - Only applies to Google Maps on Android. Specified as a constant in launchnavigator.LAUNCH_MODE. e.g. launchnavigator.LAUNCH_MODE.MAPS.
  • returns {array} of {string} - list of transports modes as constants in launchnavigator.TRANSPORT_MODE. If app/platform combination doesn't support specification of transport mode, the list will be empty;

supportsDestName()

Indicates if an app on a given platform supports specification of a custom nickname for destination location.

let destNameIsSupported = launchnavigator.supportsDestName(app, platform, launchMode);

Parameters

  • {string} app - specified as a constant in launchnavigator.APP. e.g. launchnavigator.APP.GOOGLE_MAPS.
  • {string} platform - specified as a constant in launchnavigator.PLATFORM. e.g. launchnavigator.PLATFORM.IOS.
  • {string} launchMode (optional) - Only applies to Google Maps on Android and Apple Maps on iOS. Specified as a constant in launchnavigator.LAUNCH_MODE. e.g. launchnavigator.LAUNCH_MODE.MAPS.
  • returns {boolean} - true if app/platform combination supports specification of a custom nickname for destination location.

supportsStart()

Indicates if an app on a given platform supports specification of start location.

let startIsSupported =  launchnavigator.supportsStart(app, platform, launchMode);

Parameters

  • {string} app - specified as a constant in launchnavigator.APP. e.g. launchnavigator.APP.GOOGLE_MAPS.
  • {string} platform - specified as a constant in launchnavigator.PLATFORM. e.g. launchnavigator.PLATFORM.IOS.
  • {string} launchMode (optional) - Only applies to Google Maps on Android. Specified as a constant in launchnavigator.LAUNCH_MODE. e.g. launchnavigator.LAUNCH_MODE.MAPS.
  • returns {boolean} - true if app/platform combination supports specification of start location.

supportsStartName()

Indicates if an app on a given platform supports specification of a custom nickname for start location.

let startNameIsSupported = launchnavigator.supportsStartName(app, platform);

Parameters

  • {string} app - specified as a constant in launchnavigator.APP. e.g. launchnavigator.APP.GOOGLE_MAPS.
  • {string} platform - specified as a constant in launchnavigator.PLATFORM. e.g. launchnavigator.PLATFORM.IOS.
  • {string} launchMode (optional) - Only applies to Apple Maps on iOS. Specified as a constant in launchnavigator.LAUNCH_MODE. e.g. launchnavigator.LAUNCH_MODE.MAPKIT.
  • returns {boolean} - {boolean} - true if app/platform combination supports specification of a custom nickname for start location.

supportsLaunchMode()

Indicates if an app on a given platform supports specification of launch mode.

  • Currently only Google Maps on Android and Apple Maps on iOS does.

    let launchModeIsSupported = launchnavigator.supportsLaunchMode(app, platform);

Parameters

  • {string} app - specified as a constant in launchnavigator.APP. e.g. launchnavigator.APP.GOOGLE_MAPS.
  • {string} platform - specified as a constant in launchnavigator.PLATFORM. e.g. launchnavigator.PLATFORM.ANDROID.
  • returns {boolean} - true if app/platform combination supports specification of transport mode.

appSelection.userChoice.exists()

Indicates whether a user choice exists for a preferred navigator app.

launchnavigator.appSelection.userChoice.exists(function(exists){
    console.log("User preference of app: " + (exists ? "exists" : "doesn't exist"));
});

Parameters

  • [function} cb - function to pass result to: will receive a boolean argument.

appSelection.userChoice.get()

Returns current user choice of preferred navigator app.

launchnavigator.appSelection.userChoice.get(function(app){
    console.log("User preferred app is: " + launchnavigator.getAppDisplayName(app));
});

Parameters

  • [function} cb - function to pass result to: will receive a string argument indicating the app, which is a constant in launchnavigator.APP.

appSelection.userChoice.set()

Sets the current user choice of preferred navigator app.

launchnavigator.appSelection.userChoice.set(launchnavigator.APP.GOOGLE_MAPS, function(){
    console.log("User preferred app is set");
});

Parameters

  • {string} app - app to set as preferred choice as a constant in launchnavigator.APP.
  • [function} cb - function to call once operation is complete.

appSelection.userChoice.clear()

Clears the current user choice of preferred navigator app.

launchnavigator.appSelection.userChoice.clear(function(){
    console.log("User preferred app is cleared");
});

Parameters

  • [function} cb - function to call once operation is complete.

appSelection.userPrompted.get()

Indicates whether user has already been prompted whether to remember their choice a preferred navigator app.

launchnavigator.appSelection.userPrompted.get(function(alreadyPrompted){
    console.log("User " + (alreadyPrompted ? "has" : "hasn't") + " already been asked whether to remember their choice of navigator app");
});

Parameters

  • [function} cb - function to pass result to: will receive a boolean argument.

appSelection.userPrompted.set()

Sets flag indicating user has already been prompted whether to remember their choice a preferred navigator app.

launchnavigator.appSelection.userPrompted.set(function(){
    console.log("Flag set to indicate user chose to remember their choice of navigator app");
});

Parameters

  • [function} cb - function to call once operation is complete.

appSelection.userPrompted.clear()

Clears flag which indicates if user has already been prompted whether to remember their choice a preferred navigator app.

launchnavigator.appSelection.userPrompted.clear(function(){
    console.log("Clear flag indicating whether user chose to remember their choice of navigator app");
});

Parameters

  • [function} cb - function to call once operation is complete.

setApiKey()

Sets the Google API key for Android. Note: This function is also available on iOS but it does nothing. This is to keep the interface consistent between the platforms.

launchnavigator.setApiKey(api_key, success, error);

Parameters

  • {String} apiKey - Google API Key.
  • {function} success - callback to invoke on successfully setting api key.
  • {function} error - callback to invoke on error while setting api key. Will be passed a single string argument containing the error message.

Example projects

There are several example projects in the example repo which illustrate usage of this plugin:

  • SimpleExample - illustrates basic usage of the plugin
  • AdvancedExample - illustrates advanced usage of the plugin
  • IonicExample - illustrates usage of the plugin with the Ionic v1 framework
  • Ionic2Example - illustrates usage of the plugin with the Ionic v2 framework and Ionic Native plugin wrapper.

Platform-specifics

Android

  • Running on Android, in addition to discovering which explicitly supported apps are installed, the plugin will also detect which installed apps support using the geo: URI scheme for use in navigation. These are returned in the list of available apps.

  • By specifying the app option as launchnavigator.APP.GEO, the plugin will invoke a native Android chooser, to allow the user to select an app which supports the geo: URI scheme for navigation.

  • Google Maps on Android can be launched in 3 launch modes:

    • Maps mode (launchnavigator.LAUNCH_MODE.MAPS) - launches in Map view. Enables start location to be specified, but not transport mode or destination name.
    • Turn-by-turn mode (launchnavigator.LAUNCH_MODE.TURN_BY_TURN) - launches in Navigation view. Enables transport mode to be specified, but not start location or destination name.
    • Geo mode (launchnavigator.LAUNCH_MODE.GEO) - invokes Navigation view via geo: URI scheme. Enables destination name to be specified, but not start location or transport mode.
    • Launch mode can be specified via the launchModeGoogleMaps option, but defaults to Maps mode if not specified.

Windows

  • The plugin is compatible with Windows 10 on any PC or Windows 10 Mobile on a phone/tablet using the Universal .Net project generated by Cordova: cordova platform add windows

  • Bing Maps requires the user to press the enter key to initiate navigation if you don't provide the start location. Therefore, if a start location is not going to be passed to the plugin from your app, you should install the Geolocation plugin into your project. By default, if the geolocation plugin is detected, the plugin will attempt to retrieve the current device location using it, and use this as the start location. This can be disabled via the enableGeolocation option.

iOS

"Removing" Apple Maps

  • Since iOS 10, it is possible to "remove" built-in Apple apps, including Maps, from the Home screen.
  • Not that removing is not the same as uninstalling - the app is still actually present on the device, just the icon is removed from the Home screen.
  • Therefore it's not possible detect if Apple Maps is unavailable - launchnavigator.availableApps() will always report it as present.
  • The best that can be done is to gracefully handle the error when attempting to open Apple Maps using launchnavigator.navigate()
  • For reference, see this SO question and the Apple documentation.

Apple Maps launch method

This plugin supports 2 different launch methods for launching the Apple Maps app on iOS.

  • Specified by passing the launchModeAppleMaps option as a launchnavigator.LAUNCH_MODE constant to navigate()
    • launchnavigator.LAUNCH_MODE.URI_SCHEME: use the URI scheme launch method. Default if not specified.
    • launchnavigator.LAUNCH_MODE.MAPKIT: use the MapKit class launch method.

URI scheme launch method

  • Launches the app using the Apple Maps URI scheme
  • The default method used by the plugin.
  • Supports input location types of both coordinates and address string without requiring remote geocoding service (works offline)
  • Doesn't support specifying nicknames for start/destination locations.

MapKit class launch method

  • Launches the app using the MapKit class to launch Apple Maps
  • Only supports input location type of coordinates without requiring remote geocoding service (works offline)
  • An input location type of an address (formatted as a single string) requires use of remote geocoding service (requires internet connection)
    • MapKit class input requires an address which is formatted as an address dictionary, in which the address is split into known fields such as street, city and state.
  • Support specifying nicknames for start/destination locations.
  • Provides additional launch options which are not available via the URI scheme launch method.

App-specifics

Lyft

On both Android and iOS, the "ride type" will default to "Lyft" unless otherwise specified in the extras list as id.

See the Lyft documentation for URL scheme details and other supported ride types.

99 Taxi

On both Android and iOS, the extra parameters client_id and deep_link_product_id are required by 99 Taxi

  • client_id should follow the pattern MAP_*** where *** is the client name given by the 99 Team.
    • If not specified defaults to client_id=MAP_123
  • deep_link_product_id identifies the ride category
    • Currently supported values are:
      • 316 - POP ride
      • 326 - TOP ride
      • 327 - Taxis ride
    • If not specified defaults to deep_link_product_id=316

On Android, 99 Taxi is currently the only app where options.start is a required parameter when calling navigate()

  • If navigate() is called without a start location and the selected app is 99 Taxi, the error callback will be invoked and the 99 Taxi app will not be launched
  • In order for this plugin to automatically provide start location to 99 Taxi (if it's not already specified), the native Android implementation needs to be enhanced to:
    • check/request runtime permission to use location
    • add the necessary permission entries to the AndroidManifest.xml
    • check/request high accuracy location is enabled (no point in requesting a low-accuracy city-level position if you want a pickup at your exact current address)
    • request a high accuracy position to determine the user's current location
    • handle errors cases such as:
      • User denies location permission
      • User denies high accuracy mode permission
      • Location cannot be retrieved
  • Currently, I don't have time to do all of the above just for the case of 99 Taxi
    • However I'm willing to accept a PR request which implements the necessary native Android features.
  • Otherwise/until then, you'll need to manually specify the start location for 99 Taxi
    • If the current user location is required, you can use cordova-plugin-geolocation to find this.

Credits

Thanks to:

License

The MIT License

Copyright (c) 2016 Dave Alden (Working Edge Ltd.)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

phonegap-launch-navigator's People

Contributors

anthonywg avatar apierr avatar bareynol avatar bf4 avatar blhylton avatar catalinmitrofan avatar ctesene avatar danielsan avatar dpa99c avatar fredericosferreira avatar frederikbosch avatar glasset avatar guilleferrer avatar ihadeed avatar jase88 avatar oliversalzburg avatar opadro avatar pdlmobileapps avatar pke avatar seeday avatar ucswift avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phonegap-launch-navigator's Issues

Geolocation inside a promise

We have implemented the geolocation call inside a promise, using Ionic 2. It works as expected on iOS and older versions of Android.

We're performing the geolocation call inside the app.js file, and we’re resolving it in the first view.

Under Android Marshmallow (our problematic platform here), we get permission-related errors until the user accepts the permissions dialog. So far, so good. However, once the user accepts the permissions, the errors keep happening, but are instead timeout errors.

We’d expect the plugin to return coordinates when called after being granted permissions by the user, instead it is returning a timeout error. This does not happen if the app is force closed and then open again, as the plugin returns coordinates as expected.

Is this a known issue? Is there a known workaround?
ideas?

Suggestion: If start parameter is null...

Thank you for the great work and sharing it with the community.

I'd like to make a suggestion: if the second (start) parameter is a null or none or some other predefined term, have the map just open to the designated location instead of trying to navigate to the location (I know - the plugin is named navigator and that is it's primary focus). Seems like this would offer some flexibility.

launchnavigator.isAppAvailable(launchnavigator.APP.GOOGLE_MAPS returns false

i tried launchnavigator.isAppAvailable(launchnavigator.APP.GOOGLE_MAPS, function (isAvailable) {...})
from the example for my android and it returns false. However it is listed as available in launchnavigator.availableApps and also works when i use launchnavigator.navigate and specify optional parameter
app: launchnavigator.APP.GOOGLE_MAPS

Navigation for IOS In India

Hi,
I'm creating a Cordova app for android & ios that provides navigation support.
The plugin was extremely helpful & worked well in android. However I'm from India and hence i'm unable to access the navigation options on the ios platform using the plugin. Can you please suggest any solutions to make this feature work for the ios platform.

Thank you.

photo

when "preferGoogleMaps" set to true,If Google Maps is not available, it "will not" fall back to Apple Maps

hi @dpa99c
I am using Cordova 5.1.1 + all latest official core plugin + your plugin 2.9.0

If Google Maps is available (installed),when "preferGoogleMaps" set to true,it really open the googleMap instead of Apple Maps
but...
If Google Maps is not available (not installed),when "preferGoogleMaps" still set to true,it do nothing (nothing means that there is no any further action,just "nothing")

iOS Apple Maps zooms out to globe for several seconds

First off: thanks for this plugin! I love that it can work without requiring user permissions (disableAutoGeolocation: true).

When I run something like this:

launchnavigator.navigate(address, null, function () {
    console.log("successful directions");
}, function (err) {
    console.log("error with directions: " + err);
}, {
    disableAutoGeolocation: true
});

Most of the time Apple Maps starts with the map near my location, but then it zooms out to the entire globe and sits there for several (~5) seconds before zooming back to the proper level.

I understand that I am not providing it with any information about my whereabouts (null), but I've never seen this behavior before.

It's unlikely to be related, but I noticed that the plugin has a "UK" prefix. Is there anything in the code that might encourage the map to think it should start in the UK (I'm in the US)? For instance, it starts zoomed in near my location (I'm guessing due to caching my recent location), then something the plugin communicated makes it "think" globally, and then it finally figures out my location.

Plugin seems to terminate app process when invoked

I'm not sure if this is the expected behavior, but after calling the plugin and after the navigation loads, it seems to halt my app's process. If I continue pressing back to go back to my app, my app has restarted and loses it's current state.

I have very little native Android knowledge, is this expected behavior when invoking an ACTION_VIEW intent?

Testing on a Nexus 4 running Android 5.0.1.

iOS default Start

Thanks for the cool plugin.
Your doc says that leaving the start parameter as null should default to the current location as the start but my implementation is pulling up the directions and the user has to select the Start (Current Location is one of the options). I found that if I use "Current Location" as the start parameter, it will do this for me but not if I just leave it null. I haven't tested this on other platforms yet.

launch navigator is not define

Hi, I tried to implement this plugin in my ionic app but the error comes up and it says "launchnavigator is not define"
then I try your ionic example on several devices, the same problem also occurs.
what should i do to overcome this problem? thanks

Android is fine, iOS console giving me error

module uk.co.workingedge.phonegap.plugin.launchnavigator.LaunchNavigator already defined

Error: Module uk.co.workingedge.phonegap.plugin.LaunchNavigator.LaunchNavigator does not exist.

Not sure about this error since I tried to remove/add it many times.
Any suggestions?

Navigator doesn't run [ionic]

Hi,

I had worked example in my phone with navigation.
Now Im after some rebuilds, updates(ionic to latest version) and navigation doesn't works on android and on ios.

Here is screen from web serving:
https://i.imgur.com/t0r2hFI.png

When I run application on device , I don't received any errors, just nothing is going on.

I have installed plugin (phonegap plugin add uk.co.workingedge.phonegap.plugin.launchnavigator)

There is a code:
var destination = [50.279306, -5.163158];
var start = "Trento";
$cordovaLaunchNavigator.navigate(destination, start).then(function () {
console.log("Navigator launched");
}, function (err) {
console.error(err);
});

I also add $cordovaLaunchNavigator in controller

Navigator won't work, even with demo project

For a project I'm trying to achieve something for which this plugin should be perfect. However, when I install this plugin using phonegap plugin add uk.co.workingedge.phonegap.plugin.launchnavigator,
adding <gap:plugin name="uk.co.workingedge.phonegap.plugin.launchnavigator" version="2.1.0" /> to the config.xml file, and trying to use the launchnavigator.navigate(destination, start, successCallback, errorCallback); command with some plain data, it will always say "Uncaught ReferenceError: launchnavigator is not defined".

I downloaded your demo project and tried that, but whenever I click on one of the navigate button, simply nothing happens.

I've tried both situations on a webbrowser with the Ripple Chrome extention, whilst connecting my iPhone to my PC using the PhoneGap app, and for my own app, distribute it using build.phonegap.com.

Yandex Navigator for Android

Thanks for the plugin! It would be nice to add support for Yandex Navigator for Android as well. They have a spec but it's in Russian. Below is a code example for creating a route with translated comments:

    Intent intent = new Intent("ru.yandex.yandexnavi.action.BUILD_ROUTE_ON_MAP");
    intent.setPackage("ru.yandex.yandexnavi");

    PackageManager pm = getPackageManager();
    List<ResolveInfo> infos = pm.queryIntentActivities(intent, 0);

    // check if Yandex Navigator is installed
    if (infos == null || infos.size() == 0) {
        // If not, show the app page at Google Play
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("market://details?id=ru.yandex.yandexnavi"));
    } else {
        intent.putExtra("lat_from", 55.751802);
        intent.putExtra("lon_from", 37.586684);
        intent.putExtra("lat_to", 55.758192);
        intent.putExtra("lon_to", 37.642817);
    }

    startActivity(intent);

seem not support "navigator.notification.alert" in iOS 9.2

hi @dpa99c
I am using 2.9.7 version from npm and iOS 9.2
when I use

launchnavigator.navigate(action, action2,
 function()
 {
 navigator.notification.alert("success", null, 'title', 'yes');
 },
 function(error)
 {
 navigator.notification.alert("fail", null, 'title', 'yes');
 },
 options
);
 );

when in Android and winphone,it will all trigger the success callback
but in iOS,it will trigger "nothing"

but if I change the code to...

launchnavigator.navigate(action, action2,
 function()
 {
 alert("success");
 },
 function(error)
 {
 alert("fail");
 },
 options
);
 );

the iOS will become can trigger the success callback
is it a bug with the official "cordova-plugin-dialogs" ?

phonegap-launch-navigator not working!!

Hi,
i am new to the phonegap developement, i have npm 2.14.12, cordova 6.0.0, phonegap 5.5.0 installed in my system. i have installed the following plugin in my project:
cordova-plugin-device 1.1.1 "Device"
cordova-plugin-device-motion 1.2.0 "Device Motion"
cordova-plugin-device-orientation 1.0.2 "Device Orientation"
cordova-plugin-dialogs 1.2.0 "Notification"
cordova-plugin-file 4.1.0 "File"
cordova-plugin-file-transfer 1.5.0 "File Transfer"
cordova-plugin-geolocation 2.1.0 "Geolocation"
cordova-plugin-inappbrowser 1.3.0 "InAppBrowser"
cordova-plugin-network-information 1.2.0 "Network Information"
cordova-plugin-splashscreen 3.2.0 "Splashscreen"
cordova-plugin-whitelist 1.2.1 "Whitelist"
i have installed your plugin in my project and did as you explain in README file, but the plugin does not work. i have also tried "typeof launchnavigator" to check whether the object exists or not but it says undefined.

UPDATE:
here is my code:

document.addEventListener('deviceready', function () {
            $("#button").click(function () {

                launchnavigator.navigate(
                        [50.279306, -5.163158],
                        [50.342847, -4.749904],
                        function () {
                            alert("Plugin success");
                        },
                        function (error) {
                            alert("Plugin error: " + error);
                        });


            });
        }, false);

Please Help!!!
Thanks.

Conflict with the background-geolocation plugin

In my application I need two plugins (background-geolocation and launch-navigator), which have a dependency with the geolocation plugin.
I use cordova 4.3.1, suddenly, the backgroud-geolocation plugin will install the dependency plugin org.apache.cordova.geolocation but the launch-navigator plugin will install the plugin cordova-plugin-geolocation

Following this conflict, I have build problems with the following error:

_ERROR building one of the platforms: Error: / Tests / hello / platforms / ios / cordova / build: Command failed with exit code 2
You May not-have the required environment or OS to build this project
Error: / Tests / hello / platforms / ios / cordova / build: Command failed with exit code 2
    Has ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
    Has ChildProcess.emit (events.js: 110: 17)
    Has maybeClose (child_process.js 1008: 16)
    Has Process.ChildProcess.handle.onexit (child_process.js: 1080: 5)

Could you help me please?

successCallback and errorCallback options wrong documented

In the README.md -> API methods -> navigate() -> Parameters -> Options
You are writing "successFn:" and "errorFn:", but it has to be "successCallback:" and "errorCallback:" ...

For example the way it performs well:
launchnavigator.navigate(dest, {
successCallback: successMethode,
errorCallback: errorMethode
});

An example which I wrote suggested by your documentation and which DOESN'T work:
launchnavigator.navigate(dest, {
successFn: successMethode,
errorFn: errorMethode
});

Thanks in advance for correcting and thanks a lot for your plugin, I'm so happy with it =)

iOS not opening navigator if starting location is null unless the screen is touched again

I am having an issue opening Apple Maps with iOS 8.4 when no starting destination is specified.

Both

launchnavigator.navigate(
    city + ", " + state
);

and

launchnavigator.navigate(
    city + ", " + state,
    null,
    function() {
        alert("Success.");
    },
    function() {
        alert(error);
    }
);

behave as intended on the android devices I have tested on, however it does not immediately open navigation with iOS 8.4. The way this code is being executed is through a popup after close event through jQuery. The user selects a "Get Directions" button, the popup closes, then the navigation is supposed to open. However, I am assuming the starting location will be the users current location, so no starting location is specified, the popup closes and nothing happens. Neither the failure nor the success functions are called. However, if I scroll the contents of the page, a large amount of scrolling or a very short amount of scrolling, as soon as the scrolling stops, the navigation will open and I get the success function. I have tried scrolling immediately as well as waiting over 60 seconds before starting to scroll to see if the navigation would eventually open on its own.

However, I have tried specifying the starting location and the navigation opens immediately as expected. For example,

launchnavigator.navigate(
    city + ", " + state,
    "Dallas, TX"
);

Works just fine.

Step 2 fails due to incorrect file path

On step 2 after getting files from git you need to run:

$ cp -R phonegap-native-navigation/src/android/src/ $YOUR_PROJECT/src

the command fails as there is no /src/android/src/ path in the downloaded plugin.

Plugin not usable in Intel XDK anymore

Somewhere between june 18 2015 and now something happened such that, when building with intel XDK, a
"plugin failed"
when trying to build an app.

The june 18 version works when building in intel XDK.

the upper cause problem

hi @dpa99c
I am using your 2.9.6 version from npm + latest cordova
when I use

cordova plugin add uk.co.workingedge.phonegap.plugin.launchnavigator

no problem at all
but when I use

cordova plugin rm uk.co.workingedge.phonegap.plugin.launchnavigator

the cordova log told me that have no this plugin
finally I find in your plugin.xml
https://github.com/dpa99c/phonegap-launch-navigator/blob/master/plugin.xml
you use the upper case "L"aunchnavigator
it will cause when remove this plugin must use

cordova plugin rm uk.co.workingedge.phonegap.plugin.Launchnavigator

so I think it should beter more "Consistency" (maybe all lower case)

On iOS 9.0.2 preferGoogleMaps: true

Awesome plugin! I ran into one issue though. Tried to go through docs but could not find anything on this. It seems like on iOS 9.0.2 (could be other versions too) setting preferGoogleMaps: true will open Apple Maps even thought Google Maps is actually available on device. Error: -canOpenURL: failed for URL: "comgooglemaps://" - error: "This app is not allowed to query for scheme comgooglemaps". Did Apple change url politics or did I miss something basic info on this? Maybe I need to register something somewhere for this to work?

Ionic: Maps won't open

Hi guys,
I'm using the Ionic framework and doing this:

$scope.navigate = function() {

    // Ermittelt die eigene Position und gibt die Koordinaten wider
    var posOptions = {timeout: 10000, enableHighAccuracy: false};
    $cordovaGeolocation
      .getCurrentPosition(posOptions)
      .then(function (position) {

        $scope.position = position;

        // Smartphone Koordinaten
        var destination = [
          $scope.position.coords.latitude,
          $scope.position.coords.longitude
        ];

        // Ziel Koordinaten
        var start = [
          $scope.LatLng.lat,
          $scope.LatLng.lng
        ];

        console.log(destination);
        console.log(start);

        launchnavigator.navigate(
          destination,
          start,
          function(){
            alert("Plugin success");
          },
          function(error){
            alert("Plugin error: "+ error);
          },
          {
            navigationMode: "maps"
          }
        );

      });
  };

Within my app is a button calling the function navigate(), but nothing happens.
What shall I do?

If google maps or other app are not available

Hello,

Is it possible to ask what app should be used if google maps, bing or apple maps are not available?

I think every iphone/ipad has apple maps and windows device has bing maps, but on Android google maps are not always available (some strange ROM or chinese manufacturer may not include it).

It would be cool if there was a fallback for that situations.
A native window should popup and ask for a default app.

ReferenceError: launchnavigator is not defined

Hi,

I would like to use this plugin with an Ionic App, but I got an error.

I installed with: $ cordova plugin add uk.co.workingedge.phonegap.plugin.launchnavigator

And in my mainCtrl I call the function : launchnavigator.navigate(destination,source);
but chrome shows me ReferenceError: launchnavigator is not defined in the Console.

Am I missing something ?

Thank you !

Edit: Works like a charm in iOS simulator ;)

Permission popups bypassed on plugin launch

Hi there,
i have noticed a strange behavior of the plugin. I am using ionic and the code that launches the plugin is:
$cordovaLaunchNavigator.navigate([$scope.appService.map.options.lat, $scope.appService.map.options.lng], null, {
preferGoogleMaps: false,
transportMode: "driving",
enableDebug: true,
disableAutoGeolocation: false
}).then(function () {
console.log("Navigator launched");
}, function (err) {
console.error(err);
});
As you can see in the video below as soon as the user presses the button to get map directions and the map app is launched the confirmation messages are popping up for 2-3 seconds but the process continues without waiting for the user to confirm or not.
This behavior changes when parameter disableAutoGeolocation is true. What happens in this case is that (if user has location services enabled) the plugin proceeds opening the map app without any confirmation popups.
Is there any way to force the whole process to wait the users approval?
I am attaching the video https://www.youtube.com/watch?v=Wt_wap4naCg

Thanks in advance.

API v3

Hey there,

Great plugin, thanks for your efforts!

I noticed in your v3 API you have moved the success/error callbacks to be inside the option parameter's object. I would like to understand what lead you to switch to this approach instead.

The reason I'm asking is because I'm one of the developers for the Ionic Native Repo. It basically wraps plugins to provide Promise or Observable approach instead of the default success/error callback methods approach. Currently, it does that by working with successCallback/errorCallback parameters which are commonly used by most developers. But now that you are in the process of updating your API we would have to write additional code to be able to support your plugin.

I look forward to hearing back from you.

Missing MapsActivity on Android

Hi,
i use visual studio 2015 tools for apache cordova (cordova 5.1.1).
When i launch the navigator...

       launchnavigator.navigate(
            "Berlin",
            null,
            function() {
                console.log("success");
            }.bind(this),
            function (error) {
                console.log(error);
            }.bind(this),
            {
                disableAutoGeolocation: true,
                transportMode: "walking"
            }
        );

under android ive got the following error.

Unable to find explicit activity class {com.google.android.apps.maps/com.google.android.maps.MapsActivity}; have you declared this activity in your AndroidManifest.xml?

What must i do? I could run the same code under windows phone (universal) and it works.

Thanks & Regards!

Help using the plugin.

Hi
I've only recently starting with mobile development and i am working on a HTML5/JavaScript app that will navigate to a destination using the users's phones native navigation apps when a button is clicked. We are already using phonegap/cordova to get geolocation and a few other things but i have never used phonegap or cordova before. I really want to use this plugin as it is very nice and will do exactly what i need but i really don't know how to get it to work. I have tried placing the plugin in the config.xml file and then used the code from the Usage Examples area but that just doesn't work. I have also tried to use node.js to try install the plugin that way but i am finding it very confusing. So any advice or documentation that will help with learning how to get it working will be very helpful.
(sorry if i am asking this in the wrong place)

maybe a "Apple Maps" problem ?

hi @dpa99c
I am using cordova cli 5.1.1 + your latest version from npm +ipad mini 8.4.1(12H321)
well...this is my full code

function checkLaunchNavigator2(action, action2)
{
var options = { preferGoogleMaps: false, transportMode: "driving", enableDebug: false, disableAutoGeolocation: false }

launchnavigator.navigate(action, action2,
 function()
 {
 console.log('success');
 },
 function(error)
 {
 console.log('fail');
 },
 options
);
}

<a onClick="checkLaunchNavigator2('London, UK', 'Manchester, UK');">STEP1</a>
<a onClick="checkLaunchNavigator2([50.279306, -5.163158], [50.342847, -4.749904]);">STEP2</a>

first time,when you use "STEP1",it will show the Apple Maps and have a title "Manchester to London"

 don't close the Apple Maps and change back to your app...

second time,when you click "STEP2",it will show the Apple Maps and have a title "Satrt to Destination"

 change back to your app again...

third time,when you click "STEP1" again,it still show the Apple Maps but still have a old title "Satrt to Destination" and old "Route line"

if I use GoogleMap to instead,it have no this problem
Android and wp8 seem have no this problem too

Phonegap build - IOS not working

Hi I'm using phonegap build to use this plugin it is working perfectly fine on android devices however its not working properly on IOS.

function navigate() { launchnavigator.navigate([25.180047, 55.224282],null,onSuccess,onError); }

This is the code that I'm using which on Android it ask me for the my current location and starts the navigation. However, on IOS the same code opens APPLE MAP but don't ask me for my current location neither carries [25.180047, 55.224282] destination over.

Any idea on why this is happening?

How can i provide source and destination

Hi... your plugin seems option to provide destination.
How can i provide Source and Destination from my app to Google map App for getting the direction.
please guide me.

NSInvalidArgumentException in iOS

I am getting this error in IOS(8.0.2) while trying to launch the plugin . Is this a plugin issue?

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
0x2684df87 0x33e70c77 0x26769ad1 0x26773ae1 0x168601 0x166d07 0xf2925 0xf21af 0xf314b 0x2755c3cf 0x26814807 0x26813c1b 0x26812299 0x2675fdb1 0x2675fbc3 0x2dac4051 0x29d2ba31 0xf82cb 0x3440caaf)
NSException
Process 682 stopped

  • thread #1: tid = 0x4be0, 0x344d1dfc libsystem_kernel.dylib__pthread_kill + 8, queue = 'com.apple.main-thread', stop reason = signal SIGABRT frame #0: 0x344d1dfc libsystem_kernel.dylib__pthread_kill + 8
    libsystem_kernel.dylib`__pthread_kill + 8:
    -> 0x344d1dfc: blo 0x344d1e14 ; __pthread_kill + 32
    0x344d1e00: ldr r12, [pc, #4] ; __pthread_kill + 24
    0x344d1e04: ldr r12, [pc, r12]
    0x344d1e08: b 0x344d1e10 ; __pthread_kill + 28

My js code is
var pickup = this.destination_lat+','+this.destination_long;
var dest = this.pickup_lat+','+this.pickup_long;
launchnavigator.navigate(
dest,
start,
function(){
// alert("Plugin success");
},
function(error){
alert("Maps error: "+ error);
});

[iOS] org.apache.cordova.geolocation required to build?

Hey,

Your plugin is really useful, many thanks for it.

I face a problem, though:

When I try to build my app on iOS, I get the following error:

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_CLLocation", referenced from:
      objc-class-ref in LaunchNavigator.o
  "_OBJC_CLASS_$_CLGeocoder", referenced from:
      objc-class-ref in LaunchNavigator.o
  "_CLLocationCoordinate2DMake", referenced from:
      -[LaunchNavigator setAppleDestination] in LaunchNavigator.o
      -[LaunchNavigator setAppleStart] in LaunchNavigator.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am forced to install org.apache.cordova.geolocation to be able to build it.

This is sad, for two reasons:

  • It is not documented in the README.md
  • I do not need geolocation on my app

What do you think about this?

Error on windows cordova platform ""The app can’t use script to load the bingmaps..."

When building to windows 10 (universal app) and I try to lunch the navigation I get this error:

"The app can’t use script to load the bingmaps:?rtp=pos.40.656_-8.6009~pos.39.912856_-8.435529999999972 url because the url launches another app. Only direct user interaction can launch another app."

var successOpenDirections = function()
{
       return;
 }

 var errorOpenDirections = function(error)
 {
        return;
 }

 var openDirections = function ()
  {
         launchnavigator.navigate(scope.coords, null, successOpenDirections, errorOpenDirections);
  }

Error on iOS.

I'm getting this error while trying to launch the maps app on an iOS device, primarily iPhone 4s, and iPhone 5 (dont have any other phones at my disposal).

2015-05-04 09:00:31.702 FlyBuy[8930:608532] Navigator succesfully launched maps application <-- This is the success callback
2015-05-04 09:00:31.715 FlyBuy[8930:608532] *** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: *** -[NSRegularExpression enumerateMatchesInString:options:range:usingBlock:]: nil argument

And this is the pattern i'm using:

launchnavigator.navigate(
[47.614651 -122.314252],
[47.61528546427107 -122.3148449229748],
function(){
console.log("Navigator succesfully launched maps application");
},
function(error){
console.log("There was an error opening the maps application", error);
});

Any thoughts?

Google Back Button Disappears After 15 seconds

Thank you for the implementing the google preferred and having google call a url with a back button. I was able to get it working and it works great. When you click the back button it takes me right back to my app, but the button goes away in Google Maps after 15 seconds. Any ideas what could be causing that?

Open with option

Hi,

Could be the behaviour similar to when in android is open with google.navigation:?
I mean that is possible to open with navigation apps as citymapper, waze, etc. and you are able to choose with which one open?

Thanks,

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.