Content-Length: 515847 | pFad | http://github.com/NativeScript/plugins/commit/ec6d8a4f42f0dfaf80eaed70c472144e812fe912

FD docs(directions): update (#445) · NativeScript/plugins@ec6d8a4 · GitHub
Skip to content

Commit ec6d8a4

Browse files
authored
docs(directions): update (#445)
1 parent 215e785 commit ec6d8a4

File tree

1 file changed

+57
-33
lines changed

1 file changed

+57
-33
lines changed

Diff for: packages/directions/README.md

+57-33
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
11
# @nativescript/directions
22
<!-- TODO: Add Preview -->
3+
4+
A plugin that allows you to launch the Google Maps app, if it's installed on the device, with some directions. For more information, visit [Directions action](https://developers.google.com/maps/documentation/urls/get-started#directions-action).
5+
6+
## Contents
7+
* [Installation](#installation)
8+
* [Use @nativescript/directions](#use-nativescriptdirections)
9+
* [Launch Google Maps with directions](#launch-google-maps-with-directions)
10+
* [Check if the Google Maps app is installed](#check-if-the-google-maps-app-is-installed)
11+
* [API](#api)
12+
* [Directions methods](#directions-methods)
13+
* [NavigateToOptions](#navigatetooptions)
14+
315
## Installation
416

17+
To install the plugin, run the following command in the root directory of your app.
18+
519
```cli
620
npm install @nativescript/directions
721
```
822

9-
## Usage
10-
### Importing
11-
Once you have installed the plugin, import and create an instance of the `Directions` class.
12-
```ts
13-
import { Directions } from "@nativescript/directions"
14-
15-
const directions = new Directions()
16-
```
23+
## Use @nativescript/directions
1724

18-
### Checking for support
25+
### Launch Google Maps with directions
1926

20-
To check if the device has a Maps application installed, call the `available` method.
21-
```ts
22-
directions.available().then((avail:boolean) => {
27+
To launch Google Maps with the desired directions, call the `navigate` method on `Directions` instance passing it a [NavigateToOptions](#navigatetooptions) object.
2328

24-
console.log(avail ? 'Yes' : 'No');
25-
});
26-
```
27-
To open the Google (Android) or Apple (iOS) Maps app with the desired directions, call the `navigate` method.
2829
```typescript
30+
import { Directions } from "@nativescript/directions"
31+
32+
const directions = new Directions()
33+
2934
directions
3035
.navigate({
3136
from: {
@@ -60,28 +65,32 @@ directions
6065
);
6166
```
6267

68+
### Check if the Google Maps app is installed
69+
70+
If you need to check if the Google Maps mobile application is installed on the device, call the `available` method.
71+
72+
```ts
73+
const directions = new Directions()
74+
75+
directions.available().then((avail:boolean) => {
76+
77+
console.log(avail ? 'Yes' : 'No');
78+
});
79+
```
80+
6381
## API
64-
### Method(s)
82+
### Directions methods
83+
84+
The `Directions` class has the following two methods:
6585

66-
| Name | Return Type | Description |
86+
| Method | Returns | Description |
6787
|------|-------------|-------------|
6888
| `available()` | `Promise<boolean>` | Checks if the device has the Maps application installed. |
6989
| `navigate(options: NavigateToOptions)`| `Promise<void>` | Opens the native Maps app with a predefined `from` and `to` address and [other](#navigatetooptions) optional settings.|
7090

71-
### AddressOptions
72-
| Name| Type | Description|
73-
|-----|------|------------|
74-
| `lat` | `number` | _Optional_: The latitude. Ignored if `address`' is set.|
75-
| `lng` | `number` | _Optional_: The longitude. Ignored if `address`' is set. |
76-
| `address` | `string` | _Optional_: The address of the direction. For multiple addresses, add them to the string separating them with a comma.|
77-
78-
### NavigateToOptionsType
79-
```ts
80-
'driving' | 'transit' | 'bicycling' | 'walking'
81-
```
82-
8391
### NavigateToOptions
84-
| Name| Type | Description|
92+
93+
| Property| Type | Description|
8594
|-----|------|------------|
8695
| `from`| [AddressOptions](#addressoptions)| _Optional_: The starting point for the navigation. <br><br>If this option is not passed, the current location of the user will be used.|
8796
| `to` | [AddressOptions](#addressoptions) \| Array<[AddressOptions](#addressoptions)>| The destination of the navigation. If it's an array of addresses, then the last item is the destination, the others become 'waypoints'.|
@@ -91,13 +100,28 @@ directions
91100
| `type` | [NavigateToOptionsType](#navigatetooptionstype) | _Optional_: The mode of reaching to the destionation. |
92101

93102
>**Note** that if there's an ocean in between `from` and `to` you won't be able to get directions, don't blame this plugin for that 😁.
94-
### iOSOptions
103+
104+
#### AddressOptions
105+
106+
| Name| Type | Description|
107+
|-----|------|------------|
108+
| `lat` | `number` | _Optional_: The latitude. Ignored if `address`' is set.|
109+
| `lng` | `number` | _Optional_: The longitude. Ignored if `address`' is set. |
110+
| `address` | `string` | _Optional_: The address of the direction. For multiple addresses, add them to the string separating them with a comma.|
111+
112+
#### NavigateToOptionsType
113+
```ts
114+
'driving' | 'transit' | 'bicycling' | 'walking'
115+
```
116+
117+
#### iOSOptions
95118
| Name| Type | Description|
96119
|-----|------|------------|
97120
| `preferGoogleMaps`| `boolean`| _Optional_: Indicates whether to use Google Maps(if installed) instead of the iOS Maps. You might want to use Google Maps app because it supports waypoints.|
98121
| `allowGoogleMapsWeb`| `boolean` | If waypoints are passed in and Google Maps is not installed, you can either open Apple Maps and the first waypoint is used as the to-address (the rest is ignored), or you can set this option to `true` to open Google Maps on web so all waypoints are shown.|
99122

100-
### AndroidOptions
123+
#### AndroidOptions
124+
101125
| Name| Type | Description|
102126
|-----|------|------------|
103127
| `newTask` | `boolean` | _Optional_: Indicates whether to start directions as new task.|

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/NativeScript/plugins/commit/ec6d8a4f42f0dfaf80eaed70c472144e812fe912

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy