GithubHelp home page GithubHelp logo

aducworth / react-native-map-link Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tschoffelen/react-native-map-link

0.0 1.0 0.0 933 KB

๐Ÿ—บ Open the map app of the user's choice.

License: MIT License

JavaScript 100.00%

react-native-map-link's Introduction

React Native Map Link

GitHub release npm GitHub license


An easy way to open a location in a map app of the user's choice, based on the apps they have installed on their device.

Currently supported apps:

  • Apple Maps โ€“ apple-maps
  • Google Maps โ€“ google-maps
  • Citymapper โ€“ citymapper
  • Uber โ€“ uber
  • Lyft โ€“ lyft
  • The Transit App โ€“ transit
  • TruckMap โ€“ truckmap
  • Waze โ€“ waze
  • Yandex.Navi โ€“ yandex
  • Moovit โ€“ moovit
  • Yandex Maps โ€“ yandex-maps
  • Kakao Map โ€“ kakaomap

Installation

1. Install the package

npm i -S react-native-map-link         # or yarn add react-native-map-link

2. Update your Info.plist

To allow your app to detect if any of the directions apps are installed, an extra step is required on iOS. Your app needs to provide the LSApplicationQueriesSchemes key inside ios/{my-project}/Info.plist to specify the URL schemes with which the app can interact.

Just add this in your Info.plist depending on which apps you'd like to support. Omitting these might mean that the library can't detect some of the maps apps installed by the user.

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>comgooglemaps</string>
    <string>citymapper</string>
    <string>uber</string>
    <string>lyft</string>
    <string>transit</string>
    <string>truckmap</string>
    <string>waze</string>
    <string>yandexnavi</string>
    <string>moovit</string>
    <string>yandexmaps</string>
    <string>kakaomap</string>
</array>

Using Expo? Read the instructions to make it work on iOS.

Usage

Using the showLocation function will shown an action sheet on iOS and an alert on Android, without any custom styling:

import { showLocation } from 'react-native-map-link'

showLocation({
    latitude: 38.8976763,
    longitude: -77.0387185,
    sourceLatitude: -8.0870631,  // optionally specify starting location for directions
    sourceLongitude: -34.8941619,  // not optional if sourceLatitude is specified
    title: 'The White House',  // optional
    googleForceLatLon: false,  // optionally force GoogleMaps to use the latlon for the query instead of the title
    googlePlaceId: 'ChIJGVtI4by3t4kRr51d_Qm_x58',  // optionally specify the google-place-id
    alwaysIncludeGoogle: true, // optional, true will always add Google Maps to iOS and open in Safari, even if app is not installed (default: false)
    dialogTitle: 'This is the dialog Title', // optional (default: 'Open in Maps')
    dialogMessage: 'This is the amazing dialog Message', // optional (default: 'What app would you like to use?')
    cancelText: 'This is the cancel button text', // optional (default: 'Cancel')
    appsWhiteList: ['google-maps'] // optionally you can set which apps to show (default: will show all supported apps installed on device)
    // appTitles: { 'google-maps': 'My custom Google Maps title' } // optionally you can override default app titles
    // app: 'uber'  // optionally specify specific app to use
})

Notes:

  • The sourceLatitude/sourceLongitude options only work if you specify both. Currently supports all apps except Waze.

More information

Credits

This library is developed by Lean Motherfuckers, a tech consulting company like no other.

Contributors:

react-native-map-link's People

Contributors

tschoffelen avatar greenkeeper[bot] avatar johanleroch avatar cesar3030 avatar djalmaaraujo avatar hanlitheron avatar gbahamondezc avatar bcalik avatar brunocavallarigois avatar exiam avatar grifotv avatar jpate148 avatar dependabot[bot] avatar davidten avatar adrianchinghc avatar hatko avatar rsokz avatar ntorionbearstudio avatar monjohn avatar maxencehenneron avatar rememberlenny avatar jeremywen3 avatar isacjunior avatar bingneef avatar rollsroyc3 avatar avegrv avatar

Watchers

James Cloos 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.