expo-gaode-map-navigation 1.1.5 → 1.1.7

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.
Files changed (146) hide show
  1. package/README.md +213 -73
  2. package/android/build.gradle +10 -0
  3. package/android/src/main/cpp/CMakeLists.txt +24 -0
  4. package/android/src/main/cpp/cluster_jni.cpp +848 -0
  5. package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapModule.kt +616 -92
  6. package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapOfflineModule.kt +493 -0
  7. package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapView.kt +230 -14
  8. package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapViewModule.kt +37 -27
  9. package/android/src/main/java/expo/modules/gaodemap/map/MapPreloadManager.kt +494 -0
  10. package/android/src/main/java/expo/modules/gaodemap/map/companion/BitmapDescriptorCache.kt +30 -0
  11. package/android/src/main/java/expo/modules/gaodemap/map/companion/IconBitmapCache.kt +37 -0
  12. package/android/src/main/java/expo/modules/gaodemap/map/managers/UIManager.kt +76 -0
  13. package/android/src/main/java/expo/modules/gaodemap/map/modules/LocationManager.kt +15 -3
  14. package/android/src/main/java/expo/modules/gaodemap/map/modules/SDKInitializer.kt +4 -59
  15. package/android/src/main/java/expo/modules/gaodemap/map/overlays/CircleView.kt +9 -12
  16. package/android/src/main/java/expo/modules/gaodemap/map/overlays/CircleViewModule.kt +5 -6
  17. package/android/src/main/java/expo/modules/gaodemap/map/overlays/ClusterView.kt +539 -66
  18. package/android/src/main/java/expo/modules/gaodemap/map/overlays/ClusterViewModule.kt +17 -1
  19. package/android/src/main/java/expo/modules/gaodemap/map/overlays/HeatMapView.kt +165 -33
  20. package/android/src/main/java/expo/modules/gaodemap/map/overlays/HeatMapViewModule.kt +15 -3
  21. package/android/src/main/java/expo/modules/gaodemap/map/overlays/MarkerView.kt +1249 -672
  22. package/android/src/main/java/expo/modules/gaodemap/map/overlays/MarkerViewModule.kt +40 -17
  23. package/android/src/main/java/expo/modules/gaodemap/map/overlays/MultiPointView.kt +177 -22
  24. package/android/src/main/java/expo/modules/gaodemap/map/overlays/MultiPointViewModule.kt +11 -3
  25. package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolygonView.kt +57 -14
  26. package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolygonViewModule.kt +9 -5
  27. package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolylineView.kt +90 -63
  28. package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolylineViewModule.kt +7 -3
  29. package/android/src/main/java/expo/modules/gaodemap/map/services/LocationForegroundService.kt +3 -2
  30. package/android/src/main/java/expo/modules/gaodemap/map/utils/BitmapDescriptorCache.kt +20 -0
  31. package/android/src/main/java/expo/modules/gaodemap/map/utils/ClusterNative.kt +13 -0
  32. package/android/src/main/java/expo/modules/gaodemap/map/utils/ColorParser.kt +20 -0
  33. package/android/src/main/java/expo/modules/gaodemap/map/utils/GeometryUtils.kt +515 -0
  34. package/android/src/main/java/expo/modules/gaodemap/map/utils/LatLngParser.kt +91 -0
  35. package/android/src/main/java/expo/modules/gaodemap/map/utils/PermissionHelper.kt +248 -0
  36. package/build/ExpoGaodeMapNaviView.d.ts +7 -7
  37. package/build/ExpoGaodeMapNaviView.js +10 -11
  38. package/build/ExpoGaodeMapNavigationModule.d.ts +2 -1
  39. package/build/index.d.ts +35 -33
  40. package/build/index.js +70 -106
  41. package/build/map/ExpoGaodeMapModule.d.ts +2 -201
  42. package/build/map/ExpoGaodeMapModule.js +586 -18
  43. package/build/map/ExpoGaodeMapOfflineModule.d.ts +139 -0
  44. package/build/map/ExpoGaodeMapOfflineModule.js +8 -0
  45. package/build/map/ExpoGaodeMapView.js +66 -58
  46. package/build/map/components/FoldableMapView.d.ts +38 -0
  47. package/build/map/components/FoldableMapView.js +209 -0
  48. package/build/map/components/MapContext.d.ts +12 -0
  49. package/build/map/components/MapContext.js +54 -0
  50. package/build/map/components/MapUI.d.ts +18 -0
  51. package/build/map/components/MapUI.js +29 -0
  52. package/build/map/components/overlays/Circle.js +34 -3
  53. package/build/map/components/overlays/Cluster.d.ts +3 -1
  54. package/build/map/components/overlays/Cluster.js +31 -2
  55. package/build/map/components/overlays/HeatMap.d.ts +3 -1
  56. package/build/map/components/overlays/HeatMap.js +33 -3
  57. package/build/map/components/overlays/Marker.d.ts +1 -1
  58. package/build/map/components/overlays/Marker.js +37 -32
  59. package/build/map/components/overlays/MultiPoint.js +1 -1
  60. package/build/map/components/overlays/Polygon.js +30 -3
  61. package/build/map/components/overlays/Polyline.js +36 -3
  62. package/build/map/index.d.ts +25 -5
  63. package/build/map/index.js +59 -18
  64. package/build/map/types/common.types.d.ts +40 -0
  65. package/build/map/types/common.types.js +0 -4
  66. package/build/map/types/index.d.ts +3 -2
  67. package/build/map/types/map-view.types.d.ts +108 -3
  68. package/build/map/types/native-module.types.d.ts +363 -0
  69. package/build/map/types/native-module.types.js +5 -0
  70. package/build/map/types/offline.types.d.ts +132 -0
  71. package/build/map/types/offline.types.js +5 -0
  72. package/build/map/types/overlays.types.d.ts +137 -24
  73. package/build/map/utils/ErrorHandler.d.ts +110 -0
  74. package/build/map/utils/ErrorHandler.js +421 -0
  75. package/build/map/utils/GeoUtils.d.ts +20 -0
  76. package/build/map/utils/GeoUtils.js +76 -0
  77. package/build/map/utils/OfflineMapManager.d.ts +148 -0
  78. package/build/map/utils/OfflineMapManager.js +217 -0
  79. package/build/map/utils/PermissionUtils.d.ts +91 -0
  80. package/build/map/utils/PermissionUtils.js +255 -0
  81. package/build/map/utils/PlatformDetector.d.ts +102 -0
  82. package/build/map/utils/PlatformDetector.js +186 -0
  83. package/build/types/index.d.ts +1 -0
  84. package/build/types/index.js +1 -0
  85. package/build/types/native-module.types.d.ts +69 -0
  86. package/build/types/native-module.types.js +2 -0
  87. package/build/types/naviview.types.d.ts +1 -1
  88. package/expo-module.config.json +12 -10
  89. package/ios/ExpoGaodeMapNavigation.podspec +9 -0
  90. package/ios/map/ExpoGaodeMapModule.swift +485 -75
  91. package/ios/map/ExpoGaodeMapOfflineModule.swift +479 -0
  92. package/ios/map/ExpoGaodeMapView.swift +611 -62
  93. package/ios/map/ExpoGaodeMapViewModule.swift +48 -26
  94. package/ios/map/MapPreloadManager.swift +348 -0
  95. package/ios/map/cpp/ClusterEngine.cpp +110 -0
  96. package/ios/map/cpp/ClusterEngine.hpp +20 -0
  97. package/ios/map/cpp/ColorParser.cpp +135 -0
  98. package/ios/map/cpp/ColorParser.hpp +14 -0
  99. package/ios/map/cpp/GeometryEngine.cpp +574 -0
  100. package/ios/map/cpp/GeometryEngine.hpp +159 -0
  101. package/ios/map/cpp/QuadTree.cpp +92 -0
  102. package/ios/map/cpp/QuadTree.hpp +42 -0
  103. package/ios/map/cpp/README.md +55 -0
  104. package/ios/map/managers/UIManager.swift +72 -1
  105. package/ios/map/modules/LocationManager.swift +123 -166
  106. package/ios/map/overlays/CircleView.swift +16 -32
  107. package/ios/map/overlays/CircleViewModule.swift +12 -12
  108. package/ios/map/overlays/ClusterAnnotation.swift +32 -0
  109. package/ios/map/overlays/ClusterView.swift +331 -45
  110. package/ios/map/overlays/ClusterViewModule.swift +20 -6
  111. package/ios/map/overlays/HeatMapView.swift +135 -32
  112. package/ios/map/overlays/HeatMapViewModule.swift +20 -8
  113. package/ios/map/overlays/MarkerView.swift +613 -130
  114. package/ios/map/overlays/MarkerViewModule.swift +38 -18
  115. package/ios/map/overlays/MultiPointView.swift +168 -10
  116. package/ios/map/overlays/MultiPointViewModule.swift +27 -5
  117. package/ios/map/overlays/PolygonView.swift +62 -23
  118. package/ios/map/overlays/PolygonViewModule.swift +18 -12
  119. package/ios/map/overlays/PolylineView.swift +21 -13
  120. package/ios/map/overlays/PolylineViewModule.swift +18 -12
  121. package/ios/map/utils/ClusterNative.h +96 -0
  122. package/ios/map/utils/ClusterNative.mm +377 -0
  123. package/ios/map/utils/ColorParser.swift +12 -1
  124. package/ios/map/utils/CppBridging.mm +13 -0
  125. package/ios/map/utils/GeometryUtils.swift +34 -0
  126. package/ios/map/utils/LatLngParser.swift +87 -0
  127. package/ios/map/utils/PermissionManager.swift +135 -6
  128. package/package.json +3 -2
  129. package/shared/cpp/ClusterEngine.cpp +110 -0
  130. package/shared/cpp/ClusterEngine.hpp +20 -0
  131. package/shared/cpp/ColorParser.cpp +135 -0
  132. package/shared/cpp/ColorParser.hpp +14 -0
  133. package/shared/cpp/GeometryEngine.cpp +574 -0
  134. package/shared/cpp/GeometryEngine.hpp +159 -0
  135. package/shared/cpp/QuadTree.cpp +92 -0
  136. package/shared/cpp/QuadTree.hpp +42 -0
  137. package/shared/cpp/README.md +55 -0
  138. package/shared/cpp/tests/benchmark_js.js +41 -0
  139. package/shared/cpp/tests/run.sh +17 -0
  140. package/shared/cpp/tests/test_main.cpp +276 -0
  141. package/build/map/ExpoGaodeMap.types.d.ts +0 -41
  142. package/build/map/ExpoGaodeMap.types.js +0 -24
  143. package/build/map/utils/EventManager.d.ts +0 -10
  144. package/build/map/utils/EventManager.js +0 -26
  145. package/build/map/utils/ModuleLoader.d.ts +0 -73
  146. package/build/map/utils/ModuleLoader.js +0 -112
@@ -0,0 +1,248 @@
1
+ package expo.modules.gaodemap.map.utils
2
+
3
+ import android.Manifest
4
+ import android.app.Activity
5
+ import android.content.Context
6
+ import android.content.Intent
7
+ import android.content.pm.PackageManager
8
+ import android.net.Uri
9
+ import android.os.Build
10
+ import android.provider.Settings
11
+ import androidx.core.app.ActivityCompat
12
+ import androidx.core.content.ContextCompat
13
+
14
+ /**
15
+ * Android 14+ 权限适配助手
16
+ *
17
+ * 主要变化:
18
+ * 1. Android 14 (API 34) 引入了更精细的位置权限
19
+ * 2. 需要同时请求前台和后台位置权限
20
+ * 3. 权限请求流程更加严格
21
+ */
22
+ object PermissionHelper {
23
+
24
+ /**
25
+ * 位置权限类型
26
+ */
27
+ enum class LocationPermissionType {
28
+ FOREGROUND, // 仅前台位置
29
+ BACKGROUND, // 后台位置
30
+ FOREGROUND_AND_BACKGROUND // 前台+后台
31
+ }
32
+
33
+ /**
34
+ * 权限状态
35
+ */
36
+ data class PermissionStatus(
37
+ val granted: Boolean,
38
+ val shouldShowRationale: Boolean,
39
+ val isPermanentlyDenied: Boolean,
40
+ val fineLocation: Boolean = false,
41
+ val coarseLocation: Boolean = false,
42
+ val backgroundLocation: Boolean = false
43
+
44
+ )
45
+
46
+ /**
47
+ * 检查是否为 Android 14+
48
+ */
49
+ fun isAndroid14Plus(): Boolean {
50
+ return Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE // API 34
51
+ }
52
+
53
+ /**
54
+ * 检查是否为 Android 10+(引入后台位置权限)
55
+ */
56
+ fun isAndroid10Plus(): Boolean {
57
+ return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q // API 29
58
+ }
59
+
60
+ /**
61
+ * 获取需要请求的前台位置权限列表
62
+ */
63
+ fun getForegroundLocationPermissions(): Array<String> {
64
+ return arrayOf(
65
+ Manifest.permission.ACCESS_FINE_LOCATION,
66
+ Manifest.permission.ACCESS_COARSE_LOCATION
67
+ )
68
+ }
69
+
70
+ /**
71
+ * 获取后台位置权限
72
+ */
73
+ fun getBackgroundLocationPermission(): String? {
74
+ return if (isAndroid10Plus()) {
75
+ Manifest.permission.ACCESS_BACKGROUND_LOCATION
76
+ } else {
77
+ null
78
+ }
79
+ }
80
+
81
+ /**
82
+ * 检查前台位置权限状态
83
+ */
84
+ fun checkForegroundLocationPermission(context: Context): PermissionStatus {
85
+ val fineGranted = ContextCompat.checkSelfPermission(
86
+ context,
87
+ Manifest.permission.ACCESS_FINE_LOCATION
88
+ ) == PackageManager.PERMISSION_GRANTED
89
+
90
+ val coarseGranted = ContextCompat.checkSelfPermission(
91
+ context,
92
+ Manifest.permission.ACCESS_COARSE_LOCATION
93
+ ) == PackageManager.PERMISSION_GRANTED
94
+
95
+ val granted = fineGranted && coarseGranted
96
+
97
+ val activity = context as? Activity
98
+ val shouldShowRationale = if (activity != null && !granted) {
99
+ ActivityCompat.shouldShowRequestPermissionRationale(
100
+ activity,
101
+ Manifest.permission.ACCESS_FINE_LOCATION
102
+ )
103
+ } else {
104
+ false
105
+ }
106
+
107
+ return PermissionStatus(
108
+ granted = granted,
109
+ shouldShowRationale = shouldShowRationale,
110
+ isPermanentlyDenied = !granted && !shouldShowRationale && activity != null,
111
+ fineLocation = fineGranted,
112
+ coarseLocation = coarseGranted
113
+ )
114
+ }
115
+
116
+ /**
117
+ * 检查后台位置权限状态
118
+ */
119
+ fun checkBackgroundLocationPermission(context: Context): PermissionStatus {
120
+ val permission = getBackgroundLocationPermission()
121
+ if (permission == null) {
122
+ // Android 10 以下不支持后台位置权限
123
+ return PermissionStatus(
124
+ granted = true,
125
+ shouldShowRationale = false,
126
+ isPermanentlyDenied = false,
127
+ backgroundLocation = true
128
+ )
129
+ }
130
+
131
+ val granted = ContextCompat.checkSelfPermission(
132
+ context,
133
+ permission
134
+ ) == PackageManager.PERMISSION_GRANTED
135
+
136
+ val activity = context as? Activity
137
+ val shouldShowRationale = if (activity != null && !granted) {
138
+ ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)
139
+ } else {
140
+ false
141
+ }
142
+
143
+ return PermissionStatus(
144
+ granted = granted,
145
+ shouldShowRationale = shouldShowRationale,
146
+ isPermanentlyDenied = !granted && !shouldShowRationale && activity != null,
147
+ backgroundLocation = granted
148
+ )
149
+ }
150
+
151
+ /**
152
+ * 检查完整位置权限状态(前台+后台)
153
+ */
154
+ fun checkFullLocationPermission(context: Context): PermissionStatus {
155
+ val foreground = checkForegroundLocationPermission(context)
156
+ val background = checkBackgroundLocationPermission(context)
157
+
158
+ return PermissionStatus(
159
+ granted = foreground.granted && background.granted,
160
+ shouldShowRationale = foreground.shouldShowRationale || background.shouldShowRationale,
161
+ isPermanentlyDenied = foreground.isPermanentlyDenied || background.isPermanentlyDenied,
162
+ fineLocation = foreground.fineLocation,
163
+ coarseLocation = foreground.coarseLocation,
164
+ backgroundLocation = background.backgroundLocation
165
+ )
166
+ }
167
+
168
+ /**
169
+ * 请求前台位置权限
170
+ * Android 14+ 推荐的请求流程
171
+ */
172
+ fun requestForegroundLocationPermission(activity: Activity, requestCode: Int) {
173
+ val permissions = getForegroundLocationPermissions()
174
+ ActivityCompat.requestPermissions(activity, permissions, requestCode)
175
+ }
176
+
177
+ /**
178
+ * 请求后台位置权限
179
+ * 注意:必须在前台权限已授予后才能请求
180
+ */
181
+ fun requestBackgroundLocationPermission(activity: Activity, requestCode: Int): Boolean {
182
+ val permission = getBackgroundLocationPermission()
183
+ if (permission == null) {
184
+ return false
185
+ }
186
+
187
+ // 检查前台权限是否已授予
188
+ val foregroundStatus = checkForegroundLocationPermission(activity)
189
+ if (!foregroundStatus.granted) {
190
+ return false
191
+ }
192
+
193
+ ActivityCompat.requestPermissions(activity, arrayOf(permission), requestCode)
194
+ return true
195
+ }
196
+
197
+ /**
198
+ * 打开应用设置页面
199
+ * 用于引导用户手动授予权限
200
+ */
201
+ fun openAppSettings(context: Context) {
202
+ val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply {
203
+ data = Uri.fromParts("package", context.packageName, null)
204
+ flags = Intent.FLAG_ACTIVITY_NEW_TASK
205
+ }
206
+ context.startActivity(intent)
207
+ }
208
+
209
+ /**
210
+ * 获取权限请求的推荐提示文案(Android 14+ 优化)
211
+ */
212
+ fun getPermissionRationale(
213
+ type: LocationPermissionType,
214
+ isAndroid14: Boolean = isAndroid14Plus()
215
+ ): String {
216
+ return when (type) {
217
+ LocationPermissionType.FOREGROUND -> {
218
+ if (isAndroid14) {
219
+ "为了在地图上显示您的位置,应用需要访问您的位置信息。\n\n" +
220
+ "您可以选择:\n" +
221
+ "• 仅在使用应用时允许\n" +
222
+ "• 每次询问\n\n" +
223
+ "我们不会在后台收集您的位置数据。"
224
+ } else {
225
+ "为了在地图上显示您的位置,应用需要访问您的位置信息。"
226
+ }
227
+ }
228
+ LocationPermissionType.BACKGROUND -> {
229
+ if (isAndroid14) {
230
+ "为了在后台更新您的位置(如导航、轨迹记录),应用需要始终访问位置权限。\n\n" +
231
+ "您可以随时在设置中更改此权限。"
232
+ } else {
233
+ "为了在后台更新您的位置,应用需要始终访问位置权限。"
234
+ }
235
+ }
236
+ LocationPermissionType.FOREGROUND_AND_BACKGROUND -> {
237
+ if (isAndroid14) {
238
+ "应用需要位置权限来提供以下功能:\n" +
239
+ "• 在地图上显示您的位置(前台)\n" +
240
+ "• 后台导航和轨迹记录(后台)\n\n" +
241
+ "我们会先请求前台权限,然后再请求后台权限。"
242
+ } else {
243
+ "应用需要位置权限来显示地图位置和后台导航功能。"
244
+ }
245
+ }
246
+ }
247
+ }
248
+ }
@@ -1,9 +1,9 @@
1
1
  import * as React from 'react';
2
- import type { Coordinates, NaviViewProps } from './types';
2
+ import type { Coordinates, ExpoGaodeMapNaviViewProps } from './types';
3
3
  /**
4
- * NaviView Ref 类型
4
+ * ExpoGaodeMapNaviView Ref 类型
5
5
  */
6
- export interface NaviViewRef {
6
+ export interface ExpoGaodeMapNaviViewRef {
7
7
  /**
8
8
  * 开始导航
9
9
  */
@@ -26,11 +26,11 @@ export interface NaviViewRef {
26
26
  *
27
27
  * @example
28
28
  * ```tsx
29
- * import { NaviView } from 'expo-gaode-map-navigation';
29
+ * import { ExpoGaodeMapNaviView } from 'expo-gaode-map-navigation';
30
30
  *
31
31
  * function NavigationScreen() {
32
32
  * return (
33
- * <NaviView
33
+ * <ExpoGaodeMapNaviView
34
34
  * style={{ flex: 1 }}
35
35
  * naviType={0} // GPS 导航
36
36
  * showCamera={true}
@@ -46,5 +46,5 @@ export interface NaviViewRef {
46
46
  * }
47
47
  * ```
48
48
  */
49
- export declare const NaviView: React.ForwardRefExoticComponent<NaviViewProps & React.RefAttributes<NaviViewRef>>;
50
- export default NaviView;
49
+ export declare const ExpoGaodeMapNaviView: React.ForwardRefExoticComponent<ExpoGaodeMapNaviViewProps & React.RefAttributes<ExpoGaodeMapNaviViewRef>>;
50
+ export default ExpoGaodeMapNaviView;
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.NaviView = void 0;
36
+ exports.ExpoGaodeMapNaviView = void 0;
37
37
  const expo_modules_core_1 = require("expo-modules-core");
38
38
  const React = __importStar(require("react"));
39
39
  const NativeView = (0, expo_modules_core_1.requireNativeViewManager)('ExpoGaodeMapNaviView');
@@ -50,11 +50,11 @@ const NativeView = (0, expo_modules_core_1.requireNativeViewManager)('ExpoGaodeM
50
50
  *
51
51
  * @example
52
52
  * ```tsx
53
- * import { NaviView } from 'expo-gaode-map-navigation';
53
+ * import { ExpoGaodeMapNaviView } from 'expo-gaode-map-navigation';
54
54
  *
55
55
  * function NavigationScreen() {
56
56
  * return (
57
- * <NaviView
57
+ * <ExpoGaodeMapNaviView
58
58
  * style={{ flex: 1 }}
59
59
  * naviType={0} // GPS 导航
60
60
  * showCamera={true}
@@ -70,24 +70,23 @@ const NativeView = (0, expo_modules_core_1.requireNativeViewManager)('ExpoGaodeM
70
70
  * }
71
71
  * ```
72
72
  */
73
- exports.NaviView = React.forwardRef((props, ref) => {
73
+ exports.ExpoGaodeMapNaviView = React.forwardRef((props, ref) => {
74
74
  const nativeRef = React.useRef(null);
75
75
  // 创建 API 引用
76
76
  const apiRef = React.useMemo(() => ({
77
77
  startNavigation: async (start, end, type) => {
78
- var _a, _b;
79
78
  if (!nativeRef.current)
80
- throw new Error('NaviView not initialized');
79
+ throw new Error('ExpoGaodeMapNaviView not initialized');
81
80
  // 将对象解构为单独的参数传递给原生层
82
- const startLat = (_a = start === null || start === void 0 ? void 0 : start.latitude) !== null && _a !== void 0 ? _a : 0;
83
- const startLng = (_b = start === null || start === void 0 ? void 0 : start.longitude) !== null && _b !== void 0 ? _b : 0;
81
+ const startLat = start?.latitude ?? 0;
82
+ const startLng = start?.longitude ?? 0;
84
83
  const endLat = end.latitude;
85
84
  const endLng = end.longitude;
86
85
  return nativeRef.current.startNavigation(startLat, startLng, endLat, endLng);
87
86
  },
88
87
  stopNavigation: async () => {
89
88
  if (!nativeRef.current)
90
- throw new Error('NaviView not initialized');
89
+ throw new Error('ExpoGaodeMapNaviView not initialized');
91
90
  return nativeRef.current.stopNavigation();
92
91
  },
93
92
  }), []);
@@ -95,5 +94,5 @@ exports.NaviView = React.forwardRef((props, ref) => {
95
94
  React.useImperativeHandle(ref, () => apiRef, [apiRef]);
96
95
  return <NativeView ref={nativeRef} {...props}/>;
97
96
  });
98
- exports.NaviView.displayName = 'NaviView';
99
- exports.default = exports.NaviView;
97
+ exports.ExpoGaodeMapNaviView.displayName = 'ExpoGaodeMapNaviView';
98
+ exports.default = exports.ExpoGaodeMapNaviView;
@@ -1,7 +1,8 @@
1
+ import { ExpoGaodeMapNavigationModule as ExpoGaodeMapNavigationModuleType } from './types/native-module.types';
1
2
  /**
2
3
  * 高德地图导航模块
3
4
  *
4
5
  * 提供路径规划功能,包括驾车、步行、骑行、公交、货车等多种出行方式
5
6
  */
6
- declare const ExpoGaodeMapNavigationModule: any;
7
+ declare const ExpoGaodeMapNavigationModule: ExpoGaodeMapNavigationModuleType;
7
8
  export default ExpoGaodeMapNavigationModule;
package/build/index.d.ts CHANGED
@@ -1,16 +1,17 @@
1
+ import ExpoGaodeMapNavigationModule from './ExpoGaodeMapNavigationModule';
1
2
  export * from './map';
2
3
  import { RouteType, DriveStrategy, WalkStrategy, RideStrategy, TruckSize, TravelStrategy } from './types';
3
4
  import type { NaviPoint, RouteOptions, DriveRouteOptions, WalkRouteOptions, RideRouteOptions, EBikeRouteOptions, TruckRouteOptions, RouteResult, DriveRouteResult, IndependentRouteResult, IndependentDriveRouteOptions, IndependentTruckRouteOptions, IndependentWalkRouteOptions, IndependentRideRouteOptions, SelectIndependentRouteOptions, StartNaviWithIndependentPathOptions, ClearIndependentRouteOptions, MotorcycleRouteOptions, IndependentMotorcycleRouteOptions } from './types';
4
- export { NaviView, type NaviViewRef } from './ExpoGaodeMapNaviView';
5
+ export { ExpoGaodeMapNaviView, type ExpoGaodeMapNaviViewRef, ExpoGaodeMapNaviView as NaviView, type ExpoGaodeMapNaviViewRef as NaviViewRef } from './ExpoGaodeMapNaviView';
5
6
  /**
6
7
  * 初始化导航模块(可选)
7
8
  */
8
- export declare function initNavigation(): void;
9
+ export declare const initNavigation: () => void;
9
10
  /**
10
11
  * 销毁所有路径计算器实例
11
12
  * 用于页面切换时释放资源,避免"Another route calculation is in progress"错误
12
13
  */
13
- export declare function destroyAllCalculators(): void;
14
+ export declare const destroyAllCalculators: () => void;
14
15
  /**
15
16
  * 路径规划(通用方法)
16
17
  * 注意:公交路径规划暂未实现
@@ -19,69 +20,70 @@ export declare function calculateRoute(options: RouteOptions): Promise<RouteResu
19
20
  /**
20
21
  * 驾车路径规划
21
22
  */
22
- export declare function calculateDriveRoute(options: DriveRouteOptions): Promise<DriveRouteResult>;
23
+ export declare const calculateDriveRoute: (options: DriveRouteOptions) => Promise<DriveRouteResult>;
23
24
  /**
24
25
  * 步行路径规划
25
26
  */
26
- export declare function calculateWalkRoute(options: WalkRouteOptions): Promise<RouteResult>;
27
+ export declare const calculateWalkRoute: (options: WalkRouteOptions) => Promise<RouteResult>;
27
28
  /**
28
29
  * 骑行路径规划
29
30
  */
30
- export declare function calculateRideRoute(options: RideRouteOptions): Promise<RouteResult>;
31
+ export declare const calculateRideRoute: (options: RideRouteOptions) => Promise<RouteResult>;
31
32
  /**
32
33
  * 骑行电动车路径规划
33
34
  */
34
- export declare function calculateEBikeRoute(options: EBikeRouteOptions): Promise<RouteResult>;
35
+ export declare const calculateEBikeRoute: (options: EBikeRouteOptions) => Promise<RouteResult>;
35
36
  /**
36
37
  * 货车路径规划
37
38
  */
38
- export declare function calculateTruckRoute(options: TruckRouteOptions): Promise<DriveRouteResult>;
39
+ export declare const calculateTruckRoute: (options: TruckRouteOptions) => Promise<DriveRouteResult>;
39
40
  /**
40
41
  * 摩托车路径规划(车类型为 11,支持传入排量)
41
42
  */
42
- export declare function calculateMotorcycleRoute(options: MotorcycleRouteOptions): Promise<DriveRouteResult>;
43
+ export declare const calculateMotorcycleRoute: (options: MotorcycleRouteOptions) => Promise<DriveRouteResult>;
43
44
  /**
44
45
  * 独立路径规划(不会影响当前导航;适合路线预览/行前选路)
45
46
  */
46
- export declare function independentDriveRoute(options: IndependentDriveRouteOptions): Promise<IndependentRouteResult>;
47
- export declare function independentTruckRoute(options: IndependentTruckRouteOptions): Promise<IndependentRouteResult>;
48
- export declare function independentWalkRoute(options: IndependentWalkRouteOptions): Promise<IndependentRouteResult>;
49
- export declare function independentRideRoute(options: IndependentRideRouteOptions): Promise<IndependentRouteResult>;
47
+ export declare const independentDriveRoute: (options: IndependentDriveRouteOptions) => Promise<IndependentRouteResult>;
48
+ export declare const independentTruckRoute: (options: IndependentTruckRouteOptions) => Promise<IndependentRouteResult>;
49
+ export declare const independentWalkRoute: (options: IndependentWalkRouteOptions) => Promise<IndependentRouteResult>;
50
+ export declare const independentRideRoute: (options: IndependentRideRouteOptions) => Promise<IndependentRouteResult>;
50
51
  /**
51
52
  * 独立摩托车路径规划(不干扰当前导航)
52
53
  */
53
- export declare function independentMotorcycleRoute(options: IndependentMotorcycleRouteOptions): Promise<IndependentRouteResult>;
54
+ export declare const independentMotorcycleRoute: (options: IndependentMotorcycleRouteOptions) => Promise<IndependentRouteResult>;
54
55
  /**
55
56
  * 独立路径组:选主路线
56
57
  */
57
- export declare function selectIndependentRoute(options: SelectIndependentRouteOptions): Promise<boolean>;
58
+ export declare const selectIndependentRoute: (options: SelectIndependentRouteOptions) => Promise<boolean>;
58
59
  /**
59
60
  * 独立路径组:使用指定路线启动导航
60
61
  */
61
- export declare function startNaviWithIndependentPath(options: StartNaviWithIndependentPathOptions): Promise<boolean>;
62
+ export declare const startNaviWithIndependentPath: (options: StartNaviWithIndependentPathOptions) => Promise<boolean>;
62
63
  /**
63
64
  * 独立路径组:清理
64
65
  */
65
- export declare function clearIndependentRoute(options: ClearIndependentRouteOptions): Promise<boolean>;
66
+ export declare const clearIndependentRoute: (options: ClearIndependentRouteOptions) => Promise<boolean>;
66
67
  export type { NaviPoint, RouteOptions, DriveRouteOptions, WalkRouteOptions, RideRouteOptions, EBikeRouteOptions, TruckRouteOptions, RouteResult, DriveRouteResult, IndependentRouteResult, IndependentDriveRouteOptions, IndependentTruckRouteOptions, IndependentWalkRouteOptions, IndependentRideRouteOptions, SelectIndependentRouteOptions, StartNaviWithIndependentPathOptions, ClearIndependentRouteOptions, MotorcycleRouteOptions, IndependentMotorcycleRouteOptions, };
67
68
  export { RouteType, DriveStrategy, WalkStrategy, RideStrategy, TruckSize, TravelStrategy, };
68
69
  declare const _default: {
69
- initNavigation: typeof initNavigation;
70
- destroyAllCalculators: typeof destroyAllCalculators;
70
+ initNavigation: () => void;
71
+ destroyAllCalculators: () => void;
71
72
  calculateRoute: typeof calculateRoute;
72
- calculateDriveRoute: typeof calculateDriveRoute;
73
- calculateWalkRoute: typeof calculateWalkRoute;
74
- calculateRideRoute: typeof calculateRideRoute;
75
- calculateEBikeRoute: typeof calculateEBikeRoute;
76
- calculateTruckRoute: typeof calculateTruckRoute;
77
- calculateMotorcycleRoute: typeof calculateMotorcycleRoute;
78
- independentDriveRoute: typeof independentDriveRoute;
79
- independentTruckRoute: typeof independentTruckRoute;
80
- independentWalkRoute: typeof independentWalkRoute;
81
- independentRideRoute: typeof independentRideRoute;
82
- independentMotorcycleRoute: typeof independentMotorcycleRoute;
83
- selectIndependentRoute: typeof selectIndependentRoute;
84
- startNaviWithIndependentPath: typeof startNaviWithIndependentPath;
85
- clearIndependentRoute: typeof clearIndependentRoute;
73
+ calculateDriveRoute: (options: DriveRouteOptions) => Promise<DriveRouteResult>;
74
+ calculateWalkRoute: (options: WalkRouteOptions) => Promise<RouteResult>;
75
+ calculateRideRoute: (options: RideRouteOptions) => Promise<RouteResult>;
76
+ calculateEBikeRoute: (options: EBikeRouteOptions) => Promise<RouteResult>;
77
+ calculateTruckRoute: (options: TruckRouteOptions) => Promise<DriveRouteResult>;
78
+ calculateMotorcycleRoute: (options: MotorcycleRouteOptions) => Promise<DriveRouteResult>;
79
+ independentDriveRoute: (options: IndependentDriveRouteOptions) => Promise<IndependentRouteResult>;
80
+ independentTruckRoute: (options: IndependentTruckRouteOptions) => Promise<IndependentRouteResult>;
81
+ independentWalkRoute: (options: IndependentWalkRouteOptions) => Promise<IndependentRouteResult>;
82
+ independentRideRoute: (options: IndependentRideRouteOptions) => Promise<IndependentRouteResult>;
83
+ independentMotorcycleRoute: (options: IndependentMotorcycleRouteOptions) => Promise<IndependentRouteResult>;
84
+ selectIndependentRoute: (options: SelectIndependentRouteOptions) => Promise<boolean>;
85
+ startNaviWithIndependentPath: (options: StartNaviWithIndependentPathOptions) => Promise<boolean>;
86
+ clearIndependentRoute: (options: ClearIndependentRouteOptions) => Promise<boolean>;
86
87
  };
87
88
  export default _default;
89
+ export { ExpoGaodeMapNavigationModule, };