expo-gaode-map-navigation 2.0.18 → 2.0.19

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 (261) hide show
  1. package/android/build.gradle +4 -25
  2. package/build/ExpoGaodeMapNaviView.js +2 -1
  3. package/build/ExpoGaodeMapNaviView.js.map +1 -1
  4. package/build/ExpoGaodeMapNavigationModule.d.ts +1 -1
  5. package/build/ExpoGaodeMapNavigationModule.d.ts.map +1 -1
  6. package/build/ExpoGaodeMapNavigationModule.js.map +1 -1
  7. package/build/map/ExpoGaodeMapModule.d.ts +3 -2
  8. package/build/map/ExpoGaodeMapModule.d.ts.map +1 -1
  9. package/build/map/ExpoGaodeMapModule.js +3 -1
  10. package/build/map/ExpoGaodeMapModule.js.map +1 -1
  11. package/build/map/ExpoGaodeMapOfflineModule.js +1 -1
  12. package/build/map/ExpoGaodeMapOfflineModule.js.map +1 -1
  13. package/build/map/ExpoGaodeMapView.js +2 -8
  14. package/build/map/ExpoGaodeMapView.js.map +1 -1
  15. package/build/map/components/FoldableMapView.d.ts +3 -2
  16. package/build/map/components/FoldableMapView.d.ts.map +1 -1
  17. package/build/map/components/FoldableMapView.js +2 -1
  18. package/build/map/components/FoldableMapView.js.map +1 -1
  19. package/build/map/components/MapUI.js +2 -1
  20. package/build/map/components/MapUI.js.map +1 -1
  21. package/build/map/components/overlays/Circle.d.ts +1 -1
  22. package/build/map/components/overlays/Circle.d.ts.map +1 -1
  23. package/build/map/components/overlays/Circle.js +2 -1
  24. package/build/map/components/overlays/Circle.js.map +1 -1
  25. package/build/map/components/overlays/Cluster.d.ts +1 -1
  26. package/build/map/components/overlays/Cluster.d.ts.map +1 -1
  27. package/build/map/components/overlays/Cluster.js +2 -1
  28. package/build/map/components/overlays/Cluster.js.map +1 -1
  29. package/build/map/components/overlays/HeatMap.d.ts +1 -1
  30. package/build/map/components/overlays/HeatMap.d.ts.map +1 -1
  31. package/build/map/components/overlays/HeatMap.js +2 -1
  32. package/build/map/components/overlays/HeatMap.js.map +1 -1
  33. package/build/map/components/overlays/Marker.d.ts +1 -1
  34. package/build/map/components/overlays/Marker.d.ts.map +1 -1
  35. package/build/map/components/overlays/Marker.js +2 -5
  36. package/build/map/components/overlays/Marker.js.map +1 -1
  37. package/build/map/components/overlays/MultiPoint.d.ts +1 -2
  38. package/build/map/components/overlays/MultiPoint.d.ts.map +1 -1
  39. package/build/map/components/overlays/MultiPoint.js +2 -1
  40. package/build/map/components/overlays/MultiPoint.js.map +1 -1
  41. package/build/map/components/overlays/Polygon.d.ts +1 -1
  42. package/build/map/components/overlays/Polygon.d.ts.map +1 -1
  43. package/build/map/components/overlays/Polygon.js +2 -1
  44. package/build/map/components/overlays/Polygon.js.map +1 -1
  45. package/build/map/components/overlays/Polyline.d.ts +1 -1
  46. package/build/map/components/overlays/Polyline.d.ts.map +1 -1
  47. package/build/map/components/overlays/Polyline.js +2 -1
  48. package/build/map/components/overlays/Polyline.js.map +1 -1
  49. package/build/map/search/ExpoGaodeMapSearchModule.d.ts +1 -1
  50. package/build/map/search/ExpoGaodeMapSearchModule.d.ts.map +1 -1
  51. package/build/map/search/ExpoGaodeMapSearchModule.js.map +1 -1
  52. package/build/map/types/common.types.d.ts +1 -1
  53. package/build/map/types/common.types.d.ts.map +1 -1
  54. package/build/map/types/common.types.js.map +1 -1
  55. package/build/map/types/map-view.types.d.ts +2 -2
  56. package/build/map/types/map-view.types.d.ts.map +1 -1
  57. package/build/map/types/map-view.types.js.map +1 -1
  58. package/build/map/utils/GeoUtils.d.ts +1 -1
  59. package/build/map/utils/GeoUtils.d.ts.map +1 -1
  60. package/build/map/utils/GeoUtils.js +2 -2
  61. package/build/map/utils/GeoUtils.js.map +1 -1
  62. package/build/route-geometry.d.ts.map +1 -1
  63. package/build/route-geometry.js +24 -8
  64. package/build/route-geometry.js.map +1 -1
  65. package/build/src/ExpoGaodeMapNaviView.d.ts +67 -0
  66. package/build/src/ExpoGaodeMapNaviView.d.ts.map +1 -0
  67. package/build/src/ExpoGaodeMapNaviView.js +138 -0
  68. package/build/src/ExpoGaodeMapNaviView.js.map +1 -0
  69. package/build/src/ExpoGaodeMapNavigation.types.d.ts +2 -0
  70. package/build/src/ExpoGaodeMapNavigation.types.d.ts.map +1 -0
  71. package/build/src/ExpoGaodeMapNavigation.types.js +3 -0
  72. package/build/src/ExpoGaodeMapNavigation.types.js.map +1 -0
  73. package/build/src/ExpoGaodeMapNavigationModule.d.ts +4 -0
  74. package/build/src/ExpoGaodeMapNavigationModule.d.ts.map +1 -0
  75. package/build/src/ExpoGaodeMapNavigationModule.js +27 -0
  76. package/build/src/ExpoGaodeMapNavigationModule.js.map +1 -0
  77. package/build/src/index.d.ts +47 -0
  78. package/build/src/index.d.ts.map +1 -0
  79. package/build/src/index.js +48 -0
  80. package/build/src/index.js.map +1 -0
  81. package/build/src/map/ExpoGaodeMapModule.d.ts +256 -0
  82. package/build/src/map/ExpoGaodeMapModule.d.ts.map +1 -0
  83. package/build/src/map/ExpoGaodeMapModule.js +813 -0
  84. package/build/src/map/ExpoGaodeMapModule.js.map +1 -0
  85. package/build/src/map/ExpoGaodeMapOfflineModule.d.ts +145 -0
  86. package/build/src/map/ExpoGaodeMapOfflineModule.d.ts.map +1 -0
  87. package/build/src/map/ExpoGaodeMapOfflineModule.js +24 -0
  88. package/build/src/map/ExpoGaodeMapOfflineModule.js.map +1 -0
  89. package/build/src/map/ExpoGaodeMapView.d.ts +23 -0
  90. package/build/src/map/ExpoGaodeMapView.d.ts.map +1 -0
  91. package/build/src/map/ExpoGaodeMapView.js +173 -0
  92. package/build/src/map/ExpoGaodeMapView.js.map +1 -0
  93. package/build/src/map/components/FoldableMapView.d.ts +39 -0
  94. package/build/src/map/components/FoldableMapView.d.ts.map +1 -0
  95. package/build/src/map/components/FoldableMapView.js +171 -0
  96. package/build/src/map/components/FoldableMapView.js.map +1 -0
  97. package/build/src/map/components/MapContext.d.ts +13 -0
  98. package/build/src/map/components/MapContext.d.ts.map +1 -0
  99. package/build/src/map/components/MapContext.js +18 -0
  100. package/build/src/map/components/MapContext.js.map +1 -0
  101. package/build/src/map/components/MapUI.d.ts +19 -0
  102. package/build/src/map/components/MapUI.d.ts.map +1 -0
  103. package/build/src/map/components/MapUI.js +24 -0
  104. package/build/src/map/components/MapUI.js.map +1 -0
  105. package/build/src/map/components/overlays/Circle.d.ts +13 -0
  106. package/build/src/map/components/overlays/Circle.d.ts.map +1 -0
  107. package/build/src/map/components/overlays/Circle.js +20 -0
  108. package/build/src/map/components/overlays/Circle.js.map +1 -0
  109. package/build/src/map/components/overlays/Cluster.d.ts +12 -0
  110. package/build/src/map/components/overlays/Cluster.d.ts.map +1 -0
  111. package/build/src/map/components/overlays/Cluster.js +16 -0
  112. package/build/src/map/components/overlays/Cluster.js.map +1 -0
  113. package/build/src/map/components/overlays/HeatMap.d.ts +12 -0
  114. package/build/src/map/components/overlays/HeatMap.d.ts.map +1 -0
  115. package/build/src/map/components/overlays/HeatMap.js +46 -0
  116. package/build/src/map/components/overlays/HeatMap.js.map +1 -0
  117. package/build/src/map/components/overlays/Marker.d.ts +16 -0
  118. package/build/src/map/components/overlays/Marker.d.ts.map +1 -0
  119. package/build/src/map/components/overlays/Marker.js +125 -0
  120. package/build/src/map/components/overlays/Marker.js.map +1 -0
  121. package/build/src/map/components/overlays/MultiPoint.d.ts +9 -0
  122. package/build/src/map/components/overlays/MultiPoint.d.ts.map +1 -0
  123. package/build/src/map/components/overlays/MultiPoint.js +15 -0
  124. package/build/src/map/components/overlays/MultiPoint.js.map +1 -0
  125. package/build/src/map/components/overlays/Polygon.d.ts +12 -0
  126. package/build/src/map/components/overlays/Polygon.d.ts.map +1 -0
  127. package/build/src/map/components/overlays/Polygon.js +20 -0
  128. package/build/src/map/components/overlays/Polygon.js.map +1 -0
  129. package/build/src/map/components/overlays/Polyline.d.ts +12 -0
  130. package/build/src/map/components/overlays/Polyline.d.ts.map +1 -0
  131. package/build/src/map/components/overlays/Polyline.js +20 -0
  132. package/build/src/map/components/overlays/Polyline.js.map +1 -0
  133. package/build/src/map/components/overlays/index.d.ts +8 -0
  134. package/build/src/map/components/overlays/index.d.ts.map +1 -0
  135. package/build/src/map/components/overlays/index.js +8 -0
  136. package/build/src/map/components/overlays/index.js.map +1 -0
  137. package/build/src/map/index.d.ts +35 -0
  138. package/build/src/map/index.d.ts.map +1 -0
  139. package/build/src/map/index.js +48 -0
  140. package/build/src/map/index.js.map +1 -0
  141. package/build/src/map/search/ExpoGaodeMapSearch.types.d.ts +340 -0
  142. package/build/src/map/search/ExpoGaodeMapSearch.types.d.ts.map +1 -0
  143. package/build/src/map/search/ExpoGaodeMapSearch.types.js +19 -0
  144. package/build/src/map/search/ExpoGaodeMapSearch.types.js.map +1 -0
  145. package/build/src/map/search/ExpoGaodeMapSearchModule.d.ts +74 -0
  146. package/build/src/map/search/ExpoGaodeMapSearchModule.d.ts.map +1 -0
  147. package/build/src/map/search/ExpoGaodeMapSearchModule.js +48 -0
  148. package/build/src/map/search/ExpoGaodeMapSearchModule.js.map +1 -0
  149. package/build/src/map/search/index.d.ts +156 -0
  150. package/build/src/map/search/index.d.ts.map +1 -0
  151. package/build/src/map/search/index.js +171 -0
  152. package/build/src/map/search/index.js.map +1 -0
  153. package/build/src/map/types/common.types.d.ts +199 -0
  154. package/build/src/map/types/common.types.d.ts.map +1 -0
  155. package/build/src/map/types/common.types.js +33 -0
  156. package/build/src/map/types/common.types.js.map +1 -0
  157. package/build/src/map/types/index.d.ts +13 -0
  158. package/build/src/map/types/index.d.ts.map +1 -0
  159. package/build/src/map/types/index.js +7 -0
  160. package/build/src/map/types/index.js.map +1 -0
  161. package/build/src/map/types/location.types.d.ts +358 -0
  162. package/build/src/map/types/location.types.d.ts.map +1 -0
  163. package/build/src/map/types/location.types.js +93 -0
  164. package/build/src/map/types/location.types.js.map +1 -0
  165. package/build/src/map/types/map-view.types.d.ts +340 -0
  166. package/build/src/map/types/map-view.types.d.ts.map +1 -0
  167. package/build/src/map/types/map-view.types.js +6 -0
  168. package/build/src/map/types/map-view.types.js.map +1 -0
  169. package/build/src/map/types/native-module.types.d.ts +395 -0
  170. package/build/src/map/types/native-module.types.d.ts.map +1 -0
  171. package/build/src/map/types/native-module.types.js +5 -0
  172. package/build/src/map/types/native-module.types.js.map +1 -0
  173. package/build/src/map/types/offline.types.d.ts +133 -0
  174. package/build/src/map/types/offline.types.d.ts.map +1 -0
  175. package/build/src/map/types/offline.types.js +5 -0
  176. package/build/src/map/types/offline.types.js.map +1 -0
  177. package/build/src/map/types/overlays.types.d.ts +456 -0
  178. package/build/src/map/types/overlays.types.d.ts.map +1 -0
  179. package/build/src/map/types/overlays.types.js +6 -0
  180. package/build/src/map/types/overlays.types.js.map +1 -0
  181. package/build/src/map/types/route-playback.types.d.ts +28 -0
  182. package/build/src/map/types/route-playback.types.d.ts.map +1 -0
  183. package/build/src/map/types/route-playback.types.js +2 -0
  184. package/build/src/map/types/route-playback.types.js.map +1 -0
  185. package/build/src/map/utils/ErrorHandler.d.ts +121 -0
  186. package/build/src/map/utils/ErrorHandler.d.ts.map +1 -0
  187. package/build/src/map/utils/ErrorHandler.js +470 -0
  188. package/build/src/map/utils/ErrorHandler.js.map +1 -0
  189. package/build/src/map/utils/GeoUtils.d.ts +21 -0
  190. package/build/src/map/utils/GeoUtils.d.ts.map +1 -0
  191. package/build/src/map/utils/GeoUtils.js +78 -0
  192. package/build/src/map/utils/GeoUtils.js.map +1 -0
  193. package/build/src/map/utils/OfflineMapManager.d.ts +153 -0
  194. package/build/src/map/utils/OfflineMapManager.d.ts.map +1 -0
  195. package/build/src/map/utils/OfflineMapManager.js +217 -0
  196. package/build/src/map/utils/OfflineMapManager.js.map +1 -0
  197. package/build/src/map/utils/PermissionUtils.d.ts +92 -0
  198. package/build/src/map/utils/PermissionUtils.d.ts.map +1 -0
  199. package/build/src/map/utils/PermissionUtils.js +252 -0
  200. package/build/src/map/utils/PermissionUtils.js.map +1 -0
  201. package/build/src/map/utils/PlatformDetector.d.ts +103 -0
  202. package/build/src/map/utils/PlatformDetector.d.ts.map +1 -0
  203. package/build/src/map/utils/PlatformDetector.js +178 -0
  204. package/build/src/map/utils/PlatformDetector.js.map +1 -0
  205. package/build/src/map/utils/lazyNativeViewManager.d.ts +3 -0
  206. package/build/src/map/utils/lazyNativeViewManager.d.ts.map +1 -0
  207. package/build/src/map/utils/lazyNativeViewManager.js +11 -0
  208. package/build/src/map/utils/lazyNativeViewManager.js.map +1 -0
  209. package/build/src/route-geometry.d.ts +13 -0
  210. package/build/src/route-geometry.d.ts.map +1 -0
  211. package/build/src/route-geometry.js +154 -0
  212. package/build/src/route-geometry.js.map +1 -0
  213. package/build/src/route-planning.d.ts +21 -0
  214. package/build/src/route-planning.d.ts.map +1 -0
  215. package/build/src/route-planning.js +67 -0
  216. package/build/src/route-planning.js.map +1 -0
  217. package/build/src/types/coordinates.types.d.ts +25 -0
  218. package/build/src/types/coordinates.types.d.ts.map +1 -0
  219. package/build/src/types/coordinates.types.js +6 -0
  220. package/build/src/types/coordinates.types.js.map +1 -0
  221. package/build/src/types/independent.types.d.ts +385 -0
  222. package/build/src/types/independent.types.d.ts.map +1 -0
  223. package/build/src/types/independent.types.js +2 -0
  224. package/build/src/types/independent.types.js.map +1 -0
  225. package/build/src/types/index.d.ts +6 -0
  226. package/build/src/types/index.d.ts.map +1 -0
  227. package/build/src/types/index.js +7 -0
  228. package/build/src/types/index.js.map +1 -0
  229. package/build/src/types/native-module.types.d.ts +74 -0
  230. package/build/src/types/native-module.types.d.ts.map +1 -0
  231. package/build/src/types/native-module.types.js +3 -0
  232. package/build/src/types/native-module.types.js.map +1 -0
  233. package/build/src/types/naviview.types.d.ts +562 -0
  234. package/build/src/types/naviview.types.d.ts.map +1 -0
  235. package/build/src/types/naviview.types.js +2 -0
  236. package/build/src/types/naviview.types.js.map +1 -0
  237. package/build/src/types/route.types.d.ts +414 -0
  238. package/build/src/types/route.types.d.ts.map +1 -0
  239. package/build/src/types/route.types.js +137 -0
  240. package/build/src/types/route.types.js.map +1 -0
  241. package/build/src/web-api-fallback.d.ts +5 -0
  242. package/build/src/web-api-fallback.d.ts.map +1 -0
  243. package/build/src/web-api-fallback.js +160 -0
  244. package/build/src/web-api-fallback.js.map +1 -0
  245. package/build/src/web-route-following.d.ts +3 -0
  246. package/build/src/web-route-following.d.ts.map +1 -0
  247. package/build/src/web-route-following.js +178 -0
  248. package/build/src/web-route-following.js.map +1 -0
  249. package/build/types/native-module.types.d.ts +2 -2
  250. package/build/types/native-module.types.d.ts.map +1 -1
  251. package/build/types/native-module.types.js.map +1 -1
  252. package/build/types/naviview.types.d.ts +1 -1
  253. package/build/types/naviview.types.d.ts.map +1 -1
  254. package/build/types/naviview.types.js.map +1 -1
  255. package/build/web-api-fallback.d.ts.map +1 -1
  256. package/build/web-api-fallback.js +0 -1
  257. package/build/web-api-fallback.js.map +1 -1
  258. package/ios/map/ExpoGaodeMapView.swift +145 -3
  259. package/ios/map/managers/UIManager.swift +3 -0
  260. package/package.json +10 -7
  261. package/plugin/build/withGaodeMap.js +19 -14
@@ -0,0 +1,154 @@
1
+ import { ExpoGaodeMapModule } from './map';
2
+ export function parsePolyline(polyline) {
3
+ if (!polyline?.trim()) {
4
+ return [];
5
+ }
6
+ return polyline
7
+ .split(';')
8
+ .map((segment) => segment.trim())
9
+ .filter(Boolean)
10
+ .map((segment) => {
11
+ const [longitude, latitude] = segment.split(',').map((value) => Number(value.trim()));
12
+ if (!Number.isFinite(longitude) || !Number.isFinite(latitude)) {
13
+ return null;
14
+ }
15
+ return {
16
+ latitude,
17
+ longitude,
18
+ };
19
+ })
20
+ .filter((point) => point !== null);
21
+ }
22
+ export function dedupeAdjacentPoints(points) {
23
+ return points.filter((point, index) => {
24
+ if (index === 0) {
25
+ return true;
26
+ }
27
+ const previous = points[index - 1];
28
+ return (previous.latitude !== point.latitude ||
29
+ previous.longitude !== point.longitude);
30
+ });
31
+ }
32
+ export function haversineDistance(pointA, pointB) {
33
+ const toRadians = (degrees) => (degrees * Math.PI) / 180;
34
+ const earthRadiusMeters = 6371000;
35
+ const latitudeDelta = toRadians(pointB.latitude - pointA.latitude);
36
+ const longitudeDelta = toRadians(pointB.longitude - pointA.longitude);
37
+ const latitudeA = toRadians(pointA.latitude);
38
+ const latitudeB = toRadians(pointB.latitude);
39
+ const a = Math.sin(latitudeDelta / 2) ** 2 +
40
+ Math.cos(latitudeA) * Math.cos(latitudeB) * Math.sin(longitudeDelta / 2) ** 2;
41
+ return 2 * earthRadiusMeters * Math.asin(Math.sqrt(a));
42
+ }
43
+ export function distanceBetweenCoordinatesSafe(pointA, pointB) {
44
+ try {
45
+ return ExpoGaodeMapModule.distanceBetweenCoordinates(pointA, pointB);
46
+ }
47
+ catch {
48
+ return haversineDistance(pointA, pointB);
49
+ }
50
+ }
51
+ export function calculatePathLengthSafe(points) {
52
+ try {
53
+ return ExpoGaodeMapModule.calculatePathLength(points);
54
+ }
55
+ catch {
56
+ let total = 0;
57
+ for (let index = 1; index < points.length; index += 1) {
58
+ total += distanceBetweenCoordinatesSafe(points[index - 1], points[index]);
59
+ }
60
+ return total;
61
+ }
62
+ }
63
+ export function simplifyPolylineSafe(points, tolerance) {
64
+ if (points.length <= 2) {
65
+ return points;
66
+ }
67
+ try {
68
+ const simplified = ExpoGaodeMapModule.simplifyPolyline(points, tolerance);
69
+ return simplified.length >= 2 ? simplified : points;
70
+ }
71
+ catch {
72
+ return points;
73
+ }
74
+ }
75
+ export function getDistanceToPathSafe(path, target) {
76
+ if (path.length === 0) {
77
+ return Number.POSITIVE_INFINITY;
78
+ }
79
+ try {
80
+ const nearest = ExpoGaodeMapModule.getNearestPointOnPath(path, target);
81
+ if (nearest) {
82
+ return nearest.distanceMeters;
83
+ }
84
+ }
85
+ catch {
86
+ // ignore and fallback to point-to-point scan
87
+ }
88
+ return path.reduce((minimum, point) => {
89
+ const distance = distanceBetweenCoordinatesSafe(point, target);
90
+ return distance < minimum ? distance : minimum;
91
+ }, Number.POSITIVE_INFINITY);
92
+ }
93
+ export function samplePolyline(points, targetSamples = 36) {
94
+ if (points.length <= targetSamples) {
95
+ return points;
96
+ }
97
+ const step = Math.max(1, Math.floor(points.length / targetSamples));
98
+ const samples = points.filter((_, index) => index % step === 0);
99
+ const lastPoint = points[points.length - 1];
100
+ const lastSample = samples[samples.length - 1];
101
+ if (!lastSample ||
102
+ lastSample.latitude !== lastPoint.latitude ||
103
+ lastSample.longitude !== lastPoint.longitude) {
104
+ samples.push(lastPoint);
105
+ }
106
+ return samples;
107
+ }
108
+ export function selectEvenlySpacedPoints(points, count) {
109
+ if (count <= 0 || points.length <= count) {
110
+ return points;
111
+ }
112
+ return Array.from({ length: count }, (_, index) => {
113
+ const rawIndex = Math.round(((index + 1) * (points.length + 1)) / (count + 1)) - 1;
114
+ const boundedIndex = Math.min(points.length - 1, Math.max(0, rawIndex));
115
+ return points[boundedIndex];
116
+ });
117
+ }
118
+ export function normalizeWebRoutePolyline(webRoute) {
119
+ const directPolyline = dedupeAdjacentPoints(webRoute.polyline ?? []);
120
+ if (directPolyline.length > 1) {
121
+ return directPolyline;
122
+ }
123
+ const stepPolyline = dedupeAdjacentPoints((webRoute.steps ?? []).flatMap((step) => step.polyline ?? []));
124
+ return stepPolyline;
125
+ }
126
+ export function buildAnchorWaypointsFromWebRoute(options) {
127
+ // 这一步的目标不是“还原原始 Web 线路”,而是从 Web 线路里抽出
128
+ // 少量、间距足够大的中间锚点,方便原生独立算路尽量贴近它。
129
+ const { webRoute, maxViaPoints = 8, simplifyTolerance = 80, minSpacingMeters = 800, } = options;
130
+ const polyline = normalizeWebRoutePolyline(webRoute);
131
+ if (polyline.length <= 2) {
132
+ return [];
133
+ }
134
+ const simplified = dedupeAdjacentPoints(simplifyPolylineSafe(polyline, simplifyTolerance));
135
+ const candidatePoints = simplified.length > 2 ? simplified : polyline;
136
+ const interiorPoints = candidatePoints.slice(1, -1);
137
+ // 优先用离前一个锚点足够远的点,避免途经点过密导致原生算路失真。
138
+ const spacedPoints = [];
139
+ let previousPoint = polyline[0];
140
+ for (const point of interiorPoints) {
141
+ if (distanceBetweenCoordinatesSafe(previousPoint, point) < minSpacingMeters) {
142
+ continue;
143
+ }
144
+ spacedPoints.push(point);
145
+ previousPoint = point;
146
+ }
147
+ const waypoints = spacedPoints.length > 0
148
+ ? spacedPoints
149
+ : candidatePoints.length > 2
150
+ ? [candidatePoints[Math.floor(candidatePoints.length / 2)]]
151
+ : [];
152
+ return dedupeAdjacentPoints(selectEvenlySpacedPoints(waypoints, maxViaPoints));
153
+ }
154
+ //# sourceMappingURL=route-geometry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-geometry.js","sourceRoot":"","sources":["../../src/route-geometry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAQ3C,MAAM,UAAU,aAAa,CAAC,QAAiB;IAC7C,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC;QACtB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,QAAQ;SACZ,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;SAChC,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACf,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACtF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9D,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO;YACL,QAAQ;YACR,SAAS;SACV,CAAC;IACJ,CAAC,CAAC;SACD,M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C,YAAY;QACd,CAAC,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC;YAC1B,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;YAC3D,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,oBAAoB,CAAC,wBAAwB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;AACjF,CAAC","sourcesContent":["import { ExpoGaodeMapModule } from './map';\nimport type {\n BuildAnchorWaypointsOptions,\n NaviPoint,\n WebPlannedRoute,\n} from './types';\n\n\nexport function parsePolyline(polyline?: string): NaviPoint[] {\n if (!polyline?.trim()) {\n return [];\n }\n\n return polyline\n .split(';')\n .map((segment) => segment.trim())\n .filter(Boolean)\n .map((segment) => {\n const [longitude, latitude] = segment.split(',').map((value) => Number(value.trim()));\n if (!Number.isFinite(longitude) || !Number.isFinite(latitude)) {\n return null;\n }\n\n return {\n latitude,\n longitude,\n };\n })\n .filter((point): point is NaviPoint => point !== null);\n}\n\n\nexport function dedupeAdjacentPoints(points: NaviPoint[]): NaviPoint[] {\n return points.filter((point, index) => {\n if (index === 0) {\n return true;\n }\n\n const previous = points[index - 1];\n return (\n previous.latitude !== point.latitude ||\n previous.longitude !== point.longitude\n );\n });\n}\n\n\nexport function haversineDistance(pointA: NaviPoint, pointB: NaviPoint): number {\n const toRadians = (degrees: number) => (degrees * Math.PI) / 180;\n const earthRadiusMeters = 6371000;\n const latitudeDelta = toRadians(pointB.latitude - pointA.latitude);\n const longitudeDelta = toRadians(pointB.longitude - pointA.longitude);\n const latitudeA = toRadians(pointA.latitude);\n const latitudeB = toRadians(pointB.latitude);\n\n const a =\n Math.sin(latitudeDelta / 2) ** 2 +\n Math.cos(latitudeA) * Math.cos(latitudeB) * Math.sin(longitudeDelta / 2) ** 2;\n\n return 2 * earthRadiusMeters * Math.asin(Math.sqrt(a));\n}\n\nexport function distanceBetweenCoordinatesSafe(pointA: NaviPoint, pointB: NaviPoint): number {\n try {\n return ExpoGaodeMapModule.distanceBetweenCoordinates(pointA, pointB);\n } catch {\n return haversineDistance(pointA, pointB);\n }\n}\n\nexport function calculatePathLengthSafe(points: NaviPoint[]): number {\n try {\n return ExpoGaodeMapModule.calculatePathLength(points);\n } catch {\n let total = 0;\n for (let index = 1; index < points.length; index += 1) {\n total += distanceBetweenCoordinatesSafe(points[index - 1], points[index]);\n }\n return total;\n }\n}\n\nexport function simplifyPolylineSafe(points: NaviPoint[], tolerance: number): NaviPoint[] {\n if (points.length <= 2) {\n return points;\n }\n\n try {\n const simplified = ExpoGaodeMapModule.simplifyPolyline(points, tolerance);\n return simplified.length >= 2 ? simplified : points;\n } catch {\n return points;\n }\n}\n\nexport function getDistanceToPathSafe(path: NaviPoint[], target: NaviPoint): number {\n if (path.length === 0) {\n return Number.POSITIVE_INFINITY;\n }\n\n try {\n const nearest = ExpoGaodeMapModule.getNearestPointOnPath(path, target);\n if (nearest) {\n return nearest.distanceMeters;\n }\n } catch {\n // ignore and fallback to point-to-point scan\n }\n\n return path.reduce((minimum, point) => {\n const distance = distanceBetweenCoordinatesSafe(point, target);\n return distance < minimum ? distance : minimum;\n }, Number.POSITIVE_INFINITY);\n}\n\nexport function samplePolyline(points: NaviPoint[], targetSamples = 36): NaviPoint[] {\n if (points.length <= targetSamples) {\n return points;\n }\n\n const step = Math.max(1, Math.floor(points.length / targetSamples));\n const samples = points.filter((_, index) => index % step === 0);\n const lastPoint = points[points.length - 1];\n const lastSample = samples[samples.length - 1];\n if (\n !lastSample ||\n lastSample.latitude !== lastPoint.latitude ||\n lastSample.longitude !== lastPoint.longitude\n ) {\n samples.push(lastPoint);\n }\n return samples;\n}\n\nexport function selectEvenlySpacedPoints(points: NaviPoint[], count: number): NaviPoint[] {\n if (count <= 0 || points.length <= count) {\n return points;\n }\n\n return Array.from({ length: count }, (_, index) => {\n const rawIndex = Math.round(((index + 1) * (points.length + 1)) / (count + 1)) - 1;\n const boundedIndex = Math.min(points.length - 1, Math.max(0, rawIndex));\n return points[boundedIndex];\n });\n}\n\nexport function normalizeWebRoutePolyline(webRoute: WebPlannedRoute): NaviPoint[] {\n const directPolyline = dedupeAdjacentPoints(webRoute.polyline ?? []);\n if (directPolyline.length > 1) {\n return directPolyline;\n }\n\n const stepPolyline = dedupeAdjacentPoints(\n (webRoute.steps ?? []).flatMap((step) => step.polyline ?? [])\n );\n return stepPolyline;\n}\n\nexport function buildAnchorWaypointsFromWebRoute(\n options: BuildAnchorWaypointsOptions\n): NaviPoint[] {\n // 这一步的目标不是“还原原始 Web 线路”,而是从 Web 线路里抽出\n // 少量、间距足够大的中间锚点,方便原生独立算路尽量贴近它。\n const {\n webRoute,\n maxViaPoints = 8,\n simplifyTolerance = 80,\n minSpacingMeters = 800,\n } = options;\n\n const polyline = normalizeWebRoutePolyline(webRoute);\n if (polyline.length <= 2) {\n return [];\n }\n\n const simplified = dedupeAdjacentPoints(\n simplifyPolylineSafe(polyline, simplifyTolerance)\n );\n const candidatePoints = simplified.length > 2 ? simplified : polyline;\n const interiorPoints = candidatePoints.slice(1, -1);\n\n // 优先用离前一个锚点足够远的点,避免途经点过密导致原生算路失真。\n const spacedPoints: NaviPoint[] = [];\n let previousPoint = polyline[0];\n\n for (const point of interiorPoints) {\n if (distanceBetweenCoordinatesSafe(previousPoint, point) < minSpacingMeters) {\n continue;\n }\n spacedPoints.push(point);\n previousPoint = point;\n }\n\n const waypoints = spacedPoints.length > 0\n ? spacedPoints\n : candidatePoints.length > 2\n ? [candidatePoints[Math.floor(candidatePoints.length / 2)]]\n : [];\n\n return dedupeAdjacentPoints(selectEvenlySpacedPoints(waypoints, maxViaPoints));\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import type { ClearIndependentRouteOptions, DriveRouteOptions, DriveRouteResult, EBikeRouteOptions, IndependentDriveRouteOptions, IndependentMotorcycleRouteOptions, IndependentRideRouteOptions, IndependentTruckRouteOptions, IndependentWalkRouteOptions, MotorcycleRouteOptions, OfficialNaviPageOptions, RouteOptions, RouteResult, SelectIndependentRouteOptions, StartNaviWithIndependentPathOptions, TransitRouteOptions, TruckRouteOptions, WalkRouteOptions, RideRouteOptions } from './types';
2
+ export declare const initNavigation: () => void;
3
+ export declare const destroyAllCalculators: () => void;
4
+ export declare function calculateDriveRoute(options: DriveRouteOptions): Promise<DriveRouteResult>;
5
+ export declare const calculateWalkRoute: (options: WalkRouteOptions) => Promise<RouteResult>;
6
+ export declare const calculateRideRoute: (options: RideRouteOptions) => Promise<RouteResult>;
7
+ export declare const calculateEBikeRoute: (options: EBikeRouteOptions) => Promise<RouteResult>;
8
+ export declare const calculateTruckRoute: (options: TruckRouteOptions) => Promise<DriveRouteResult>;
9
+ export declare const calculateMotorcycleRoute: (options: MotorcycleRouteOptions) => Promise<DriveRouteResult>;
10
+ export declare function calculateTransitRoute(options: TransitRouteOptions): Promise<DriveRouteResult>;
11
+ export declare function calculateRoute(options: RouteOptions): Promise<RouteResult | DriveRouteResult>;
12
+ export declare const independentDriveRoute: (options: IndependentDriveRouteOptions) => Promise<import("./types").IndependentRouteResult>;
13
+ export declare const independentTruckRoute: (options: IndependentTruckRouteOptions) => Promise<import("./types").IndependentRouteResult>;
14
+ export declare const independentWalkRoute: (options: IndependentWalkRouteOptions) => Promise<import("./types").IndependentRouteResult>;
15
+ export declare const independentRideRoute: (options: IndependentRideRouteOptions) => Promise<import("./types").IndependentRouteResult>;
16
+ export declare const independentMotorcycleRoute: (options: IndependentMotorcycleRouteOptions) => Promise<import("./types").IndependentRouteResult>;
17
+ export declare const selectIndependentRoute: (options: SelectIndependentRouteOptions) => Promise<boolean>;
18
+ export declare const startNaviWithIndependentPath: (options: StartNaviWithIndependentPathOptions) => Promise<boolean>;
19
+ export declare const openOfficialNaviPage: (options: OfficialNaviPageOptions) => Promise<boolean>;
20
+ export declare const clearIndependentRoute: (options: ClearIndependentRouteOptions) => Promise<boolean>;
21
+ //# sourceMappingURL=route-planning.d.ts.map
@@ -0,0 +1 @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eAAO,MAAM,oBAAoB,GAAI,SAAS,2BAA2B,sDACb,CAAC;AAE7D,eAAO,MAAM,0BAA0B,GAAI,SAAS,iCAAiC,sDACnB,CAAC;AAEnE,eAAO,MAAM,sBAAsB,GAAI,SAAS,6BAA6B,qBACf,CAAC;AAE/D,eAAO,MAAM,4BAA4B,GAAI,SAAS,mCAAmC,qBACrB,CAAC;AAErE,eAAO,MAAM,oBAAoB,GAAI,SAAS,uBAAuB,qBACT,CAAC;AAE7D,eAAO,MAAM,qBAAqB,GAAI,SAAS,4BAA4B,qBACd,CAAC"}
@@ -0,0 +1,67 @@
1
+ import ExpoGaodeMapNavigationModule from './ExpoGaodeMapNavigationModule';
2
+ import { calculateDriveRouteWithAvoidPreview, calculateTransitRouteWithWebApi, shouldUseAvoidPreviewFallback, } from './web-api-fallback';
3
+ import { RouteType } from './types';
4
+ export const initNavigation = () => ExpoGaodeMapNavigationModule.initNavigation();
5
+ export const destroyAllCalculators = () => ExpoGaodeMapNavigationModule.destroyAllCalculators();
6
+ export async function calculateDriveRoute(options) {
7
+ // 驾车算路先检查是否需要规避预览;只有在这类场景下才临时回退 Web API。
8
+ if (shouldUseAvoidPreviewFallback(options)) {
9
+ try {
10
+ return await calculateDriveRouteWithAvoidPreview(options);
11
+ }
12
+ catch {
13
+ // 若未安装 Web API 包,则保持现有原生逻辑不变。
14
+ // 这样不会破坏当前依赖 Android 反射重载的项目。
15
+ }
16
+ }
17
+ return ExpoGaodeMapNavigationModule.calculateDriveRoute(options);
18
+ }
19
+ export const calculateWalkRoute = (options) => ExpoGaodeMapNavigationModule.calculateWalkRoute(options);
20
+ export const calculateRideRoute = (options) => ExpoGaodeMapNavigationModule.calculateRideRoute(options);
21
+ export const calculateEBikeRoute = (options) => ExpoGaodeMapNavigationModule.calculateEBikeRoute(options);
22
+ export const calculateTruckRoute = (options) => ExpoGaodeMapNavigationModule.calculateTruckRoute(options);
23
+ export const calculateMotorcycleRoute = (options) => ExpoGaodeMapNavigationModule.calculateMotorcycleRoute(options);
24
+ export async function calculateTransitRoute(options) {
25
+ return calculateTransitRouteWithWebApi(options);
26
+ }
27
+ function hasStrategyOption(options) {
28
+ return 'strategy' in options;
29
+ }
30
+ function isMotorcycleRouteOptions(options) {
31
+ return 'motorcycleCC' in options;
32
+ }
33
+ export async function calculateRoute(options) {
34
+ // 这里是统一入口,按“最明确的类型特征”逐层分流。
35
+ // 顺序很重要:先看显式 type,再看货车 / 步骑 / 摩托车,最后才回到默认驾车。
36
+ if ('type' in options && options.type === RouteType.TRANSIT) {
37
+ return calculateTransitRoute(options);
38
+ }
39
+ if ('size' in options) {
40
+ return calculateTruckRoute(options);
41
+ }
42
+ if ('multiple' in options || 'travelStrategy' in options) {
43
+ // 电动车 / 步行 / 骑行这几类在 JS 层会共享部分字段,先用 usePoi 做电动车识别。
44
+ if ('usePoi' in options)
45
+ return ExpoGaodeMapNavigationModule.calculateEBikeRoute(options);
46
+ // 骑行和步行的区分主要看 strategy 值;其余情况默认按步行处理。
47
+ const strategy = hasStrategyOption(options) ? options.strategy : undefined;
48
+ if (strategy === 0 || strategy === 1) {
49
+ return calculateRideRoute(options);
50
+ }
51
+ return calculateWalkRoute(options);
52
+ }
53
+ if (isMotorcycleRouteOptions(options)) {
54
+ return calculateMotorcycleRoute(options);
55
+ }
56
+ return calculateDriveRoute(options);
57
+ }
58
+ export const independentDriveRoute = (options) => ExpoGaodeMapNavigationModule.independentDriveRoute(options);
59
+ export const independentTruckRoute = (options) => ExpoGaodeMapNavigationModule.independentTruckRoute(options);
60
+ export const independentWalkRoute = (options) => ExpoGaodeMapNavigationModule.independentWalkRoute(options);
61
+ export const independentRideRoute = (options) => ExpoGaodeMapNavigationModule.independentRideRoute(options);
62
+ export const independentMotorcycleRoute = (options) => ExpoGaodeMapNavigationModule.independentMotorcycleRoute(options);
63
+ export const selectIndependentRoute = (options) => ExpoGaodeMapNavigationModule.selectIndependentRoute(options);
64
+ export const startNaviWithIndependentPath = (options) => ExpoGaodeMapNavigationModule.startNaviWithIndependentPath(options);
65
+ export const openOfficialNaviPage = (options) => ExpoGaodeMapNavigationModule.openOfficialNaviPage(options);
66
+ export const clearIndependentRoute = (options) => ExpoGaodeMapNavigationModule.clearIndependentRoute(options);
67
+ //# sourceMappingURL=route-planning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-planning.js","sourceRoot":"","sources":["../../src/route-planning.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EACL,mCAAmC,EACnC,+BAA+B,EAC/B,6BAA6B,GAC9B,MAAM,oBAAoB,CAAC;AAsB5B,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,4BAA4B,CAAC,cAAc,EAAE,CAAC;AAElF,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE,CAAC,4BAA4B,CAAC,qBAAqB,EAAE,CAAC;AAEhG,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAA0B;IAE1B,yCAAyC;IACzC,IAAI,6BAA6B,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,IAAI,CAAC;YACH,OAAO,MAAM,mCAAmC,CAAC,OAAO,CAAC,CAAC;QAC5D,CAAC;QAAC,MAAM,CAAC;YACP,8BAA8B;YAC9B,8BAA8B;QAChC,CAAC;IACH,CAAC;IAED,OAAO,4BAA4B,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAyB,EAAE,EAAE,CAC9D,4BAA4B,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAE3D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAyB,EAAE,EAAE,CAC9D,4BAA4B,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAE3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,C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AAE,CACvE,4BAA4B,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAE7D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,OAAqC,EAAE,EAAE,CAC7E,4BAA4B,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC","sourcesContent":["import ExpoGaodeMapNavigationModule from './ExpoGaodeMapNavigationModule';\nimport {\n calculateDriveRouteWithAvoidPreview,\n calculateTransitRouteWithWebApi,\n shouldUseAvoidPreviewFallback,\n} from './web-api-fallback';\nimport type {\n ClearIndependentRouteOptions,\n DriveRouteOptions,\n DriveRouteResult,\n EBikeRouteOptions,\n IndependentDriveRouteOptions,\n IndependentMotorcycleRouteOptions,\n IndependentRideRouteOptions,\n IndependentTruckRouteOptions,\n IndependentWalkRouteOptions,\n MotorcycleRouteOptions,\n OfficialNaviPageOptions,\n RouteOptions,\n RouteResult,\n SelectIndependentRouteOptions,\n StartNaviWithIndependentPathOptions,\n TransitRouteOptions,\n TruckRouteOptions,\n WalkRouteOptions,\n RideRouteOptions,\n} from './types';\nimport { RouteType } from './types';\n\nexport const initNavigation = () => ExpoGaodeMapNavigationModule.initNavigation();\n\nexport const destroyAllCalculators = () => ExpoGaodeMapNavigationModule.destroyAllCalculators();\n\nexport async function calculateDriveRoute(\n options: DriveRouteOptions\n): Promise<DriveRouteResult> {\n // 驾车算路先检查是否需要规避预览;只有在这类场景下才临时回退 Web API。\n if (shouldUseAvoidPreviewFallback(options)) {\n try {\n return await calculateDriveRouteWithAvoidPreview(options);\n } catch {\n // 若未安装 Web API 包,则保持现有原生逻辑不变。\n // 这样不会破坏当前依赖 Android 反射重载的项目。\n }\n }\n\n return ExpoGaodeMapNavigationModule.calculateDriveRoute(options);\n}\n\nexport const calculateWalkRoute = (options: WalkRouteOptions) =>\n ExpoGaodeMapNavigationModule.calculateWalkRoute(options);\n\nexport const calculateRideRoute = (options: RideRouteOptions) =>\n ExpoGaodeMapNavigationModule.calculateRideRoute(options);\n\nexport const calculateEBikeRoute = (options: EBikeRouteOptions) =>\n ExpoGaodeMapNavigationModule.calculateEBikeRoute(options);\n\nexport const calculateTruckRoute = (options: TruckRouteOptions) =>\n ExpoGaodeMapNavigationModule.calculateTruckRoute(options);\n\nexport const calculateMotorcycleRoute = (options: MotorcycleRouteOptions) =>\n ExpoGaodeMapNavigationModule.calculateMotorcycleRoute(options);\n\nexport async function calculateTransitRoute(options: TransitRouteOptions): Promise<DriveRouteResult> {\n return calculateTransitRouteWithWebApi(options);\n}\n\nfunction hasStrategyOption(\n options: RouteOptions\n): options is WalkRouteOptions | RideRouteOptions {\n return 'strategy' in options;\n}\n\nfunction isMotorcycleRouteOptions(\n options: RouteOptions | MotorcycleRouteOptions\n): options is MotorcycleRouteOptions {\n return 'motorcycleCC' in options;\n}\n\nexport async function calculateRoute(\n options: RouteOptions\n): Promise<RouteResult | DriveRouteResult> {\n // 这里是统一入口,按“最明确的类型特征”逐层分流。\n // 顺序很重要:先看显式 type,再看货车 / 步骑 / 摩托车,最后才回到默认驾车。\n if ('type' in options && options.type === RouteType.TRANSIT) {\n return calculateTransitRoute(options as TransitRouteOptions);\n }\n\n if ('size' in options) {\n return calculateTruckRoute(options as TruckRouteOptions);\n }\n\n if ('multiple' in options || 'travelStrategy' in options) {\n // 电动车 / 步行 / 骑行这几类在 JS 层会共享部分字段,先用 usePoi 做电动车识别。\n if ('usePoi' in options) return ExpoGaodeMapNavigationModule.calculateEBikeRoute(options as EBikeRouteOptions);\n\n // 骑行和步行的区分主要看 strategy 值;其余情况默认按步行处理。\n const strategy = hasStrategyOption(options) ? options.strategy : undefined;\n if (strategy === 0 || strategy === 1) {\n return calculateRideRoute(options as RideRouteOptions);\n }\n return calculateWalkRoute(options as WalkRouteOptions);\n }\n\n if (isMotorcycleRouteOptions(options)) {\n return calculateMotorcycleRoute(options as MotorcycleRouteOptions);\n }\n\n return calculateDriveRoute(options as DriveRouteOptions);\n}\n\nexport const independentDriveRoute = (options: IndependentDriveRouteOptions) =>\n ExpoGaodeMapNavigationModule.independentDriveRoute(options);\n\nexport const independentTruckRoute = (options: IndependentTruckRouteOptions) =>\n ExpoGaodeMapNavigationModule.independentTruckRoute(options);\n\nexport const independentWalkRoute = (options: IndependentWalkRouteOptions) =>\n ExpoGaodeMapNavigationModule.independentWalkRoute(options);\n\nexport const independentRideRoute = (options: IndependentRideRouteOptions) =>\n ExpoGaodeMapNavigationModule.independentRideRoute(options);\n\nexport const independentMotorcycleRoute = (options: IndependentMotorcycleRouteOptions) =>\n ExpoGaodeMapNavigationModule.independentMotorcycleRoute(options);\n\nexport const selectIndependentRoute = (options: SelectIndependentRouteOptions) =>\n ExpoGaodeMapNavigationModule.selectIndependentRoute(options);\n\nexport const startNaviWithIndependentPath = (options: StartNaviWithIndependentPathOptions) =>\n ExpoGaodeMapNavigationModule.startNaviWithIndependentPath(options);\n\nexport const openOfficialNaviPage = (options: OfficialNaviPageOptions) =>\n ExpoGaodeMapNavigationModule.openOfficialNaviPage(options);\n\nexport const clearIndependentRoute = (options: ClearIndependentRouteOptions) =>\n ExpoGaodeMapNavigationModule.clearIndependentRoute(options);\n"]}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * 导航模块坐标类型定义
3
+ * 简化版本,仅包含导航所需的基础坐标
4
+ */
5
+ /**
6
+ * 导航坐标点(简化版)
7
+ */
8
+ export interface NaviPoint {
9
+ latitude: number;
10
+ longitude: number;
11
+ }
12
+ /**
13
+ * 带名称的坐标点(POI)
14
+ */
15
+ export interface NamedCoordinates extends NaviPoint {
16
+ /** 名称 */
17
+ name?: string;
18
+ /** POI ID */
19
+ poiId?: string;
20
+ }
21
+ /**
22
+ * @deprecated 请使用 `NaviPoint`
23
+ */
24
+ export type Coordinates = NaviPoint;
25
+ //# sourceMappingURL=coordinates.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinates.types.d.ts","sourceRoot":"","sources":["../../../src/types/coordinates.types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IACjD,SAAS;IACT,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 导航模块坐标类型定义
3
+ * 简化版本,仅包含导航所需的基础坐标
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=coordinates.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinates.types.js","sourceRoot":"","sources":["../../../src/types/coordinates.types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * 导航模块坐标类型定义\n * 简化版本,仅包含导航所需的基础坐标\n */\n\n/**\n * 导航坐标点(简化版)\n */\nexport interface NaviPoint {\n latitude: number;\n longitude: number;\n}\n\n/**\n * 带名称的坐标点(POI)\n */\nexport interface NamedCoordinates extends NaviPoint {\n /** 名称 */\n name?: string;\n /** POI ID */\n poiId?: string;\n}\n\n/**\n * @deprecated 请使用 `NaviPoint`\n */\nexport type Coordinates = NaviPoint;\n"]}