You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/directions/README.md
+57-33
Original file line number
Diff line number
Diff line change
@@ -1,31 +1,36 @@
1
1
# @nativescript/directions
2
2
<!-- 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).
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.
23
28
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.
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 =newDirections()
74
+
75
+
directions.available().then((avail:boolean) => {
76
+
77
+
console.log(avail?'Yes':'No');
78
+
});
79
+
```
80
+
63
81
## API
64
-
### Method(s)
82
+
### Directions methods
83
+
84
+
The `Directions` class has the following two methods:
65
85
66
-
|Name|Return Type| Description |
86
+
|Method|Returns| Description |
67
87
|------|-------------|-------------|
68
88
|`available()`|`Promise<boolean>`| Checks if the device has the Maps application installed. |
69
89
|`navigate(options: NavigateToOptions)`|`Promise<void>`| Opens the native Maps app with a predefined `from` and `to` address and [other](#navigatetooptions) optional settings.|
70
90
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
-
83
91
### NavigateToOptions
84
-
| Name| Type | Description|
92
+
93
+
| Property| Type | Description|
85
94
|-----|------|------------|
86
95
|`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.|
87
96
|`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
91
100
|`type`|[NavigateToOptionsType](#navigatetooptionstype)|_Optional_: The mode of reaching to the destionation. |
92
101
93
102
>**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
95
118
| Name| Type | Description|
96
119
|-----|------|------------|
97
120
|`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.|
98
121
|`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.|
99
122
100
-
### AndroidOptions
123
+
#### AndroidOptions
124
+
101
125
| Name| Type | Description|
102
126
|-----|------|------------|
103
127
|`newTask`|`boolean`|_Optional_: Indicates whether to start directions as new task.|
0 commit comments