@atomiqlab/react-native-mapbox-navigation 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -29
- package/app.plugin.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
# @atomiqlab/react-native-mapbox-navigation
|
|
2
2
|
|
|
3
|
-
Native Mapbox turn-by-turn navigation
|
|
3
|
+
Native Mapbox turn-by-turn navigation for Expo apps on iOS and Android.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Features
|
|
6
6
|
|
|
7
|
-
- Full-screen native navigation
|
|
8
|
-
- Embedded native navigation
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
7
|
+
- Full-screen native navigation via `startNavigation`.
|
|
8
|
+
- Embedded native navigation UI via `MapboxNavigationView`.
|
|
9
|
+
- Real-time events: location, route progress, banner instruction, arrival, cancel, and error.
|
|
10
|
+
- Runtime controls for mute, voice volume, distance unit, and language.
|
|
11
|
+
- Navigation customization: camera mode/pitch/zoom, theme, map style, and UI visibility toggles.
|
|
12
|
+
- Expo config plugin that applies required Android and iOS native setup.
|
|
13
|
+
|
|
14
|
+
## Requirements
|
|
15
|
+
|
|
16
|
+
- Expo SDK `>=50`
|
|
17
|
+
- iOS `14+`
|
|
18
|
+
- Mapbox access credentials:
|
|
19
|
+
- Public token (`pk...`)
|
|
20
|
+
- Downloads token (`sk...`) with `DOWNLOADS:READ`
|
|
12
21
|
|
|
13
22
|
## Installation
|
|
14
23
|
|
|
15
24
|
```bash
|
|
16
25
|
npm install @atomiqlab/react-native-mapbox-navigation
|
|
17
|
-
npx expo install expo-build-properties
|
|
18
26
|
```
|
|
19
27
|
|
|
20
|
-
## Expo
|
|
28
|
+
## Expo Setup
|
|
21
29
|
|
|
22
|
-
Add plugin in app config:
|
|
30
|
+
Add the plugin in your app config (`app.json` or `app.config.js`):
|
|
23
31
|
|
|
24
32
|
```json
|
|
25
33
|
{
|
|
@@ -31,18 +39,18 @@ Add plugin in app config:
|
|
|
31
39
|
}
|
|
32
40
|
```
|
|
33
41
|
|
|
34
|
-
|
|
42
|
+
Set these environment variables:
|
|
35
43
|
|
|
36
|
-
- `EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN
|
|
37
|
-
- `MAPBOX_DOWNLOADS_TOKEN
|
|
44
|
+
- `EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN` (Mapbox public token)
|
|
45
|
+
- `MAPBOX_DOWNLOADS_TOKEN` (Mapbox downloads token)
|
|
38
46
|
|
|
39
|
-
|
|
47
|
+
Regenerate native projects:
|
|
40
48
|
|
|
41
49
|
```bash
|
|
42
50
|
npx expo prebuild --clean
|
|
43
51
|
```
|
|
44
52
|
|
|
45
|
-
## Quick
|
|
53
|
+
## Quick Start
|
|
46
54
|
|
|
47
55
|
```ts
|
|
48
56
|
import {
|
|
@@ -60,11 +68,14 @@ await startNavigation({
|
|
|
60
68
|
destination: { latitude: 37.7847, longitude: -122.4073, name: "Downtown" },
|
|
61
69
|
startOrigin: { latitude: 37.7749, longitude: -122.4194 },
|
|
62
70
|
shouldSimulateRoute: true,
|
|
71
|
+
routeAlternatives: true,
|
|
63
72
|
cameraMode: "following",
|
|
64
73
|
uiTheme: "system",
|
|
74
|
+
distanceUnit: "metric",
|
|
75
|
+
language: "en",
|
|
65
76
|
});
|
|
66
77
|
|
|
67
|
-
const
|
|
78
|
+
const subscriptions = [
|
|
68
79
|
addLocationChangeListener((location) => console.log(location)),
|
|
69
80
|
addRouteProgressChangeListener((progress) => console.log(progress)),
|
|
70
81
|
addBannerInstructionListener((instruction) => console.log(instruction.primaryText)),
|
|
@@ -74,11 +85,11 @@ const subs = [
|
|
|
74
85
|
];
|
|
75
86
|
|
|
76
87
|
// Cleanup
|
|
77
|
-
|
|
88
|
+
subscriptions.forEach((sub) => sub.remove());
|
|
78
89
|
await stopNavigation();
|
|
79
90
|
```
|
|
80
91
|
|
|
81
|
-
## Embedded View
|
|
92
|
+
## Embedded Navigation View
|
|
82
93
|
|
|
83
94
|
```tsx
|
|
84
95
|
import { MapboxNavigationView } from "@atomiqlab/react-native-mapbox-navigation";
|
|
@@ -89,13 +100,16 @@ import { MapboxNavigationView } from "@atomiqlab/react-native-mapbox-navigation"
|
|
|
89
100
|
startOrigin={{ latitude: 37.7749, longitude: -122.4194 }}
|
|
90
101
|
shouldSimulateRoute
|
|
91
102
|
cameraMode="following"
|
|
103
|
+
showsTripProgress
|
|
92
104
|
onBannerInstruction={(instruction) => console.log(instruction.primaryText)}
|
|
105
|
+
onRouteProgressChange={(progress) => console.log(progress.fractionTraveled)}
|
|
106
|
+
onError={(error) => console.warn(error.message)}
|
|
93
107
|
/>;
|
|
94
108
|
```
|
|
95
109
|
|
|
96
|
-
## API
|
|
110
|
+
## API Overview
|
|
97
111
|
|
|
98
|
-
|
|
112
|
+
Core functions:
|
|
99
113
|
|
|
100
114
|
- `startNavigation(options)`
|
|
101
115
|
- `stopNavigation()`
|
|
@@ -106,7 +120,7 @@ import { MapboxNavigationView } from "@atomiqlab/react-native-mapbox-navigation"
|
|
|
106
120
|
- `setDistanceUnit(unit)`
|
|
107
121
|
- `setLanguage(language)`
|
|
108
122
|
|
|
109
|
-
|
|
123
|
+
Event listeners:
|
|
110
124
|
|
|
111
125
|
- `addLocationChangeListener(listener)`
|
|
112
126
|
- `addRouteProgressChangeListener(listener)`
|
|
@@ -115,17 +129,17 @@ import { MapboxNavigationView } from "@atomiqlab/react-native-mapbox-navigation"
|
|
|
115
129
|
- `addCancelNavigationListener(listener)`
|
|
116
130
|
- `addErrorListener(listener)`
|
|
117
131
|
|
|
118
|
-
|
|
132
|
+
Main `NavigationOptions` fields:
|
|
119
133
|
|
|
120
|
-
-
|
|
134
|
+
- Route: `destination`, `startOrigin`, `waypoints`, `routeAlternatives`, `shouldSimulateRoute`
|
|
121
135
|
- Camera: `cameraMode`, `cameraPitch`, `cameraZoom`
|
|
122
136
|
- Theme/style: `uiTheme`, `mapStyleUri`, `mapStyleUriDay`, `mapStyleUriNight`
|
|
123
|
-
- Guidance
|
|
124
|
-
-
|
|
137
|
+
- Guidance: `distanceUnit`, `language`, `mute`, `voiceVolume`
|
|
138
|
+
- UI toggles: `showsSpeedLimits`, `showsWayNameLabel`, `showsTripProgress`, `showsManeuverView`, `showsActionButtons`
|
|
125
139
|
|
|
126
|
-
Full
|
|
140
|
+
Full types: `src/MapboxNavigation.types.ts`
|
|
127
141
|
|
|
128
|
-
## Platform
|
|
142
|
+
## Platform Notes
|
|
129
143
|
|
|
130
|
-
- Android: `startOrigin` optional
|
|
131
|
-
- iOS: `startOrigin` optional
|
|
144
|
+
- Android: `startOrigin` is optional (current location is supported).
|
|
145
|
+
- iOS: `startOrigin` is optional (current location is resolved at runtime with location permission).
|
package/app.plugin.js
CHANGED
package/package.json
CHANGED