expo-gaode-map-navigation 1.0.1-next.0 → 1.0.1-next.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/README.md +117 -28
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapModule.kt +7 -0
- package/android/src/main/java/expo/modules/gaodemap/map/modules/SDKInitializer.kt +38 -3
- package/build/map/ExpoGaodeMapModule.js +5 -5
- package/ios/map/ExpoGaodeMapModule.swift +22 -6
- package/package.json +13 -6
- package/package.json.backup +0 -47
- package/plugin/README.md +0 -52
- package/plugin/build/withGaodeMap.d.ts +0 -22
- package/plugin/build/withGaodeMap.js +0 -169
- package/plugin/src/withGaodeMap.ts +0 -231
- package/plugin/tsconfig.tsbuildinfo +0 -1
- package/src/ExpoGaodeMapNaviView.tsx +0 -94
- package/src/ExpoGaodeMapNavigation.types.ts +0 -3
- package/src/ExpoGaodeMapNavigationModule.ts +0 -11
- package/src/index.ts +0 -262
- package/src/map/ExpoGaodeMap.types.ts +0 -46
- package/src/map/ExpoGaodeMapModule.ts +0 -315
- package/src/map/ExpoGaodeMapView.tsx +0 -120
- package/src/map/components/overlays/Circle.tsx +0 -20
- package/src/map/components/overlays/Cluster.tsx +0 -26
- package/src/map/components/overlays/HeatMap.tsx +0 -27
- package/src/map/components/overlays/Marker.tsx +0 -88
- package/src/map/components/overlays/MultiPoint.tsx +0 -27
- package/src/map/components/overlays/Polygon.tsx +0 -19
- package/src/map/components/overlays/Polyline.tsx +0 -19
- package/src/map/components/overlays/index.ts +0 -7
- package/src/map/index.ts +0 -37
- package/src/map/types/common.types.ts +0 -126
- package/src/map/types/index.ts +0 -55
- package/src/map/types/location.types.ts +0 -368
- package/src/map/types/map-view.types.ts +0 -281
- package/src/map/types/overlays.types.ts +0 -404
- package/src/map/utils/EventManager.ts +0 -23
- package/src/map/utils/ModuleLoader.ts +0 -115
- package/src/types/coordinates.types.ts +0 -25
- package/src/types/independent.types.ts +0 -288
- package/src/types/index.ts +0 -5
- package/src/types/naviview.types.ts +0 -330
- package/src/types/route.types.ts +0 -305
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ConfigPlugin,
|
|
3
|
-
withInfoPlist,
|
|
4
|
-
withAndroidManifest,
|
|
5
|
-
withAppBuildGradle,
|
|
6
|
-
createRunOncePlugin,
|
|
7
|
-
WarningAggregator,
|
|
8
|
-
} from '@expo/config-plugins';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 高德地图插件配置类型
|
|
12
|
-
*/
|
|
13
|
-
export type GaodeMapPluginProps = {
|
|
14
|
-
/** iOS 平台 API Key */
|
|
15
|
-
iosApiKey?: string;
|
|
16
|
-
/** Android 平台 API Key */
|
|
17
|
-
androidApiKey?: string;
|
|
18
|
-
/** 是否启用定位功能 */
|
|
19
|
-
enableLocation?: boolean;
|
|
20
|
-
/** iOS 定位权限描述 */
|
|
21
|
-
locationDescription?: string;
|
|
22
|
-
/** 是否启用后台定位(Android & iOS) */
|
|
23
|
-
enableBackgroundLocation?: boolean;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* iOS: 修改 Info.plist 添加 API Key 和权限
|
|
28
|
-
*/
|
|
29
|
-
const withGaodeMapInfoPlist: ConfigPlugin<GaodeMapPluginProps> = (config, props) => {
|
|
30
|
-
return withInfoPlist(config, (config) => {
|
|
31
|
-
// 添加高德地图 API Key
|
|
32
|
-
if (props.iosApiKey) {
|
|
33
|
-
config.modResults.AMapApiKey = props.iosApiKey;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// 添加定位相关权限
|
|
37
|
-
if (props.enableLocation !== false) {
|
|
38
|
-
const description = props.locationDescription || '需要访问您的位置信息以提供地图服务';
|
|
39
|
-
|
|
40
|
-
// 使用时定位权限(必需)
|
|
41
|
-
config.modResults.NSLocationWhenInUseUsageDescription = description;
|
|
42
|
-
|
|
43
|
-
// 后台定位权限(可选)
|
|
44
|
-
if (props.enableBackgroundLocation) {
|
|
45
|
-
config.modResults.NSLocationAlwaysUsageDescription = description;
|
|
46
|
-
config.modResults.NSLocationAlwaysAndWhenInUseUsageDescription = description;
|
|
47
|
-
|
|
48
|
-
// 添加后台定位模式
|
|
49
|
-
if (!config.modResults.UIBackgroundModes) {
|
|
50
|
-
config.modResults.UIBackgroundModes = [];
|
|
51
|
-
}
|
|
52
|
-
if (!config.modResults.UIBackgroundModes.includes('location')) {
|
|
53
|
-
config.modResults.UIBackgroundModes.push('location');
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return config;
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* iOS: 注意 - 不再需要修改 AppDelegate
|
|
64
|
-
*
|
|
65
|
-
* 高德地图 SDK 已经支持从 Info.plist 自动读取 API Key
|
|
66
|
-
* 并且我们在 ExpoGaodeMapModule.swift 中提供了 initSDK 方法
|
|
67
|
-
* 用户可以选择以下任一方式初始化:
|
|
68
|
-
* 1. 通过 Info.plist 中的 AMapApiKey 字段(自动读取)
|
|
69
|
-
* 2. 通过 JavaScript 调用 ExpoGaodeMap.initSDK({ iosKey: 'your-key' })
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Android: 修改 AndroidManifest.xml 添加 API Key 和权限
|
|
74
|
-
*/
|
|
75
|
-
const withGaodeMapAndroidManifest: ConfigPlugin<GaodeMapPluginProps> = (config, props) => {
|
|
76
|
-
return withAndroidManifest(config, (config) => {
|
|
77
|
-
const androidManifest = config.modResults.manifest;
|
|
78
|
-
|
|
79
|
-
// 添加基础权限(高德地图 SDK 必需)
|
|
80
|
-
const basePermissions = [
|
|
81
|
-
'android.permission.ACCESS_COARSE_LOCATION',
|
|
82
|
-
'android.permission.ACCESS_FINE_LOCATION',
|
|
83
|
-
'android.permission.ACCESS_NETWORK_STATE',
|
|
84
|
-
'android.permission.ACCESS_WIFI_STATE',
|
|
85
|
-
'android.permission.READ_PHONE_STATE',
|
|
86
|
-
'android.permission.BLUETOOTH',
|
|
87
|
-
'android.permission.BLUETOOTH_ADMIN',
|
|
88
|
-
];
|
|
89
|
-
|
|
90
|
-
if (!androidManifest['uses-permission']) {
|
|
91
|
-
androidManifest['uses-permission'] = [];
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
basePermissions.forEach((permission) => {
|
|
95
|
-
const hasPermission = androidManifest['uses-permission']?.some(
|
|
96
|
-
(item) => item.$?.['android:name'] === permission
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
if (!hasPermission) {
|
|
100
|
-
androidManifest['uses-permission']?.push({
|
|
101
|
-
$: { 'android:name': permission },
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// 后台定位权限(可选,仅在 enableBackgroundLocation 为 true 时添加)
|
|
107
|
-
if (props.enableBackgroundLocation) {
|
|
108
|
-
const backgroundPermissions = [
|
|
109
|
-
'android.permission.ACCESS_BACKGROUND_LOCATION',
|
|
110
|
-
'android.permission.FOREGROUND_SERVICE',
|
|
111
|
-
'android.permission.FOREGROUND_SERVICE_LOCATION',
|
|
112
|
-
];
|
|
113
|
-
|
|
114
|
-
if (!androidManifest['uses-permission']) {
|
|
115
|
-
androidManifest['uses-permission'] = [];
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
backgroundPermissions.forEach((permission) => {
|
|
119
|
-
const hasPermission = androidManifest['uses-permission']?.some(
|
|
120
|
-
(item) => item.$?.['android:name'] === permission
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
if (!hasPermission) {
|
|
124
|
-
androidManifest['uses-permission']?.push({
|
|
125
|
-
$: { 'android:name': permission },
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// 添加前台服务(如果启用后台定位)
|
|
132
|
-
const mainApplication = androidManifest.application?.[0];
|
|
133
|
-
if (mainApplication && props.enableBackgroundLocation) {
|
|
134
|
-
if (!mainApplication['service']) {
|
|
135
|
-
mainApplication['service'] = [];
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// 检查是否已存在 LocationForegroundService
|
|
139
|
-
const hasService = mainApplication['service'].some(
|
|
140
|
-
(item) => item.$?.['android:name'] === 'expo.modules.gaodemap.services.LocationForegroundService'
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
if (!hasService) {
|
|
144
|
-
mainApplication['service'].push({
|
|
145
|
-
$: {
|
|
146
|
-
'android:name': 'expo.modules.gaodemap.services.LocationForegroundService',
|
|
147
|
-
'android:enabled': 'true',
|
|
148
|
-
'android:exported': 'false',
|
|
149
|
-
'android:foregroundServiceType': 'location',
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// 添加 API Key 到 application 标签
|
|
156
|
-
if (mainApplication && props.androidApiKey) {
|
|
157
|
-
if (!mainApplication['meta-data']) {
|
|
158
|
-
mainApplication['meta-data'] = [];
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// 检查是否已存在
|
|
162
|
-
const hasApiKey = mainApplication['meta-data'].some(
|
|
163
|
-
(item) => item.$?.['android:name'] === 'com.amap.api.v2.apikey'
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
if (!hasApiKey) {
|
|
167
|
-
mainApplication['meta-data'].push({
|
|
168
|
-
$: {
|
|
169
|
-
'android:name': 'com.amap.api.v2.apikey',
|
|
170
|
-
'android:value': props.androidApiKey,
|
|
171
|
-
},
|
|
172
|
-
});
|
|
173
|
-
} else {
|
|
174
|
-
// 更新现有的 API Key
|
|
175
|
-
const apiKeyIndex = mainApplication['meta-data'].findIndex(
|
|
176
|
-
(item) => item.$?.['android:name'] === 'com.amap.api.v2.apikey'
|
|
177
|
-
);
|
|
178
|
-
if (apiKeyIndex !== -1) {
|
|
179
|
-
mainApplication['meta-data'][apiKeyIndex].$ = {
|
|
180
|
-
'android:name': 'com.amap.api.v2.apikey',
|
|
181
|
-
'android:value': props.androidApiKey,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return config;
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Android: 修改 app/build.gradle(预留扩展)
|
|
193
|
-
*/
|
|
194
|
-
const withGaodeMapAppBuildGradle: ConfigPlugin<GaodeMapPluginProps> = (config, props) => {
|
|
195
|
-
return withAppBuildGradle(config, (config) => {
|
|
196
|
-
// Android 3D 地图 SDK 10.0+ 已内置搜索功能
|
|
197
|
-
// 不需要额外的 Gradle 配置
|
|
198
|
-
return config;
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* 主插件函数 - 组合所有修改器
|
|
204
|
-
*/
|
|
205
|
-
const withGaodeMap: ConfigPlugin<GaodeMapPluginProps> = (config, props = {}) => {
|
|
206
|
-
// 验证配置
|
|
207
|
-
if (!props.iosApiKey && !props.androidApiKey) {
|
|
208
|
-
WarningAggregator.addWarningIOS(
|
|
209
|
-
'expo-gaode-map-navigation',
|
|
210
|
-
'未配置 API Key。请在 app.json 的 plugins 中配置 iosApiKey 和 androidApiKey'
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// 应用 iOS 配置
|
|
215
|
-
config = withGaodeMapInfoPlist(config, props);
|
|
216
|
-
// 注意:不再需要修改 AppDelegate,因为:
|
|
217
|
-
// 1. SDK 会自动从 Info.plist 读取 AMapApiKey
|
|
218
|
-
// 2. 可以通过 ExpoGaodeMapModule.initSDK() 方法初始化
|
|
219
|
-
|
|
220
|
-
// 应用 Android 配置
|
|
221
|
-
config = withGaodeMapAndroidManifest(config, props);
|
|
222
|
-
config = withGaodeMapAppBuildGradle(config, props);
|
|
223
|
-
|
|
224
|
-
return config;
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* 导出为可运行一次的插件
|
|
229
|
-
* 这确保插件只会运行一次,即使在配置中被多次引用
|
|
230
|
-
*/
|
|
231
|
-
export default createRunOncePlugin(withGaodeMap, 'expo-gaode-map-navigation', '1.0.0');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["./src/withgaodemap.ts"],"version":"5.9.3"}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
3
|
-
* @Date : 2025-12-03 20:12:54
|
|
4
|
-
* @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
5
|
-
* @LastEditTime : 2025-12-05 12:37:28
|
|
6
|
-
* @FilePath : /expo-gaode-map/packages/navigation/src/ExpoGaodeMapNaviView.tsx
|
|
7
|
-
* @Description :
|
|
8
|
-
*
|
|
9
|
-
* Copyright (c) 2025 by 尚博信_王强, All Rights Reserved.
|
|
10
|
-
*/
|
|
11
|
-
import { requireNativeViewManager } from 'expo-modules-core';
|
|
12
|
-
import * as React from 'react';
|
|
13
|
-
import type { Coordinates, NaviViewProps } from './types';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* NaviView Ref 类型
|
|
17
|
-
*/
|
|
18
|
-
export interface NaviViewRef {
|
|
19
|
-
/**
|
|
20
|
-
* 开始导航
|
|
21
|
-
*/
|
|
22
|
-
startNavigation: (start: Coordinates | null, end: Coordinates, type: number) => Promise<void>;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 停止导航
|
|
26
|
-
*/
|
|
27
|
-
stopNavigation: () => Promise<void>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const NativeView: React.ComponentType<NaviViewProps & { ref?: React.Ref<any> }> = requireNativeViewManager('ExpoGaodeMapNaviView');
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 高德导航视图组件
|
|
35
|
-
*
|
|
36
|
-
* 使用高德官方的导航界面,提供完整的导航体验,包括:
|
|
37
|
-
* - 路线规划和显示
|
|
38
|
-
* - 实时导航信息(距离、时间、道路名称)
|
|
39
|
-
* - 转向箭头和提示
|
|
40
|
-
* - 路况信息
|
|
41
|
-
* - 摄像头提示
|
|
42
|
-
* - 语音播报
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```tsx
|
|
46
|
-
* import { NaviView } from 'expo-gaode-map-navigation';
|
|
47
|
-
*
|
|
48
|
-
* function NavigationScreen() {
|
|
49
|
-
* return (
|
|
50
|
-
* <NaviView
|
|
51
|
-
* style={{ flex: 1 }}
|
|
52
|
-
* naviType={0} // GPS 导航
|
|
53
|
-
* showCamera={true}
|
|
54
|
-
* enableVoice={true}
|
|
55
|
-
* onNaviInfoUpdate={(e) => {
|
|
56
|
-
* console.log('剩余距离:', e.nativeEvent.pathRetainDistance);
|
|
57
|
-
* }}
|
|
58
|
-
* onArrive={() => {
|
|
59
|
-
* console.log('到达目的地!');
|
|
60
|
-
* }}
|
|
61
|
-
* />
|
|
62
|
-
* );
|
|
63
|
-
* }
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
export const NaviView = React.forwardRef<NaviViewRef, NaviViewProps>((props, ref) => {
|
|
67
|
-
const nativeRef = React.useRef<any>(null);
|
|
68
|
-
|
|
69
|
-
// 创建 API 引用
|
|
70
|
-
const apiRef: NaviViewRef = React.useMemo(() => ({
|
|
71
|
-
startNavigation: async (start: Coordinates | null, end: Coordinates, type: number) => {
|
|
72
|
-
if (!nativeRef.current) throw new Error('NaviView not initialized');
|
|
73
|
-
// 将对象解构为单独的参数传递给原生层
|
|
74
|
-
const startLat = start?.latitude ?? 0;
|
|
75
|
-
const startLng = start?.longitude ?? 0;
|
|
76
|
-
const endLat = end.latitude;
|
|
77
|
-
const endLng = end.longitude;
|
|
78
|
-
return nativeRef.current.startNavigation(startLat, startLng, endLat, endLng);
|
|
79
|
-
},
|
|
80
|
-
stopNavigation: async () => {
|
|
81
|
-
if (!nativeRef.current) throw new Error('NaviView not initialized');
|
|
82
|
-
return nativeRef.current.stopNavigation();
|
|
83
|
-
},
|
|
84
|
-
}), []);
|
|
85
|
-
|
|
86
|
-
// 暴露 API 给外部 ref
|
|
87
|
-
React.useImperativeHandle(ref, () => apiRef, [apiRef]);
|
|
88
|
-
|
|
89
|
-
return <NativeView ref={nativeRef} {...props} />;
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
NaviView.displayName = 'NaviView';
|
|
93
|
-
|
|
94
|
-
export default NaviView;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { requireNativeModule } from 'expo-modules-core';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 高德地图导航模块
|
|
6
|
-
*
|
|
7
|
-
* 提供路径规划功能,包括驾车、步行、骑行、公交、货车等多种出行方式
|
|
8
|
-
*/
|
|
9
|
-
const ExpoGaodeMapNavigationModule = requireNativeModule('ExpoGaodeMapNavigation');
|
|
10
|
-
|
|
11
|
-
export default ExpoGaodeMapNavigationModule;
|
package/src/index.ts
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import ExpoGaodeMapNavigationModule from './ExpoGaodeMapNavigationModule';
|
|
2
|
-
|
|
3
|
-
// 重新导出地图模块的所有内容
|
|
4
|
-
export * from './map';
|
|
5
|
-
import {
|
|
6
|
-
RouteType,
|
|
7
|
-
DriveStrategy,
|
|
8
|
-
WalkStrategy,
|
|
9
|
-
RideStrategy,
|
|
10
|
-
TruckSize,
|
|
11
|
-
TravelStrategy,
|
|
12
|
-
} from './types';
|
|
13
|
-
import type {
|
|
14
|
-
NaviPoint,
|
|
15
|
-
RouteOptions,
|
|
16
|
-
DriveRouteOptions,
|
|
17
|
-
WalkRouteOptions,
|
|
18
|
-
RideRouteOptions,
|
|
19
|
-
EBikeRouteOptions,
|
|
20
|
-
TruckRouteOptions,
|
|
21
|
-
RouteResult,
|
|
22
|
-
DriveRouteResult,
|
|
23
|
-
IndependentRouteResult,
|
|
24
|
-
IndependentDriveRouteOptions,
|
|
25
|
-
IndependentTruckRouteOptions,
|
|
26
|
-
IndependentWalkRouteOptions,
|
|
27
|
-
IndependentRideRouteOptions,
|
|
28
|
-
SelectIndependentRouteOptions,
|
|
29
|
-
StartNaviWithIndependentPathOptions,
|
|
30
|
-
ClearIndependentRouteOptions,
|
|
31
|
-
MotorcycleRouteOptions,
|
|
32
|
-
IndependentMotorcycleRouteOptions,
|
|
33
|
-
} from './types';
|
|
34
|
-
|
|
35
|
-
// 导出官方导航界面组件
|
|
36
|
-
export { NaviView, type NaviViewRef } from './ExpoGaodeMapNaviView';
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* 初始化导航模块(可选)
|
|
42
|
-
*/
|
|
43
|
-
export function initNavigation(): void {
|
|
44
|
-
ExpoGaodeMapNavigationModule.initNavigation();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* 销毁所有路径计算器实例
|
|
49
|
-
* 用于页面切换时释放资源,避免"Another route calculation is in progress"错误
|
|
50
|
-
*/
|
|
51
|
-
export function destroyAllCalculators(): void {
|
|
52
|
-
ExpoGaodeMapNavigationModule.destroyAllCalculators();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* 路径规划(通用方法)
|
|
57
|
-
* 注意:公交路径规划暂未实现
|
|
58
|
-
*/
|
|
59
|
-
export async function calculateRoute(
|
|
60
|
-
options: RouteOptions
|
|
61
|
-
): Promise<RouteResult | DriveRouteResult> {
|
|
62
|
-
// 根据传入的选项类型调用对应的方法
|
|
63
|
-
if ('carNumber' in options || 'avoidPolygons' in options) {
|
|
64
|
-
// 驾车或摩托车
|
|
65
|
-
return await calculateDriveRoute(options as DriveRouteOptions);
|
|
66
|
-
} else if ('size' in options) {
|
|
67
|
-
// 货车
|
|
68
|
-
return await calculateTruckRoute(options as TruckRouteOptions);
|
|
69
|
-
} else if ('multiple' in options || 'travelStrategy' in options) {
|
|
70
|
-
// 步行或骑行
|
|
71
|
-
if ('usePoi' in options) {
|
|
72
|
-
// 电动车
|
|
73
|
-
return await calculateEBikeRoute(options as EBikeRouteOptions);
|
|
74
|
-
} else if ((options as any).strategy === 0 || (options as any).strategy === 1) {
|
|
75
|
-
// 骑行
|
|
76
|
-
return await calculateRideRoute(options as RideRouteOptions);
|
|
77
|
-
} else {
|
|
78
|
-
// 步行
|
|
79
|
-
return await calculateWalkRoute(options as WalkRouteOptions);
|
|
80
|
-
}
|
|
81
|
-
} else {
|
|
82
|
-
// 默认当作驾车处理
|
|
83
|
-
return await calculateDriveRoute(options as DriveRouteOptions);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* 驾车路径规划
|
|
89
|
-
*/
|
|
90
|
-
export async function calculateDriveRoute(
|
|
91
|
-
options: DriveRouteOptions
|
|
92
|
-
): Promise<DriveRouteResult> {
|
|
93
|
-
return await ExpoGaodeMapNavigationModule.calculateDriveRoute(options);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* 步行路径规划
|
|
98
|
-
*/
|
|
99
|
-
export async function calculateWalkRoute(
|
|
100
|
-
options: WalkRouteOptions
|
|
101
|
-
): Promise<RouteResult> {
|
|
102
|
-
return await ExpoGaodeMapNavigationModule.calculateWalkRoute(options);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* 骑行路径规划
|
|
107
|
-
*/
|
|
108
|
-
export async function calculateRideRoute(
|
|
109
|
-
options: RideRouteOptions
|
|
110
|
-
): Promise<RouteResult> {
|
|
111
|
-
return await ExpoGaodeMapNavigationModule.calculateRideRoute(options);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* 骑行电动车路径规划
|
|
116
|
-
*/
|
|
117
|
-
export async function calculateEBikeRoute(
|
|
118
|
-
options: EBikeRouteOptions
|
|
119
|
-
): Promise<RouteResult> {
|
|
120
|
-
return await (ExpoGaodeMapNavigationModule as any).calculateEBikeRoute(options);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* 货车路径规划
|
|
125
|
-
*/
|
|
126
|
-
export async function calculateTruckRoute(
|
|
127
|
-
options: TruckRouteOptions
|
|
128
|
-
): Promise<DriveRouteResult> {
|
|
129
|
-
return await ExpoGaodeMapNavigationModule.calculateTruckRoute(options);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* 摩托车路径规划(车类型为 11,支持传入排量)
|
|
134
|
-
*/
|
|
135
|
-
export async function calculateMotorcycleRoute(
|
|
136
|
-
options: MotorcycleRouteOptions
|
|
137
|
-
): Promise<DriveRouteResult> {
|
|
138
|
-
return await ExpoGaodeMapNavigationModule.calculateMotorcycleRoute(options as any);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* 独立路径规划(不会影响当前导航;适合路线预览/行前选路)
|
|
143
|
-
*/
|
|
144
|
-
export async function independentDriveRoute(
|
|
145
|
-
options: IndependentDriveRouteOptions
|
|
146
|
-
): Promise<IndependentRouteResult> {
|
|
147
|
-
return await ExpoGaodeMapNavigationModule.independentDriveRoute(options);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export async function independentTruckRoute(
|
|
151
|
-
options: IndependentTruckRouteOptions
|
|
152
|
-
): Promise<IndependentRouteResult> {
|
|
153
|
-
return await ExpoGaodeMapNavigationModule.independentTruckRoute(options);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export async function independentWalkRoute(
|
|
157
|
-
options: IndependentWalkRouteOptions
|
|
158
|
-
): Promise<IndependentRouteResult> {
|
|
159
|
-
return await ExpoGaodeMapNavigationModule.independentWalkRoute(options);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export async function independentRideRoute(
|
|
163
|
-
options: IndependentRideRouteOptions
|
|
164
|
-
): Promise<IndependentRouteResult> {
|
|
165
|
-
return await ExpoGaodeMapNavigationModule.independentRideRoute(options);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* 独立摩托车路径规划(不干扰当前导航)
|
|
170
|
-
*/
|
|
171
|
-
export async function independentMotorcycleRoute(
|
|
172
|
-
options: IndependentMotorcycleRouteOptions
|
|
173
|
-
): Promise<IndependentRouteResult> {
|
|
174
|
-
return await ExpoGaodeMapNavigationModule.independentMotorcycleRoute(options as any);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* 独立路径组:选主路线
|
|
179
|
-
*/
|
|
180
|
-
export async function selectIndependentRoute(
|
|
181
|
-
options: SelectIndependentRouteOptions
|
|
182
|
-
): Promise<boolean> {
|
|
183
|
-
return await ExpoGaodeMapNavigationModule.selectIndependentRoute(options);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* 独立路径组:使用指定路线启动导航
|
|
188
|
-
*/
|
|
189
|
-
export async function startNaviWithIndependentPath(
|
|
190
|
-
options: StartNaviWithIndependentPathOptions
|
|
191
|
-
): Promise<boolean> {
|
|
192
|
-
return await ExpoGaodeMapNavigationModule.startNaviWithIndependentPath(options);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* 独立路径组:清理
|
|
197
|
-
*/
|
|
198
|
-
export async function clearIndependentRoute(
|
|
199
|
-
options: ClearIndependentRouteOptions
|
|
200
|
-
): Promise<boolean> {
|
|
201
|
-
return await ExpoGaodeMapNavigationModule.clearIndependentRoute(options);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// 导出导航相关类型与枚举(Coordinates 从 map 模块导出)
|
|
205
|
-
export type {
|
|
206
|
-
NaviPoint,
|
|
207
|
-
RouteOptions,
|
|
208
|
-
DriveRouteOptions,
|
|
209
|
-
WalkRouteOptions,
|
|
210
|
-
RideRouteOptions,
|
|
211
|
-
EBikeRouteOptions,
|
|
212
|
-
TruckRouteOptions,
|
|
213
|
-
RouteResult,
|
|
214
|
-
DriveRouteResult,
|
|
215
|
-
IndependentRouteResult,
|
|
216
|
-
IndependentDriveRouteOptions,
|
|
217
|
-
IndependentTruckRouteOptions,
|
|
218
|
-
IndependentWalkRouteOptions,
|
|
219
|
-
IndependentRideRouteOptions,
|
|
220
|
-
SelectIndependentRouteOptions,
|
|
221
|
-
StartNaviWithIndependentPathOptions,
|
|
222
|
-
ClearIndependentRouteOptions,
|
|
223
|
-
MotorcycleRouteOptions,
|
|
224
|
-
IndependentMotorcycleRouteOptions,
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
export {
|
|
228
|
-
RouteType,
|
|
229
|
-
DriveStrategy,
|
|
230
|
-
WalkStrategy,
|
|
231
|
-
RideStrategy,
|
|
232
|
-
TruckSize,
|
|
233
|
-
TravelStrategy,
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
// 精简后的默认导出
|
|
237
|
-
export default {
|
|
238
|
-
// 初始化
|
|
239
|
-
initNavigation,
|
|
240
|
-
destroyAllCalculators,
|
|
241
|
-
|
|
242
|
-
// 路径规划
|
|
243
|
-
calculateRoute,
|
|
244
|
-
calculateDriveRoute,
|
|
245
|
-
calculateWalkRoute,
|
|
246
|
-
calculateRideRoute,
|
|
247
|
-
calculateEBikeRoute,
|
|
248
|
-
calculateTruckRoute,
|
|
249
|
-
calculateMotorcycleRoute,
|
|
250
|
-
|
|
251
|
-
// 独立路径规划
|
|
252
|
-
independentDriveRoute,
|
|
253
|
-
independentTruckRoute,
|
|
254
|
-
independentWalkRoute,
|
|
255
|
-
independentRideRoute,
|
|
256
|
-
independentMotorcycleRoute,
|
|
257
|
-
|
|
258
|
-
// 独立路径组操作
|
|
259
|
-
selectIndependentRoute,
|
|
260
|
-
startNaviWithIndependentPath,
|
|
261
|
-
clearIndependentRoute,
|
|
262
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 高德地图 Expo 模块类型定义
|
|
3
|
-
*
|
|
4
|
-
* 此文件定义了 Expo 模块专用的类型,包括事件类型等
|
|
5
|
-
* 其他通用类型请从 './types' 导入
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { Coordinates, ReGeocode } from './types';
|
|
9
|
-
|
|
10
|
-
// 重新导出所有通用类型,方便使用
|
|
11
|
-
export * from './types';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Expo 模块事件类型
|
|
15
|
-
* 定义了原生模块可以触发的事件
|
|
16
|
-
*/
|
|
17
|
-
export type ExpoGaodeMapModuleEvents = {
|
|
18
|
-
/**
|
|
19
|
-
* 定位更新事件
|
|
20
|
-
* 当位置发生变化时触发
|
|
21
|
-
* @param location 位置信息,包含坐标和可选的逆地理编码信息
|
|
22
|
-
*/
|
|
23
|
-
onLocationUpdate: (location: Coordinates | ReGeocode) => void;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 方向更新事件(iOS)
|
|
27
|
-
* 当设备方向发生变化时触发
|
|
28
|
-
* @param heading 方向信息
|
|
29
|
-
*/
|
|
30
|
-
onHeadingUpdate: (heading: {
|
|
31
|
-
/** 磁北方向角度 (0-359.9) */
|
|
32
|
-
magneticHeading: number;
|
|
33
|
-
/** 真北方向角度 (0-359.9) */
|
|
34
|
-
trueHeading: number;
|
|
35
|
-
/** 方向精度 */
|
|
36
|
-
headingAccuracy: number;
|
|
37
|
-
/** X 轴原始数据 */
|
|
38
|
-
x: number;
|
|
39
|
-
/** Y 轴原始数据 */
|
|
40
|
-
y: number;
|
|
41
|
-
/** Z 轴原始数据 */
|
|
42
|
-
z: number;
|
|
43
|
-
/** 时间戳 */
|
|
44
|
-
timestamp: number;
|
|
45
|
-
}) => void;
|
|
46
|
-
};
|