@jacques_gordon/expo-mapbox-navigation 1.0.8 → 2.0.2
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/ExpoMapboxNavigation.podspec +39 -0
- package/LICENSE +21 -0
- package/README.md +103 -209
- package/android/build.gradle +101 -39
- package/android/src/main/java/expo/modules/mapboxnavigation/ExpoMapboxNavigationModule.kt +81 -77
- package/android/src/main/java/expo/modules/mapboxnavigation/ExpoMapboxNavigationView.kt +260 -142
- package/app.plugin.js +216 -1
- package/build/index.d.ts +121 -2
- package/build/index.js +34 -3
- package/build/src/index.d.ts +121 -0
- package/build/src/index.js +39 -0
- package/expo-module.config.json +1 -1
- package/package.json +38 -37
- package/plugin/src/index.js +216 -0
- package/src/index.tsx +162 -0
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/9.2.0/checksums/checksums.lock +0 -0
- package/android/.gradle/9.2.0/fileChanges/last-build.bin +0 -0
- package/android/.gradle/9.2.0/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/9.2.0/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/9.2.0/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/build/MapboxNavigation.types.d.ts +0 -132
- package/build/MapboxNavigation.types.js +0 -2
- package/build/MapboxNavigationView.d.ts +0 -30
- package/build/MapboxNavigationView.js +0 -41
- package/ios/ExpoMapboxNavigation.podspec +0 -25
- package/ios/ExpoMapboxNavigationModule.swift +0 -81
- package/ios/ExpoMapboxNavigationView.swift +0 -236
- package/plugin/index.js +0 -167
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
const { withAppBuildGradle, withProjectBuildGradle, withAndroidManifest, withInfoPlist, withDangerousMod } = require('@expo/config-plugins');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
6
|
+
// Config Plugin for @jacques_gordon/expo-mapbox-navigation
|
|
7
|
+
//
|
|
8
|
+
// This plugin:
|
|
9
|
+
// 1. Adds Mapbox Maven repository to android/build.gradle
|
|
10
|
+
// 2. Forces NDK 27 for 16 KB page size compatibility
|
|
11
|
+
// 3. Enables jniLibs.useLegacyPackaging = false (required for 16 KB pages)
|
|
12
|
+
// 4. Adds Mapbox access token to android resources & iOS Info.plist
|
|
13
|
+
// 5. Adds background location & audio modes for iOS
|
|
14
|
+
// 6. Supports androidColorOverrides for UI theming
|
|
15
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
16
|
+
|
|
17
|
+
const NDK_VERSION = '27.0.12077973';
|
|
18
|
+
const MAPBOX_MAPS_MIN_VERSION = '11.11.0';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {import('@expo/config-plugins').ConfigPlugin<{
|
|
22
|
+
* accessToken: string,
|
|
23
|
+
* mapboxMapsVersion?: string,
|
|
24
|
+
* androidColorOverrides?: Record<string, string>
|
|
25
|
+
* }>}
|
|
26
|
+
*/
|
|
27
|
+
const withMapboxNavigation = (config, options = {}) => {
|
|
28
|
+
const {
|
|
29
|
+
accessToken,
|
|
30
|
+
mapboxMapsVersion = MAPBOX_MAPS_MIN_VERSION,
|
|
31
|
+
androidColorOverrides = {},
|
|
32
|
+
} = options;
|
|
33
|
+
|
|
34
|
+
if (!accessToken) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
'[@jacques_gordon/expo-mapbox-navigation] `accessToken` is required in the plugin config.\n' +
|
|
37
|
+
'Add it to your app.json plugins array:\n' +
|
|
38
|
+
' ["@jacques_gordon/expo-mapbox-navigation", { "accessToken": "pk.your_token" }]'
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Validate mapboxMapsVersion >= 11.11.0
|
|
43
|
+
const [major, minor] = mapboxMapsVersion.split('.').map(Number);
|
|
44
|
+
if (major < 11 || (major === 11 && minor < 11)) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
`[@jacques_gordon/expo-mapbox-navigation] mapboxMapsVersion must be >= 11.11.0.\n` +
|
|
47
|
+
`Provided: ${mapboxMapsVersion}\n` +
|
|
48
|
+
`This minimum version is required to fix the CameraAnimationsUtils crash (issue #43).`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ── Android: project-level build.gradle ─────────────────────────────────
|
|
53
|
+
config = withProjectBuildGradle(config, (mod) => {
|
|
54
|
+
let contents = mod.modResults.contents;
|
|
55
|
+
|
|
56
|
+
// Add Mapbox Maven repo if not already present
|
|
57
|
+
if (!contents.includes('api.mapbox.com/downloads/v2/releases/maven')) {
|
|
58
|
+
const mavenBlock = `
|
|
59
|
+
maven {
|
|
60
|
+
url 'https://api.mapbox.com/downloads/v2/releases/maven'
|
|
61
|
+
authentication { basic(BasicAuthentication) }
|
|
62
|
+
credentials {
|
|
63
|
+
username = 'mapbox'
|
|
64
|
+
password = project.hasProperty('MAPBOX_DOWNLOADS_TOKEN')
|
|
65
|
+
? project.property('MAPBOX_DOWNLOADS_TOKEN')
|
|
66
|
+
: System.getenv('MAPBOX_DOWNLOADS_TOKEN') ?: ""
|
|
67
|
+
}
|
|
68
|
+
}`;
|
|
69
|
+
|
|
70
|
+
// Insert into allprojects.repositories if it exists
|
|
71
|
+
if (contents.includes('allprojects') && contents.includes('repositories')) {
|
|
72
|
+
contents = contents.replace(
|
|
73
|
+
/allprojects\s*\{[\s\S]*?repositories\s*\{/,
|
|
74
|
+
(match) => match + mavenBlock
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
mod.modResults.contents = contents;
|
|
80
|
+
return mod;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// ── Android: app-level build.gradle ─────────────────────────────────────
|
|
84
|
+
config = withAppBuildGradle(config, (mod) => {
|
|
85
|
+
let contents = mod.modResults.contents;
|
|
86
|
+
|
|
87
|
+
// Force NDK 27 for 16 KB page size
|
|
88
|
+
if (!contents.includes('ndkVersion')) {
|
|
89
|
+
contents = contents.replace(
|
|
90
|
+
/android\s*\{/,
|
|
91
|
+
`android {\n ndkVersion "${NDK_VERSION}" // Required for 16 KB page size (expo-mapbox-navigation)`
|
|
92
|
+
);
|
|
93
|
+
} else if (!contents.includes(NDK_VERSION)) {
|
|
94
|
+
// Replace any existing ndkVersion
|
|
95
|
+
contents = contents.replace(
|
|
96
|
+
/ndkVersion\s+["'][^"']*["']/,
|
|
97
|
+
`ndkVersion "${NDK_VERSION}" // Forced by expo-mapbox-navigation for 16KB page size`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Enable useLegacyPackaging = false for 16 KB page alignment
|
|
102
|
+
if (!contents.includes('useLegacyPackaging')) {
|
|
103
|
+
contents = contents.replace(
|
|
104
|
+
/android\s*\{/,
|
|
105
|
+
`android {\n packagingOptions {\n jniLibs {\n useLegacyPackaging = false // 16 KB page size support\n }\n }`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Pin Mapbox Maps version via resolutionStrategy
|
|
110
|
+
const resolutionBlock = `
|
|
111
|
+
configurations.all {
|
|
112
|
+
resolutionStrategy {
|
|
113
|
+
// Force Mapbox Maps SDK >= ${mapboxMapsVersion} — required for NavigationCamera compatibility
|
|
114
|
+
force "com.mapbox.maps:android:${mapboxMapsVersion}"
|
|
115
|
+
}
|
|
116
|
+
}`;
|
|
117
|
+
|
|
118
|
+
if (!contents.includes('com.mapbox.maps:android')) {
|
|
119
|
+
contents = contents + '\n' + resolutionBlock;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
mod.modResults.contents = contents;
|
|
123
|
+
return mod;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// ── Android: AndroidManifest — add access token as meta-data ─────────────
|
|
127
|
+
config = withAndroidManifest(config, (mod) => {
|
|
128
|
+
const mainApp = mod.modResults.manifest.application?.[0];
|
|
129
|
+
if (mainApp) {
|
|
130
|
+
if (!mainApp['meta-data']) {
|
|
131
|
+
mainApp['meta-data'] = [];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const tokenMeta = mainApp['meta-data'].find(
|
|
135
|
+
(m) => m.$?.['android:name'] === 'com.mapbox.token'
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
if (!tokenMeta) {
|
|
139
|
+
mainApp['meta-data'].push({
|
|
140
|
+
$: {
|
|
141
|
+
'android:name': 'com.mapbox.token',
|
|
142
|
+
'android:value': accessToken,
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return mod;
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// ── Android: Write color overrides resource file ──────────────────────────
|
|
151
|
+
if (Object.keys(androidColorOverrides).length > 0) {
|
|
152
|
+
config = withDangerousMod(config, [
|
|
153
|
+
'android',
|
|
154
|
+
async (mod) => {
|
|
155
|
+
const colorsDir = path.join(
|
|
156
|
+
mod.modRequest.platformProjectRoot,
|
|
157
|
+
'app/src/main/res/values'
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
if (!fs.existsSync(colorsDir)) {
|
|
161
|
+
fs.mkdirSync(colorsDir, { recursive: true });
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const colorEntries = Object.entries(androidColorOverrides)
|
|
165
|
+
.map(([name, value]) => ` <color name="${name}">${value}</color>`)
|
|
166
|
+
.join('\n');
|
|
167
|
+
|
|
168
|
+
const colorsXml = `<?xml version="1.0" encoding="utf-8"?>
|
|
169
|
+
<!-- Generated by @jacques_gordon/expo-mapbox-navigation config plugin -->
|
|
170
|
+
<resources>
|
|
171
|
+
${colorEntries}
|
|
172
|
+
</resources>
|
|
173
|
+
`;
|
|
174
|
+
|
|
175
|
+
fs.writeFileSync(
|
|
176
|
+
path.join(colorsDir, 'mapbox_navigation_colors.xml'),
|
|
177
|
+
colorsXml
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
return mod;
|
|
181
|
+
},
|
|
182
|
+
]);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ── iOS: Info.plist ──────────────────────────────────────────────────────
|
|
186
|
+
config = withInfoPlist(config, (mod) => {
|
|
187
|
+
// Mapbox public token
|
|
188
|
+
mod.modResults.MBXAccessToken = accessToken;
|
|
189
|
+
|
|
190
|
+
// Location permissions (required for navigation)
|
|
191
|
+
if (!mod.modResults.NSLocationWhenInUseUsageDescription) {
|
|
192
|
+
mod.modResults.NSLocationWhenInUseUsageDescription =
|
|
193
|
+
'Your location is used for turn-by-turn navigation.';
|
|
194
|
+
}
|
|
195
|
+
if (!mod.modResults.NSLocationAlwaysAndWhenInUseUsageDescription) {
|
|
196
|
+
mod.modResults.NSLocationAlwaysAndWhenInUseUsageDescription =
|
|
197
|
+
'Your location is used for turn-by-turn navigation even when the app is in the background.';
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Background modes required for navigation audio + location tracking
|
|
201
|
+
if (!mod.modResults.UIBackgroundModes) {
|
|
202
|
+
mod.modResults.UIBackgroundModes = [];
|
|
203
|
+
}
|
|
204
|
+
for (const mode of ['audio', 'location']) {
|
|
205
|
+
if (!mod.modResults.UIBackgroundModes.includes(mode)) {
|
|
206
|
+
mod.modResults.UIBackgroundModes.push(mode);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return mod;
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
return config;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
module.exports = withMapboxNavigation;
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import {
|
|
2
|
+
requireNativeViewManager,
|
|
3
|
+
NativeModulesProxy,
|
|
4
|
+
EventEmitter,
|
|
5
|
+
} from 'expo-modules-core';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { ViewStyle, StyleSheet } from 'react-native';
|
|
8
|
+
|
|
9
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
10
|
+
// Types
|
|
11
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
export interface Coordinate {
|
|
14
|
+
latitude: number;
|
|
15
|
+
longitude: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Voice/distance unit system for navigation instructions.
|
|
20
|
+
*
|
|
21
|
+
* Fixes Issue #31: previously always defaulted to imperial.
|
|
22
|
+
* - "metric" → km/m for distances, km/h for speed
|
|
23
|
+
* - "imperial" → mi/ft for distances, mph for speed
|
|
24
|
+
* - undefined → auto-detected from device locale
|
|
25
|
+
*/
|
|
26
|
+
export type VoiceUnits = 'metric' | 'imperial';
|
|
27
|
+
|
|
28
|
+
export type NavigationProfile =
|
|
29
|
+
| 'driving-traffic'
|
|
30
|
+
| 'driving'
|
|
31
|
+
| 'walking'
|
|
32
|
+
| 'cycling';
|
|
33
|
+
|
|
34
|
+
export interface MapboxNavigationViewProps {
|
|
35
|
+
/** Navigation route waypoints. Minimum 2 coordinates required. */
|
|
36
|
+
coordinates: Coordinate[];
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Indices into `coordinates` that are considered waypoints.
|
|
40
|
+
* First and last must be included. Defaults to all points.
|
|
41
|
+
*/
|
|
42
|
+
waypointIndices?: number[];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* BCP-47 language/locale tag for map labels and voice instructions.
|
|
46
|
+
* Example: "fr", "en-US", "de-DE". Defaults to device locale.
|
|
47
|
+
*/
|
|
48
|
+
language?: string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Unit system for voice instructions and distance display.
|
|
52
|
+
* - "metric" → kilometres and metres (default outside US/UK)
|
|
53
|
+
* - "imperial" → miles and feet (default in US/UK)
|
|
54
|
+
* - undefined → auto-detected from device locale
|
|
55
|
+
*
|
|
56
|
+
* Fixes Issue #31.
|
|
57
|
+
*/
|
|
58
|
+
voiceUnits?: VoiceUnits;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Mapbox Directions profile.
|
|
62
|
+
* Android: omit the "mapbox/" prefix (handled internally).
|
|
63
|
+
*/
|
|
64
|
+
navigationProfile?: NavigationProfile;
|
|
65
|
+
|
|
66
|
+
/** Road / feature types to exclude from the route */
|
|
67
|
+
excludeTypes?: string[];
|
|
68
|
+
|
|
69
|
+
/** Mapbox map style URL. Defaults to Mapbox Navigation Day style. */
|
|
70
|
+
mapStyle?: string;
|
|
71
|
+
|
|
72
|
+
/** Whether audio is initially muted. Defaults to false. */
|
|
73
|
+
mute?: boolean;
|
|
74
|
+
|
|
75
|
+
/** Maximum vehicle height in metres (for height-restricted routes). */
|
|
76
|
+
maxHeight?: number;
|
|
77
|
+
|
|
78
|
+
/** Maximum vehicle width in metres (for width-restricted routes). */
|
|
79
|
+
maxWidth?: number;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* When true, uses the Mapbox Map Matching API instead of the
|
|
83
|
+
* standard Directions API. Useful when you want a route that
|
|
84
|
+
* exactly follows the given coordinates.
|
|
85
|
+
*/
|
|
86
|
+
useMapMatching?: boolean;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* URL template for a custom raster tile overlay.
|
|
90
|
+
* Must include {x}, {y}, {z} placeholders.
|
|
91
|
+
* Example: "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
92
|
+
*/
|
|
93
|
+
customRasterTileUrl?: string;
|
|
94
|
+
|
|
95
|
+
/** Map layer ID above which the custom raster layer is placed. */
|
|
96
|
+
customRasterAboveLayerId?: string;
|
|
97
|
+
|
|
98
|
+
// ── Event callbacks ──────────────────────────────────────────────────────
|
|
99
|
+
|
|
100
|
+
onRouteProgressChanged?: (event: { nativeEvent: RouteProgressEvent }) => void;
|
|
101
|
+
onRoutesReady?: (event: { nativeEvent: RoutesReadyEvent }) => void;
|
|
102
|
+
onNavigationFinished?: (event: { nativeEvent: {} }) => void;
|
|
103
|
+
onNavigationCancelled?: (event: { nativeEvent: {} }) => void;
|
|
104
|
+
onRoutesFailed?: (event: { nativeEvent: { message: string } }) => void;
|
|
105
|
+
onArrival?: (event: { nativeEvent: {} }) => void;
|
|
106
|
+
|
|
107
|
+
style?: ViewStyle;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface RouteProgressEvent {
|
|
111
|
+
distanceRemaining: number;
|
|
112
|
+
durationRemaining: number;
|
|
113
|
+
distanceTraveled: number;
|
|
114
|
+
fractionTraveled: number;
|
|
115
|
+
currentStepDistanceRemaining: number;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface RoutesReadyEvent {
|
|
119
|
+
routeCount: number;
|
|
120
|
+
distanceMeters: number;
|
|
121
|
+
durationSeconds: number;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
125
|
+
// Native view
|
|
126
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
127
|
+
|
|
128
|
+
const NativeView = requireNativeViewManager('ExpoMapboxNavigation');
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* MapboxNavigationView
|
|
132
|
+
*
|
|
133
|
+
* Renders the Mapbox Drop-In Navigation UI inside your Expo/React Native app.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```tsx
|
|
137
|
+
* <MapboxNavigationView
|
|
138
|
+
* style={{ flex: 1 }}
|
|
139
|
+
* coordinates={[
|
|
140
|
+
* { latitude: 48.8566, longitude: 2.3522 },
|
|
141
|
+
* { latitude: 51.5074, longitude: -0.1278 },
|
|
142
|
+
* ]}
|
|
143
|
+
* voiceUnits="metric"
|
|
144
|
+
* language="fr"
|
|
145
|
+
* onArrival={() => console.log('Arrived!')}
|
|
146
|
+
* />
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
export function MapboxNavigationView(props: MapboxNavigationViewProps) {
|
|
150
|
+
return (
|
|
151
|
+
<NativeView
|
|
152
|
+
{...props}
|
|
153
|
+
style={[styles.fullSize, props.style]}
|
|
154
|
+
/>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const styles = StyleSheet.create({
|
|
159
|
+
fullSize: { flex: 1 },
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
export default MapboxNavigationView;
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
-
export interface Coordinate {
|
|
3
|
-
latitude: number;
|
|
4
|
-
longitude: number;
|
|
5
|
-
}
|
|
6
|
-
export interface RouteProgress {
|
|
7
|
-
/** Distance restante en mètres */
|
|
8
|
-
distanceRemaining: number;
|
|
9
|
-
/** Distance parcourue en mètres */
|
|
10
|
-
distanceTraveled: number;
|
|
11
|
-
/** Durée restante en secondes */
|
|
12
|
-
durationRemaining: number;
|
|
13
|
-
/** Fraction parcourue (0.0 → 1.0) */
|
|
14
|
-
fractionTraveled: number;
|
|
15
|
-
}
|
|
16
|
-
export interface NativeRouteProgressEvent {
|
|
17
|
-
nativeEvent: RouteProgress;
|
|
18
|
-
}
|
|
19
|
-
export interface NativeWaypointEvent {
|
|
20
|
-
nativeEvent: RouteProgress;
|
|
21
|
-
}
|
|
22
|
-
export interface MapboxNavigationViewProps {
|
|
23
|
-
/** Style du composant (ex: { flex: 1 }) */
|
|
24
|
-
style?: StyleProp<ViewStyle>;
|
|
25
|
-
/**
|
|
26
|
-
* Tableau de coordonnées { latitude, longitude }.
|
|
27
|
-
* Minimum 2 points (départ + destination).
|
|
28
|
-
* Requis.
|
|
29
|
-
*/
|
|
30
|
-
coordinates: Coordinate[];
|
|
31
|
-
/**
|
|
32
|
-
* Indices dans `coordinates` considérés comme des waypoints/destinations intermédiaires.
|
|
33
|
-
* Par défaut, tous les points sont des waypoints.
|
|
34
|
-
* Au moins le premier et le dernier index doivent être inclus.
|
|
35
|
-
*/
|
|
36
|
-
waypointIndices?: number[];
|
|
37
|
-
/**
|
|
38
|
-
* Utilise l'API Map Matching de Mapbox au lieu de l'API Directions standard.
|
|
39
|
-
* Utile pour forcer un trajet suivant exactement les coordonnées fournies.
|
|
40
|
-
* Défaut: false
|
|
41
|
-
*/
|
|
42
|
-
useRouteMatchingApi?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Locale/langue pour les labels de la carte, les directions et la voix.
|
|
45
|
-
* Exemples: "fr", "en", "de", "nl".
|
|
46
|
-
* Par défaut: locale de l'appareil.
|
|
47
|
-
*/
|
|
48
|
-
locale?: string;
|
|
49
|
-
/**
|
|
50
|
-
* Profil de routing Mapbox.
|
|
51
|
-
* iOS: "mapbox/driving-traffic" | "mapbox/driving" | "mapbox/walking" | "mapbox/cycling"
|
|
52
|
-
* Android: "driving-traffic" | "driving" | "walking" | "cycling" (sans "mapbox/" prefix)
|
|
53
|
-
* Défaut: "mapbox/driving-traffic"
|
|
54
|
-
*/
|
|
55
|
-
routeProfile?: string;
|
|
56
|
-
/**
|
|
57
|
-
* Types de routes à exclure du calcul d'itinéraire.
|
|
58
|
-
* Exemples: ["toll", "ferry", "motorway"]
|
|
59
|
-
*/
|
|
60
|
-
routeExcludeList?: string[];
|
|
61
|
-
/**
|
|
62
|
-
* Style de la carte Mapbox.
|
|
63
|
-
* Exemples: "mapbox://styles/mapbox/navigation-day-v1"
|
|
64
|
-
*/
|
|
65
|
-
mapStyle?: string;
|
|
66
|
-
/**
|
|
67
|
-
* Coupe le son de navigation au démarrage.
|
|
68
|
-
* Défaut: false
|
|
69
|
-
*/
|
|
70
|
-
mute?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Hauteur maximale du véhicule en mètres.
|
|
73
|
-
* Permet d'éviter les routes avec restriction de hauteur.
|
|
74
|
-
*/
|
|
75
|
-
vehicleMaxHeight?: number;
|
|
76
|
-
/**
|
|
77
|
-
* Largeur maximale du véhicule en mètres.
|
|
78
|
-
* Permet d'éviter les routes avec restriction de largeur.
|
|
79
|
-
*/
|
|
80
|
-
vehicleMaxWidth?: number;
|
|
81
|
-
/**
|
|
82
|
-
* URL d'une source raster personnalisée pour la carte.
|
|
83
|
-
* Doit être une URL template avec {x}, {y}, {z}.
|
|
84
|
-
* Exemple: "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
85
|
-
*/
|
|
86
|
-
customRasterSourceUrl?: string;
|
|
87
|
-
/**
|
|
88
|
-
* ID du layer au-dessus duquel placer le layer raster personnalisé.
|
|
89
|
-
*/
|
|
90
|
-
placeCustomRasterLayerAbove?: string;
|
|
91
|
-
/**
|
|
92
|
-
* Désactive le calcul et l'affichage des routes alternatives.
|
|
93
|
-
* Défaut: false
|
|
94
|
-
*/
|
|
95
|
-
disableAlternativeRoutes?: boolean;
|
|
96
|
-
/**
|
|
97
|
-
* Affiche l'UI de feedback en fin de route.
|
|
98
|
-
* Défaut: false
|
|
99
|
-
*/
|
|
100
|
-
showsEndOfRouteFeedback?: boolean;
|
|
101
|
-
/**
|
|
102
|
-
* Appelé régulièrement avec la progression sur la route.
|
|
103
|
-
* L'objet est dans event.nativeEvent.
|
|
104
|
-
*/
|
|
105
|
-
onRouteProgressChanged?: (event: NativeRouteProgressEvent) => void;
|
|
106
|
-
/**
|
|
107
|
-
* Appelé quand l'utilisateur arrive à un waypoint intermédiaire.
|
|
108
|
-
* Sur Android uniquement: fournit les données de progression dans event.nativeEvent.
|
|
109
|
-
*/
|
|
110
|
-
onWaypointArrival?: (event: NativeWaypointEvent) => void;
|
|
111
|
-
/**
|
|
112
|
-
* Appelé quand l'utilisateur arrive à la destination finale.
|
|
113
|
-
*/
|
|
114
|
-
onFinalDestinationArrival?: () => void;
|
|
115
|
-
/**
|
|
116
|
-
* Appelé quand l'utilisateur appuie sur le bouton d'annulation.
|
|
117
|
-
* La navigation ne se ferme pas automatiquement — gérer manuellement (ex: navigation.goBack()).
|
|
118
|
-
*/
|
|
119
|
-
onCancelNavigation?: (event?: any) => void;
|
|
120
|
-
/**
|
|
121
|
-
* Appelé quand la route change ou qu'un reroutage est effectué.
|
|
122
|
-
*/
|
|
123
|
-
onRouteChanged?: () => void;
|
|
124
|
-
/**
|
|
125
|
-
* Appelé quand l'utilisateur sort de la route.
|
|
126
|
-
*/
|
|
127
|
-
onUserOffRoute?: () => void;
|
|
128
|
-
/**
|
|
129
|
-
* Appelé quand les routes sont chargées et prêtes.
|
|
130
|
-
*/
|
|
131
|
-
onRoutesLoaded?: () => void;
|
|
132
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { MapboxNavigationViewProps } from './MapboxNavigation.types';
|
|
3
|
-
/**
|
|
4
|
-
* MapboxNavigationView
|
|
5
|
-
*
|
|
6
|
-
* Composant de navigation Mapbox turn-by-turn pour Expo SDK 53+.
|
|
7
|
-
* Requiert Expo Dev Client (incompatible avec Expo Go).
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```tsx
|
|
11
|
-
* <MapboxNavigationView
|
|
12
|
-
* style={{ flex: 1 }}
|
|
13
|
-
* coordinates={[
|
|
14
|
-
* { latitude: 48.8566, longitude: 2.3522 }, // Paris (départ)
|
|
15
|
-
* { latitude: 45.7640, longitude: 4.8357 }, // Lyon (waypoint)
|
|
16
|
-
* { latitude: 43.2965, longitude: 5.3698 }, // Marseille (destination)
|
|
17
|
-
* ]}
|
|
18
|
-
* locale="fr"
|
|
19
|
-
* vehicleMaxHeight={5.0}
|
|
20
|
-
* vehicleMaxWidth={2.5}
|
|
21
|
-
* onRouteProgressChanged={(event) => {
|
|
22
|
-
* const { distanceRemaining, durationRemaining } = event.nativeEvent;
|
|
23
|
-
* console.log(`${(distanceRemaining / 1000).toFixed(1)} km restants`);
|
|
24
|
-
* }}
|
|
25
|
-
* onFinalDestinationArrival={() => console.log('Arrivé !')}
|
|
26
|
-
* onCancelNavigation={() => navigation.goBack()}
|
|
27
|
-
* />
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export default function MapboxNavigationView(props: MapboxNavigationViewProps): React.JSX.Element;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = MapboxNavigationView;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const expo_modules_core_1 = require("expo-modules-core");
|
|
9
|
-
const NativeView = (0, expo_modules_core_1.requireNativeViewManager)('ExpoMapboxNavigation');
|
|
10
|
-
/**
|
|
11
|
-
* MapboxNavigationView
|
|
12
|
-
*
|
|
13
|
-
* Composant de navigation Mapbox turn-by-turn pour Expo SDK 53+.
|
|
14
|
-
* Requiert Expo Dev Client (incompatible avec Expo Go).
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```tsx
|
|
18
|
-
* <MapboxNavigationView
|
|
19
|
-
* style={{ flex: 1 }}
|
|
20
|
-
* coordinates={[
|
|
21
|
-
* { latitude: 48.8566, longitude: 2.3522 }, // Paris (départ)
|
|
22
|
-
* { latitude: 45.7640, longitude: 4.8357 }, // Lyon (waypoint)
|
|
23
|
-
* { latitude: 43.2965, longitude: 5.3698 }, // Marseille (destination)
|
|
24
|
-
* ]}
|
|
25
|
-
* locale="fr"
|
|
26
|
-
* vehicleMaxHeight={5.0}
|
|
27
|
-
* vehicleMaxWidth={2.5}
|
|
28
|
-
* onRouteProgressChanged={(event) => {
|
|
29
|
-
* const { distanceRemaining, durationRemaining } = event.nativeEvent;
|
|
30
|
-
* console.log(`${(distanceRemaining / 1000).toFixed(1)} km restants`);
|
|
31
|
-
* }}
|
|
32
|
-
* onFinalDestinationArrival={() => console.log('Arrivé !')}
|
|
33
|
-
* onCancelNavigation={() => navigation.goBack()}
|
|
34
|
-
* />
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
function MapboxNavigationView(props) {
|
|
38
|
-
return (<NativeView
|
|
39
|
-
// Valeurs par défaut
|
|
40
|
-
mute={false} useRouteMatchingApi={false} disableAlternativeRoutes={false} showsEndOfRouteFeedback={false} waypointIndices={[]} routeExcludeList={[]} {...props}/>);
|
|
41
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
Pod::Spec.new do |s|
|
|
2
|
-
s.name = 'ExpoMapboxNavigation'
|
|
3
|
-
s.version = '1.0.0'
|
|
4
|
-
s.summary = 'Expo module for Mapbox turn-by-turn navigation — iOS & Android'
|
|
5
|
-
s.homepage = 'https://github.com/YOUR_GITHUB/expo-mapbox-navigation'
|
|
6
|
-
s.license = { :type => 'MIT' }
|
|
7
|
-
s.authors = { 'Your Name' => 'you@example.com' }
|
|
8
|
-
s.platforms = { :ios => '14.0' }
|
|
9
|
-
s.swift_version = '5.7'
|
|
10
|
-
s.source = { :git => '' }
|
|
11
|
-
|
|
12
|
-
s.static_framework = true
|
|
13
|
-
|
|
14
|
-
s.dependency 'ExpoModulesCore'
|
|
15
|
-
# MapboxNavigationUIKit + MapboxNavigationCore are bundled as .xcframework
|
|
16
|
-
# See README for how to build them from source
|
|
17
|
-
|
|
18
|
-
s.source_files = '*.{swift,h,m,mm,cpp}'
|
|
19
|
-
s.preserve_paths = 'Frameworks/**/*'
|
|
20
|
-
|
|
21
|
-
s.pod_target_xcconfig = {
|
|
22
|
-
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) $(PODS_TARGET_SRCROOT)/Frameworks/**',
|
|
23
|
-
'OTHER_LDFLAGS' => '$(inherited) -framework MapboxNavigationUIKit -framework MapboxNavigationCore -framework MapboxNavigationNative -framework MapboxDirections'
|
|
24
|
-
}
|
|
25
|
-
end
|