expo-gaode-map-navigation 2.0.17 → 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 (277) hide show
  1. package/android/build.gradle +10 -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 +13 -4
  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/ErrorHandler.d.ts +4 -0
  59. package/build/map/utils/ErrorHandler.d.ts.map +1 -1
  60. package/build/map/utils/ErrorHandler.js +8 -0
  61. package/build/map/utils/ErrorHandler.js.map +1 -1
  62. package/build/map/utils/GeoUtils.d.ts +1 -1
  63. package/build/map/utils/GeoUtils.d.ts.map +1 -1
  64. package/build/map/utils/GeoUtils.js +2 -2
  65. package/build/map/utils/GeoUtils.js.map +1 -1
  66. package/build/route-geometry.d.ts.map +1 -1
  67. package/build/route-geometry.js +24 -8
  68. package/build/route-geometry.js.map +1 -1
  69. package/build/src/ExpoGaodeMapNaviView.d.ts +67 -0
  70. package/build/src/ExpoGaodeMapNaviView.d.ts.map +1 -0
  71. package/build/src/ExpoGaodeMapNaviView.js +138 -0
  72. package/build/src/ExpoGaodeMapNaviView.js.map +1 -0
  73. package/build/src/ExpoGaodeMapNavigation.types.d.ts +2 -0
  74. package/build/src/ExpoGaodeMapNavigation.types.d.ts.map +1 -0
  75. package/build/src/ExpoGaodeMapNavigation.types.js +3 -0
  76. package/build/src/ExpoGaodeMapNavigation.types.js.map +1 -0
  77. package/build/src/ExpoGaodeMapNavigationModule.d.ts +4 -0
  78. package/build/src/ExpoGaodeMapNavigationModule.d.ts.map +1 -0
  79. package/build/src/ExpoGaodeMapNavigationModule.js +27 -0
  80. package/build/src/ExpoGaodeMapNavigationModule.js.map +1 -0
  81. package/build/src/index.d.ts +47 -0
  82. package/build/src/index.d.ts.map +1 -0
  83. package/build/src/index.js +48 -0
  84. package/build/src/index.js.map +1 -0
  85. package/build/src/map/ExpoGaodeMapModule.d.ts +256 -0
  86. package/build/src/map/ExpoGaodeMapModule.d.ts.map +1 -0
  87. package/build/src/map/ExpoGaodeMapModule.js +813 -0
  88. package/build/src/map/ExpoGaodeMapModule.js.map +1 -0
  89. package/build/src/map/ExpoGaodeMapOfflineModule.d.ts +145 -0
  90. package/build/src/map/ExpoGaodeMapOfflineModule.d.ts.map +1 -0
  91. package/build/src/map/ExpoGaodeMapOfflineModule.js +24 -0
  92. package/build/src/map/ExpoGaodeMapOfflineModule.js.map +1 -0
  93. package/build/src/map/ExpoGaodeMapView.d.ts +23 -0
  94. package/build/src/map/ExpoGaodeMapView.d.ts.map +1 -0
  95. package/build/src/map/ExpoGaodeMapView.js +173 -0
  96. package/build/src/map/ExpoGaodeMapView.js.map +1 -0
  97. package/build/src/map/components/FoldableMapView.d.ts +39 -0
  98. package/build/src/map/components/FoldableMapView.d.ts.map +1 -0
  99. package/build/src/map/components/FoldableMapView.js +171 -0
  100. package/build/src/map/components/FoldableMapView.js.map +1 -0
  101. package/build/src/map/components/MapContext.d.ts +13 -0
  102. package/build/src/map/components/MapContext.d.ts.map +1 -0
  103. package/build/src/map/components/MapContext.js +18 -0
  104. package/build/src/map/components/MapContext.js.map +1 -0
  105. package/build/src/map/components/MapUI.d.ts +19 -0
  106. package/build/src/map/components/MapUI.d.ts.map +1 -0
  107. package/build/src/map/components/MapUI.js +24 -0
  108. package/build/src/map/components/MapUI.js.map +1 -0
  109. package/build/src/map/components/overlays/Circle.d.ts +13 -0
  110. package/build/src/map/components/overlays/Circle.d.ts.map +1 -0
  111. package/build/src/map/components/overlays/Circle.js +20 -0
  112. package/build/src/map/components/overlays/Circle.js.map +1 -0
  113. package/build/src/map/components/overlays/Cluster.d.ts +12 -0
  114. package/build/src/map/components/overlays/Cluster.d.ts.map +1 -0
  115. package/build/src/map/components/overlays/Cluster.js +16 -0
  116. package/build/src/map/components/overlays/Cluster.js.map +1 -0
  117. package/build/src/map/components/overlays/HeatMap.d.ts +12 -0
  118. package/build/src/map/components/overlays/HeatMap.d.ts.map +1 -0
  119. package/build/src/map/components/overlays/HeatMap.js +46 -0
  120. package/build/src/map/components/overlays/HeatMap.js.map +1 -0
  121. package/build/src/map/components/overlays/Marker.d.ts +16 -0
  122. package/build/src/map/components/overlays/Marker.d.ts.map +1 -0
  123. package/build/src/map/components/overlays/Marker.js +125 -0
  124. package/build/src/map/components/overlays/Marker.js.map +1 -0
  125. package/build/src/map/components/overlays/MultiPoint.d.ts +9 -0
  126. package/build/src/map/components/overlays/MultiPoint.d.ts.map +1 -0
  127. package/build/src/map/components/overlays/MultiPoint.js +15 -0
  128. package/build/src/map/components/overlays/MultiPoint.js.map +1 -0
  129. package/build/src/map/components/overlays/Polygon.d.ts +12 -0
  130. package/build/src/map/components/overlays/Polygon.d.ts.map +1 -0
  131. package/build/src/map/components/overlays/Polygon.js +20 -0
  132. package/build/src/map/components/overlays/Polygon.js.map +1 -0
  133. package/build/src/map/components/overlays/Polyline.d.ts +12 -0
  134. package/build/src/map/components/overlays/Polyline.d.ts.map +1 -0
  135. package/build/src/map/components/overlays/Polyline.js +20 -0
  136. package/build/src/map/components/overlays/Polyline.js.map +1 -0
  137. package/build/src/map/components/overlays/index.d.ts +8 -0
  138. package/build/src/map/components/overlays/index.d.ts.map +1 -0
  139. package/build/src/map/components/overlays/index.js +8 -0
  140. package/build/src/map/components/overlays/index.js.map +1 -0
  141. package/build/src/map/index.d.ts +35 -0
  142. package/build/src/map/index.d.ts.map +1 -0
  143. package/build/src/map/index.js +48 -0
  144. package/build/src/map/index.js.map +1 -0
  145. package/build/src/map/search/ExpoGaodeMapSearch.types.d.ts +340 -0
  146. package/build/src/map/search/ExpoGaodeMapSearch.types.d.ts.map +1 -0
  147. package/build/src/map/search/ExpoGaodeMapSearch.types.js +19 -0
  148. package/build/src/map/search/ExpoGaodeMapSearch.types.js.map +1 -0
  149. package/build/src/map/search/ExpoGaodeMapSearchModule.d.ts +74 -0
  150. package/build/src/map/search/ExpoGaodeMapSearchModule.d.ts.map +1 -0
  151. package/build/src/map/search/ExpoGaodeMapSearchModule.js +48 -0
  152. package/build/src/map/search/ExpoGaodeMapSearchModule.js.map +1 -0
  153. package/build/src/map/search/index.d.ts +156 -0
  154. package/build/src/map/search/index.d.ts.map +1 -0
  155. package/build/src/map/search/index.js +171 -0
  156. package/build/src/map/search/index.js.map +1 -0
  157. package/build/src/map/types/common.types.d.ts +199 -0
  158. package/build/src/map/types/common.types.d.ts.map +1 -0
  159. package/build/src/map/types/common.types.js +33 -0
  160. package/build/src/map/types/common.types.js.map +1 -0
  161. package/build/src/map/types/index.d.ts +13 -0
  162. package/build/src/map/types/index.d.ts.map +1 -0
  163. package/build/src/map/types/index.js +7 -0
  164. package/build/src/map/types/index.js.map +1 -0
  165. package/build/src/map/types/location.types.d.ts +358 -0
  166. package/build/src/map/types/location.types.d.ts.map +1 -0
  167. package/build/src/map/types/location.types.js +93 -0
  168. package/build/src/map/types/location.types.js.map +1 -0
  169. package/build/src/map/types/map-view.types.d.ts +340 -0
  170. package/build/src/map/types/map-view.types.d.ts.map +1 -0
  171. package/build/src/map/types/map-view.types.js +6 -0
  172. package/build/src/map/types/map-view.types.js.map +1 -0
  173. package/build/src/map/types/native-module.types.d.ts +395 -0
  174. package/build/src/map/types/native-module.types.d.ts.map +1 -0
  175. package/build/src/map/types/native-module.types.js +5 -0
  176. package/build/src/map/types/native-module.types.js.map +1 -0
  177. package/build/src/map/types/offline.types.d.ts +133 -0
  178. package/build/src/map/types/offline.types.d.ts.map +1 -0
  179. package/build/src/map/types/offline.types.js +5 -0
  180. package/build/src/map/types/offline.types.js.map +1 -0
  181. package/build/src/map/types/overlays.types.d.ts +456 -0
  182. package/build/src/map/types/overlays.types.d.ts.map +1 -0
  183. package/build/src/map/types/overlays.types.js +6 -0
  184. package/build/src/map/types/overlays.types.js.map +1 -0
  185. package/build/src/map/types/route-playback.types.d.ts +28 -0
  186. package/build/src/map/types/route-playback.types.d.ts.map +1 -0
  187. package/build/src/map/types/route-playback.types.js +2 -0
  188. package/build/src/map/types/route-playback.types.js.map +1 -0
  189. package/build/src/map/utils/ErrorHandler.d.ts +121 -0
  190. package/build/src/map/utils/ErrorHandler.d.ts.map +1 -0
  191. package/build/src/map/utils/ErrorHandler.js +470 -0
  192. package/build/src/map/utils/ErrorHandler.js.map +1 -0
  193. package/build/src/map/utils/GeoUtils.d.ts +21 -0
  194. package/build/src/map/utils/GeoUtils.d.ts.map +1 -0
  195. package/build/src/map/utils/GeoUtils.js +78 -0
  196. package/build/src/map/utils/GeoUtils.js.map +1 -0
  197. package/build/src/map/utils/OfflineMapManager.d.ts +153 -0
  198. package/build/src/map/utils/OfflineMapManager.d.ts.map +1 -0
  199. package/build/src/map/utils/OfflineMapManager.js +217 -0
  200. package/build/src/map/utils/OfflineMapManager.js.map +1 -0
  201. package/build/src/map/utils/PermissionUtils.d.ts +92 -0
  202. package/build/src/map/utils/PermissionUtils.d.ts.map +1 -0
  203. package/build/src/map/utils/PermissionUtils.js +252 -0
  204. package/build/src/map/utils/PermissionUtils.js.map +1 -0
  205. package/build/src/map/utils/PlatformDetector.d.ts +103 -0
  206. package/build/src/map/utils/PlatformDetector.d.ts.map +1 -0
  207. package/build/src/map/utils/PlatformDetector.js +178 -0
  208. package/build/src/map/utils/PlatformDetector.js.map +1 -0
  209. package/build/src/map/utils/lazyNativeViewManager.d.ts +3 -0
  210. package/build/src/map/utils/lazyNativeViewManager.d.ts.map +1 -0
  211. package/build/src/map/utils/lazyNativeViewManager.js +11 -0
  212. package/build/src/map/utils/lazyNativeViewManager.js.map +1 -0
  213. package/build/src/route-geometry.d.ts +13 -0
  214. package/build/src/route-geometry.d.ts.map +1 -0
  215. package/build/src/route-geometry.js +154 -0
  216. package/build/src/route-geometry.js.map +1 -0
  217. package/build/src/route-planning.d.ts +21 -0
  218. package/build/src/route-planning.d.ts.map +1 -0
  219. package/build/src/route-planning.js +67 -0
  220. package/build/src/route-planning.js.map +1 -0
  221. package/build/src/types/coordinates.types.d.ts +25 -0
  222. package/build/src/types/coordinates.types.d.ts.map +1 -0
  223. package/build/src/types/coordinates.types.js +6 -0
  224. package/build/src/types/coordinates.types.js.map +1 -0
  225. package/build/src/types/independent.types.d.ts +385 -0
  226. package/build/src/types/independent.types.d.ts.map +1 -0
  227. package/build/src/types/independent.types.js +2 -0
  228. package/build/src/types/independent.types.js.map +1 -0
  229. package/build/src/types/index.d.ts +6 -0
  230. package/build/src/types/index.d.ts.map +1 -0
  231. package/build/src/types/index.js +7 -0
  232. package/build/src/types/index.js.map +1 -0
  233. package/build/src/types/native-module.types.d.ts +74 -0
  234. package/build/src/types/native-module.types.d.ts.map +1 -0
  235. package/build/src/types/native-module.types.js +3 -0
  236. package/build/src/types/native-module.types.js.map +1 -0
  237. package/build/src/types/naviview.types.d.ts +562 -0
  238. package/build/src/types/naviview.types.d.ts.map +1 -0
  239. package/build/src/types/naviview.types.js +2 -0
  240. package/build/src/types/naviview.types.js.map +1 -0
  241. package/build/src/types/route.types.d.ts +414 -0
  242. package/build/src/types/route.types.d.ts.map +1 -0
  243. package/build/src/types/route.types.js +137 -0
  244. package/build/src/types/route.types.js.map +1 -0
  245. package/build/src/web-api-fallback.d.ts +5 -0
  246. package/build/src/web-api-fallback.d.ts.map +1 -0
  247. package/build/src/web-api-fallback.js +160 -0
  248. package/build/src/web-api-fallback.js.map +1 -0
  249. package/build/src/web-route-following.d.ts +3 -0
  250. package/build/src/web-route-following.d.ts.map +1 -0
  251. package/build/src/web-route-following.js +178 -0
  252. package/build/src/web-route-following.js.map +1 -0
  253. package/build/types/native-module.types.d.ts +2 -2
  254. package/build/types/native-module.types.d.ts.map +1 -1
  255. package/build/types/native-module.types.js.map +1 -1
  256. package/build/types/naviview.types.d.ts +1 -1
  257. package/build/types/naviview.types.d.ts.map +1 -1
  258. package/build/types/naviview.types.js.map +1 -1
  259. package/build/web-api-fallback.d.ts.map +1 -1
  260. package/build/web-api-fallback.js +0 -1
  261. package/build/web-api-fallback.js.map +1 -1
  262. package/ios/map/ExpoGaodeMapView.swift +145 -3
  263. package/ios/map/cpp/ClusterEngine.cpp +4 -14
  264. package/ios/map/cpp/ClusterEngine.hpp +1 -12
  265. package/ios/map/cpp/ClusterTypes.hpp +18 -0
  266. package/ios/map/cpp/ColorParser.cpp +22 -3
  267. package/ios/map/cpp/GeometryEngine.cpp +1 -1
  268. package/ios/map/cpp/QuadTree.hpp +1 -1
  269. package/ios/map/managers/UIManager.swift +3 -0
  270. package/package.json +16 -8
  271. package/plugin/build/withGaodeMap.js +19 -14
  272. package/shared/cpp/ClusterEngine.cpp +4 -14
  273. package/shared/cpp/ClusterEngine.hpp +1 -12
  274. package/shared/cpp/ClusterTypes.hpp +18 -0
  275. package/shared/cpp/ColorParser.cpp +22 -3
  276. package/shared/cpp/GeometryEngine.cpp +1 -1
  277. package/shared/cpp/QuadTree.hpp +1 -1
@@ -1 +1 @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AgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,WAAW,EAAE,eAAe;KAC7B,CACF,CAAC;IAEF,OAAO,2BAA2B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import { DriveStrategy } from './types';\nimport type { DriveRouteOptions, DriveRouteResult, RouteResult, TransitRouteOptions } from './types';\nimport { parsePolyline } from './route-geometry';\n\nasync function loadWebApiFallback(feature: '公交路径规划' | '规避路线预览') {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const webApi = require('expo-gaode-map-web-api');\n if (typeof webApi?.GaodeWebAPI !== 'function') {\n throw new Error('expo-gaode-map-web-api 未导出 GaodeWebAPI');\n }\n return webApi;\n } catch {\n throw new Error(\n `${feature}依赖 expo-gaode-map-web-api。请安装该包,并在 ExpoGaodeMapModule.initSDK 中提供 webKey。`\n );\n }\n}\n\nfunction normalizeAvoidPolygons(polygons?: DriveRouteOptions['avoidPolygons']): string | undefined {\n if (!polygons?.length) {\n return undefined;\n }\n\n const normalized = polygons\n .map((polygon) =>\n polygon\n .map((point) => `${point.longitude},${point.latitude}`)\n .join(';')\n )\n .filter(Boolean)\n .join('|');\n\n return normalized || undefined;\n}\n\nfunction normalizeDrivingStrategy(\n strategy?: DriveStrategy\n): number | undefined {\n // 导航 SDK 与 Web API 的策略枚举不完全一致。\n // 这里做“尽量等价”的映射,主要用于带规避参数时的路线预览。\n switch (strategy) {\n case DriveStrategy.FASTEST:\n return 38;\n case DriveStrategy.FEE_FIRST:\n return 1;\n case DriveStrategy.SHORTEST:\n return 2;\n case DriveStrategy.NO_EXPRESSWAYS:\n return 37;\n case DriveStrategy.AVOID_CONGESTION:\n return 33;\n case DriveStrategy.NO_HIGHWAY:\n return 35;\n case DriveStrategy.NO_HIGHWAY_AVOID_CONGESTION:\n return 40;\n case DriveStrategy.AVOID_COST_CONGESTION:\n case DriveStrategy.AVOID_CONGESTION_COST:\n return 41;\n case DriveStrategy.NO_HIGHWAY_AVOID_COST_CONGESTION:\n return 43;\n default:\n return undefined;\n }\n}\n\nfunction normalizeDrivingRouteResult(\n options: DriveRouteOptions,\n result: any\n): DriveRouteResult {\n // 把 Web API 的原始字段翻译成导航包已经对外稳定的 RouteResult 结构。\n // 这样上层代码不需要知道 Web API 的字段名,也不用为 fallback 单独写分支。\n const paths = result?.route?.paths ?? [];\n const routes = paths.map((path: any, index: number) => {\n const segments = (path?.steps ?? []).map((step: any) => ({\n instruction: step?.instruction ?? '',\n orientation: step?.orientation,\n road: step?.road_name,\n distance: Number(step?.step_distance ?? 0),\n duration: Number(step?.cost?.duration ?? 0),\n polyline: parsePolyline(step?.polyline),\n assistantAction: step?.assistant_action,\n tollDistance: step?.cost?.toll_distance ? Number(step.cost.toll_distance) : undefined,\n tollCost: step?.cost?.tolls ? Number(step.cost.tolls) : undefined,\n }));\n\n const restrictionCode = path?.restriction != null ? Number(path.restriction) : undefined;\n\n return {\n id: index,\n start: options.from,\n end: options.to,\n distance: Number(path?.distance ?? 0),\n duration: Number(path?.cost?.duration ?? path?.duration ?? 0),\n segments,\n polyline: segments.flatMap((segment: { polyline: any[] }) => segment.polyline),\n tollDistance: path?.cost?.toll_distance ? Number(path.cost.toll_distance) : undefined,\n tollCost: path?.cost?.tolls ? Number(path.cost.tolls) : undefined,\n trafficLightCount: path?.cost?.traffic_lights ? Number(path.cost.traffic_lights) : undefined,\n restrictionCode,\n restrictionInfo:\n restrictionCode === 0\n ? '限行已规避或未限行'\n : restrictionCode === 1\n ? '限行无法规避'\n : undefined,\n strategy: options.strategy,\n };\n });\n\n return {\n count: Number(result?.count ?? routes.length),\n mainPathIndex: 0,\n routeIds: routes.map((route: RouteResult) => route.id),\n routes,\n taxiCost: result?.route?.taxi_cost ? Number(result.route.taxi_cost) : undefined,\n };\n}\n\nexport function shouldUseAvoidPreviewFallback(options: DriveRouteOptions): boolean {\n // 只有出现“规避道路 / 规避区域”时才需要走 Web API 预览。\n // 普通驾车算路仍然优先走原生能力。\n return Boolean(options.avoidRoad?.trim() || options.avoidPolygons?.length);\n}\n\nexport async function calculateDriveRouteWithAvoidPreview(\n options: DriveRouteOptions\n): Promise<DriveRouteResult> {\n // Web API 只负责“预览规避后的路线”,不是替代原生导航 SDK。\n // 失败时让调用方回退到原生实现,避免把可用路径规划直接变成报错。\n const { GaodeWebAPI } = await loadWebApiFallback('规避路线预览');\n const api = new GaodeWebAPI();\n const result = await api.route.driving(\n `${options.from.longitude},${options.from.latitude}`,\n `${options.to.longitude},${options.to.latitude}`,\n {\n strategy: normalizeDrivingStrategy(options.strategy),\n waypoints: options.waypoints?.map(\n (point) => `${point.longitude},${point.latitude}`\n ),\n avoidpolygons: normalizeAvoidPolygons(options.avoidPolygons),\n avoidroad: options.avoidRoad?.trim() || undefined,\n plate: options.carNumber,\n show_fields: 'cost,navi,polyline',\n }\n );\n\n return normalizeDrivingRouteResult(options, result);\n}\n\nfunction normalizeTransitRouteResult(\n options: TransitRouteOptions,\n result: any\n): DriveRouteResult {\n // 导航包内部仍保持独立实现;\n // 这里只是在“公交无法由导航 SDK 直算”时,把 Web API 结果映射成现有 RouteResult 形状。\n const routes = (result?.route?.transits ?? []).map((transit: any, index: number) => {\n const polyline = (transit?.segments ?? []).flatMap((segment: any) => [\n ...(segment.walking?.steps?.flatMap((step: any) => parsePolyline(step.polyline)) ?? []),\n ...(segment.bus?.buslines?.flatMap((line: any) => parsePolyline(line.polyline)) ?? []),\n ...(segment.railway?.buslines?.flatMap((line: any) => parsePolyline(line.polyline)) ?? []),\n ]);\n\n return {\n id: index,\n start: options.from,\n end: options.to,\n distance: Number(transit?.distance ?? 0),\n duration: Number(transit?.cost?.duration ?? 0),\n segments: [],\n polyline,\n tollDistance: 0,\n tollCost: Number(transit?.cost?.transit_fee ?? 0),\n strategy: options.strategy,\n };\n });\n\n return {\n count: routes.length,\n mainPathIndex: 0,\n routes,\n };\n}\n\nexport async function calculateTransitRouteWithWebApi(\n options: TransitRouteOptions\n): Promise<DriveRouteResult> {\n // 公交换乘在当前 SDK 能力下统一回退到 Web API,再映射成同一份路线结构。\n // 运行时按需加载,避免把 navigation 包和 web-api 包在构建期强绑定。\n const { GaodeWebAPI, TransitStrategy } = await loadWebApiFallback('公交路径规划');\n const api = new GaodeWebAPI();\n const result = await api.route.transit(\n `${options.from.longitude},${options.from.latitude}`,\n `${options.to.longitude},${options.to.latitude}`,\n options.city1,\n options.city2,\n {\n strategy: options.strategy ?? TransitStrategy.RECOMMENDED,\n AlternativeRoute: options.alternativeRoute,\n show_fields: 'cost,polyline',\n }\n );\n\n return normalizeTransitRouteResult(options, result);\n}\n"]}
1
+ {"version":3,"file":"web-api-fallback.js","sourceRoot":"","sources":["../src/web-api-fallback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,KAAK,UAAU,kBAAkB,CAAC,OAA4B;IAC5D,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;QACjD,IAAI,OAAO,MAAM,EAAE,WAAW,KAAK,UAAU,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,GAAG,OAAO,2EAA2E,CACtF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB,CAAC,QAA6C;IAC3E,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,UAAU,GAAG,QAAQ;SACxB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACf,OAAO;SACJ,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,QAAQ,EAAE,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AC;IAC9B,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,OAAO,CACpC,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EACpD,GAAG,OAAO,CAAC,EAAE,CAAC,SAAS,IAAI,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,EAChD,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,KAAK,EACb;QACE,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAC,WAAW;QACzD,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,WAAW,EAAE,eAAe;KAC7B,CACF,CAAC;IAEF,OAAO,2BAA2B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import { DriveStrategy } from './types';\nimport type { DriveRouteOptions, DriveRouteResult, RouteResult, TransitRouteOptions } from './types';\nimport { parsePolyline } from './route-geometry';\n\nasync function loadWebApiFallback(feature: '公交路径规划' | '规避路线预览') {\n try {\n const webApi = require('expo-gaode-map-web-api');\n if (typeof webApi?.GaodeWebAPI !== 'function') {\n throw new Error('expo-gaode-map-web-api 未导出 GaodeWebAPI');\n }\n return webApi;\n } catch {\n throw new Error(\n `${feature}依赖 expo-gaode-map-web-api。请安装该包,并在 ExpoGaodeMapModule.initSDK 中提供 webKey。`\n );\n }\n}\n\nfunction normalizeAvoidPolygons(polygons?: DriveRouteOptions['avoidPolygons']): string | undefined {\n if (!polygons?.length) {\n return undefined;\n }\n\n const normalized = polygons\n .map((polygon) =>\n polygon\n .map((point) => `${point.longitude},${point.latitude}`)\n .join(';')\n )\n .filter(Boolean)\n .join('|');\n\n return normalized || undefined;\n}\n\nfunction normalizeDrivingStrategy(\n strategy?: DriveStrategy\n): number | undefined {\n // 导航 SDK 与 Web API 的策略枚举不完全一致。\n // 这里做“尽量等价”的映射,主要用于带规避参数时的路线预览。\n switch (strategy) {\n case DriveStrategy.FASTEST:\n return 38;\n case DriveStrategy.FEE_FIRST:\n return 1;\n case DriveStrategy.SHORTEST:\n return 2;\n case DriveStrategy.NO_EXPRESSWAYS:\n return 37;\n case DriveStrategy.AVOID_CONGESTION:\n return 33;\n case DriveStrategy.NO_HIGHWAY:\n return 35;\n case DriveStrategy.NO_HIGHWAY_AVOID_CONGESTION:\n return 40;\n case DriveStrategy.AVOID_COST_CONGESTION:\n case DriveStrategy.AVOID_CONGESTION_COST:\n return 41;\n case DriveStrategy.NO_HIGHWAY_AVOID_COST_CONGESTION:\n return 43;\n default:\n return undefined;\n }\n}\n\nfunction normalizeDrivingRouteResult(\n options: DriveRouteOptions,\n result: any\n): DriveRouteResult {\n // 把 Web API 的原始字段翻译成导航包已经对外稳定的 RouteResult 结构。\n // 这样上层代码不需要知道 Web API 的字段名,也不用为 fallback 单独写分支。\n const paths = result?.route?.paths ?? [];\n const routes = paths.map((path: any, index: number) => {\n const segments = (path?.steps ?? []).map((step: any) => ({\n instruction: step?.instruction ?? '',\n orientation: step?.orientation,\n road: step?.road_name,\n distance: Number(step?.step_distance ?? 0),\n duration: Number(step?.cost?.duration ?? 0),\n polyline: parsePolyline(step?.polyline),\n assistantAction: step?.assistant_action,\n tollDistance: step?.cost?.toll_distance ? Number(step.cost.toll_distance) : undefined,\n tollCost: step?.cost?.tolls ? Number(step.cost.tolls) : undefined,\n }));\n\n const restrictionCode = path?.restriction != null ? Number(path.restriction) : undefined;\n\n return {\n id: index,\n start: options.from,\n end: options.to,\n distance: Number(path?.distance ?? 0),\n duration: Number(path?.cost?.duration ?? path?.duration ?? 0),\n segments,\n polyline: segments.flatMap((segment: { polyline: any[] }) => segment.polyline),\n tollDistance: path?.cost?.toll_distance ? Number(path.cost.toll_distance) : undefined,\n tollCost: path?.cost?.tolls ? Number(path.cost.tolls) : undefined,\n trafficLightCount: path?.cost?.traffic_lights ? Number(path.cost.traffic_lights) : undefined,\n restrictionCode,\n restrictionInfo:\n restrictionCode === 0\n ? '限行已规避或未限行'\n : restrictionCode === 1\n ? '限行无法规避'\n : undefined,\n strategy: options.strategy,\n };\n });\n\n return {\n count: Number(result?.count ?? routes.length),\n mainPathIndex: 0,\n routeIds: routes.map((route: RouteResult) => route.id),\n routes,\n taxiCost: result?.route?.taxi_cost ? Number(result.route.taxi_cost) : undefined,\n };\n}\n\nexport function shouldUseAvoidPreviewFallback(options: DriveRouteOptions): boolean {\n // 只有出现“规避道路 / 规避区域”时才需要走 Web API 预览。\n // 普通驾车算路仍然优先走原生能力。\n return Boolean(options.avoidRoad?.trim() || options.avoidPolygons?.length);\n}\n\nexport async function calculateDriveRouteWithAvoidPreview(\n options: DriveRouteOptions\n): Promise<DriveRouteResult> {\n // Web API 只负责“预览规避后的路线”,不是替代原生导航 SDK。\n // 失败时让调用方回退到原生实现,避免把可用路径规划直接变成报错。\n const { GaodeWebAPI } = await loadWebApiFallback('规避路线预览');\n const api = new GaodeWebAPI();\n const result = await api.route.driving(\n `${options.from.longitude},${options.from.latitude}`,\n `${options.to.longitude},${options.to.latitude}`,\n {\n strategy: normalizeDrivingStrategy(options.strategy),\n waypoints: options.waypoints?.map(\n (point) => `${point.longitude},${point.latitude}`\n ),\n avoidpolygons: normalizeAvoidPolygons(options.avoidPolygons),\n avoidroad: options.avoidRoad?.trim() || undefined,\n plate: options.carNumber,\n show_fields: 'cost,navi,polyline',\n }\n );\n\n return normalizeDrivingRouteResult(options, result);\n}\n\nfunction normalizeTransitRouteResult(\n options: TransitRouteOptions,\n result: any\n): DriveRouteResult {\n // 导航包内部仍保持独立实现;\n // 这里只是在“公交无法由导航 SDK 直算”时,把 Web API 结果映射成现有 RouteResult 形状。\n const routes = (result?.route?.transits ?? []).map((transit: any, index: number) => {\n const polyline = (transit?.segments ?? []).flatMap((segment: any) => [\n ...(segment.walking?.steps?.flatMap((step: any) => parsePolyline(step.polyline)) ?? []),\n ...(segment.bus?.buslines?.flatMap((line: any) => parsePolyline(line.polyline)) ?? []),\n ...(segment.railway?.buslines?.flatMap((line: any) => parsePolyline(line.polyline)) ?? []),\n ]);\n\n return {\n id: index,\n start: options.from,\n end: options.to,\n distance: Number(transit?.distance ?? 0),\n duration: Number(transit?.cost?.duration ?? 0),\n segments: [],\n polyline,\n tollDistance: 0,\n tollCost: Number(transit?.cost?.transit_fee ?? 0),\n strategy: options.strategy,\n };\n });\n\n return {\n count: routes.length,\n mainPathIndex: 0,\n routes,\n };\n}\n\nexport async function calculateTransitRouteWithWebApi(\n options: TransitRouteOptions\n): Promise<DriveRouteResult> {\n // 公交换乘在当前 SDK 能力下统一回退到 Web API,再映射成同一份路线结构。\n // 运行时按需加载,避免把 navigation 包和 web-api 包在构建期强绑定。\n const { GaodeWebAPI, TransitStrategy } = await loadWebApiFallback('公交路径规划');\n const api = new GaodeWebAPI();\n const result = await api.route.transit(\n `${options.from.longitude},${options.from.latitude}`,\n `${options.to.longitude},${options.to.latitude}`,\n options.city1,\n options.city2,\n {\n strategy: options.strategy ?? TransitStrategy.RECOMMENDED,\n AlternativeRoute: options.alternativeRoute,\n show_fields: 'cost,polyline',\n }\n );\n\n return normalizeTransitRouteResult(options, result);\n}\n"]}
@@ -96,6 +96,8 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
96
96
  private var uiManager: UIManager!
97
97
  /// 地图是否已加载完成
98
98
  private var isMapLoaded = false
99
+ /// 定位 annotation 首次出现后是否已补应用定位样式
100
+ private var hasAppliedUserLocationStyleAfterLocationUpdate = false
99
101
  /// 初始相机是否已应用(仅应用一次,避免与运行时相机控制冲突)
100
102
  private var hasAppliedInitialCameraPosition = false
101
103
  /// 是否正在处理 annotation 选择事件
@@ -481,6 +483,7 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
481
483
  uiManager.setRotateEnabled(isRotateEnabled)
482
484
  uiManager.setTiltEnabled(isTiltEnabled)
483
485
  uiManager.setShowsUserLocation(showsUserLocation, followUser: followUserLocation)
486
+ applyUserLocationStyle()
484
487
  mapView.distanceFilter = distanceFilter
485
488
  mapView.headingFilter = headingFilter
486
489
  }
@@ -511,6 +514,7 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
511
514
  uiManager.setRotateEnabled(isRotateEnabled)
512
515
  uiManager.setTiltEnabled(isTiltEnabled)
513
516
  uiManager.setShowsUserLocation(showsUserLocation, followUser: followUserLocation)
517
+ applyUserLocationStyle()
514
518
  uiManager.setShowsTraffic(showsTraffic)
515
519
  uiManager.setShowsBuildings(showsBuildings)
516
520
  uiManager.setShowsIndoorMap(showsIndoorMap)
@@ -683,6 +687,9 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
683
687
  func setFollowUserLocation(_ follow: Bool) {
684
688
  followUserLocation = follow
685
689
  uiManager?.setShowsUserLocation(showsUserLocation, followUser: follow)
690
+ if showsUserLocation {
691
+ applyUserLocationStyle()
692
+ }
686
693
  }
687
694
 
688
695
  func setShowsUserLocation(_ show: Bool) {
@@ -695,6 +702,7 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
695
702
 
696
703
  func setUserLocationRepresentation(_ config: [String: Any]) {
697
704
  userLocationRepresentation = config
705
+ hasAppliedUserLocationStyleAfterLocationUpdate = false
698
706
  if showsUserLocation {
699
707
  uiManager?.setUserLocationRepresentation(config)
700
708
  }
@@ -704,7 +712,7 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
704
712
  * 应用用户位置样式
705
713
  */
706
714
  private func applyUserLocationStyle() {
707
- guard let config = userLocationRepresentation else { return }
715
+ guard showsUserLocation, let config = userLocationRepresentation else { return }
708
716
  uiManager?.setUserLocationRepresentation(config)
709
717
  }
710
718
 
@@ -974,6 +982,7 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
974
982
  super.addSubview(resolvedMapView)
975
983
  isMapLoaded = false
976
984
  hasAppliedInitialCameraPosition = false
985
+ hasAppliedUserLocationStyleAfterLocationUpdate = false
977
986
 
978
987
  cameraManager = CameraManager(mapView: resolvedMapView)
979
988
  uiManager = UIManager(mapView: resolvedMapView)
@@ -1042,9 +1051,37 @@ extension ExpoGaodeMapView {
1042
1051
  if let styleData = customMapStyleData {
1043
1052
  uiManager.setCustomMapStyle(styleData)
1044
1053
  }
1054
+
1055
+ applyUserLocationStyle()
1045
1056
 
1046
1057
  onLoad(["loaded": true])
1047
1058
  }
1059
+
1060
+ /**
1061
+ * 定位更新回调
1062
+ */
1063
+ public func mapView(_ mapView: MAMapView, didUpdate userLocation: MAUserLocation, updatingLocation: Bool) {
1064
+ guard updatingLocation, let location = userLocation.location else { return }
1065
+
1066
+ if !hasAppliedUserLocationStyleAfterLocationUpdate {
1067
+ applyUserLocationStyle()
1068
+ hasAppliedUserLocationStyleAfterLocationUpdate = true
1069
+ }
1070
+
1071
+ let latitude = location.coordinate.latitude
1072
+ let longitude = location.coordinate.longitude
1073
+ guard latitude >= -90 && latitude <= 90,
1074
+ longitude >= -180 && longitude <= 180 else {
1075
+ return
1076
+ }
1077
+
1078
+ onLocation([
1079
+ "latitude": latitude,
1080
+ "longitude": longitude,
1081
+ "accuracy": location.horizontalAccuracy,
1082
+ "timestamp": Date().timeIntervalSince1970 * 1000
1083
+ ])
1084
+ }
1048
1085
 
1049
1086
  /**
1050
1087
  * 地图区域即将改变时触发 - 应用节流优化
@@ -1367,13 +1404,118 @@ extension ExpoGaodeMapView {
1367
1404
  handleGaodePoiTouch(pois)
1368
1405
  }
1369
1406
 
1407
+ private func getUserLocationAnnotationView(for mapView: MAMapView, annotation: MAAnnotation) -> MAAnnotationView? {
1408
+ guard let config = userLocationRepresentation,
1409
+ let imagePath = config["image"] as? String,
1410
+ !imagePath.isEmpty else {
1411
+ return nil
1412
+ }
1413
+
1414
+ let reuseId = "ExpoGaodeMapUserLocationStyleReuseIdentifier"
1415
+ let annotationView: MAAnnotationView
1416
+ if let reusableView = mapView.dequeueReusableAnnotationView(withIdentifier: reuseId) {
1417
+ annotationView = reusableView
1418
+ } else {
1419
+ annotationView = MAAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
1420
+ }
1421
+ annotationView.annotation = annotation
1422
+ annotationView.canShowCallout = false
1423
+
1424
+ let imageWidth = config["imageWidth"] as? Double
1425
+ let imageHeight = config["imageHeight"] as? Double
1426
+ let cacheKey = userLocationImageCacheKey(imagePath: imagePath, imageWidth: imageWidth, imageHeight: imageHeight)
1427
+ annotationView.accessibilityIdentifier = cacheKey
1428
+
1429
+ if let cached = IconBitmapCache.shared.image(forKey: cacheKey) {
1430
+ annotationView.image = cached
1431
+ return annotationView
1432
+ }
1433
+
1434
+ annotationView.image = nil
1435
+ loadUserLocationImage(imagePath: imagePath, imageWidth: imageWidth, imageHeight: imageHeight, cacheKey: cacheKey) { [weak annotationView] image in
1436
+ guard let annotationView = annotationView,
1437
+ annotationView.accessibilityIdentifier == cacheKey else {
1438
+ return
1439
+ }
1440
+ annotationView.image = image
1441
+ }
1442
+
1443
+ return annotationView
1444
+ }
1445
+
1446
+ private func userLocationImageCacheKey(imagePath: String, imageWidth: Double?, imageHeight: Double?) -> String {
1447
+ let widthPart = imageWidth.map { String(Int($0.rounded())) } ?? "auto"
1448
+ let heightPart = imageHeight.map { String(Int($0.rounded())) } ?? "auto"
1449
+ return "userLocation|\(imagePath)|\(widthPart)x\(heightPart)"
1450
+ }
1451
+
1452
+ private func loadUserLocationImage(
1453
+ imagePath: String,
1454
+ imageWidth: Double?,
1455
+ imageHeight: Double?,
1456
+ cacheKey: String,
1457
+ completion: @escaping (UIImage?) -> Void
1458
+ ) {
1459
+ let finish: (UIImage?) -> Void = { image in
1460
+ if let image = image {
1461
+ IconBitmapCache.shared.setImage(image, forKey: cacheKey)
1462
+ }
1463
+ DispatchQueue.main.async {
1464
+ completion(image)
1465
+ }
1466
+ }
1467
+
1468
+ if imagePath.hasPrefix("http://") || imagePath.hasPrefix("https://") {
1469
+ DispatchQueue.global(qos: .userInitiated).async { [weak self] in
1470
+ guard let self = self,
1471
+ let url = URL(string: imagePath),
1472
+ let data = try? Data(contentsOf: url),
1473
+ let image = UIImage(data: data) else {
1474
+ finish(nil)
1475
+ return
1476
+ }
1477
+ finish(self.resizeUserLocationImage(image, imageWidth: imageWidth, imageHeight: imageHeight))
1478
+ }
1479
+ return
1480
+ }
1481
+
1482
+ let image: UIImage?
1483
+ if imagePath.hasPrefix("file://") {
1484
+ let path = String(imagePath.dropFirst(7))
1485
+ image = UIImage(contentsOfFile: path)
1486
+ } else {
1487
+ image = UIImage(named: imagePath)
1488
+ }
1489
+
1490
+ guard let image = image else {
1491
+ finish(nil)
1492
+ return
1493
+ }
1494
+ finish(resizeUserLocationImage(image, imageWidth: imageWidth, imageHeight: imageHeight))
1495
+ }
1496
+
1497
+ private func resizeUserLocationImage(_ image: UIImage, imageWidth: Double?, imageHeight: Double?) -> UIImage {
1498
+ guard let imageWidth = imageWidth,
1499
+ let imageHeight = imageHeight,
1500
+ imageWidth > 0,
1501
+ imageHeight > 0 else {
1502
+ return image
1503
+ }
1504
+
1505
+ let targetSize = CGSize(width: imageWidth, height: imageHeight)
1506
+ let renderer = UIGraphicsImageRenderer(size: targetSize)
1507
+ return renderer.image { _ in
1508
+ image.draw(in: CGRect(origin: .zero, size: targetSize))
1509
+ }
1510
+ }
1511
+
1370
1512
  /**
1371
1513
  * 创建标注视图
1372
- * 定位蓝点返回 nil 使用系统默认样式
1514
+ * 定位蓝点默认返回 nil 使用系统样式;传入 image 时按官方建议自定义定位 annotationView。
1373
1515
  */
1374
1516
  public func mapView(_ mapView: MAMapView, viewFor annotation: MAAnnotation) -> MAAnnotationView? {
1375
1517
  if annotation.isKind(of: MAUserLocation.self) {
1376
- return nil
1518
+ return getUserLocationAnnotationView(for: mapView, annotation: annotation)
1377
1519
  }
1378
1520
 
1379
1521
  // 🔑 支持 MAAnimatedAnnotation(平滑移动)
@@ -1,4 +1,5 @@
1
1
  #include "ClusterEngine.hpp"
2
+ #include "GeometryEngine.hpp"
2
3
  #include "QuadTree.hpp"
3
4
  #include <cmath>
4
5
  #include <algorithm>
@@ -11,19 +12,8 @@ static inline double cluster_toRadians(double degrees) {
11
12
  return degrees * 0.017453292519943295;
12
13
  }
13
14
 
14
- static double haversineMeters(const ClusterPoint& a, const ClusterPoint& b) {
15
- const double lat1 = cluster_toRadians(a.lat);
16
- const double lat2 = cluster_toRadians(b.lat);
17
- const double dLat = lat2 - lat1;
18
- const double dLon = cluster_toRadians(b.lon - a.lon);
19
-
20
- const double sinHalfLat = std::sin(dLat * 0.5);
21
- const double sinHalfLon = std::sin(dLon * 0.5);
22
-
23
- const double h = sinHalfLat * sinHalfLat + std::cos(lat1) * std::cos(lat2) * sinHalfLon * sinHalfLon;
24
- const double c = 2.0 * std::atan2(std::sqrt(h), std::sqrt(1.0 - h));
25
-
26
- return 6371000.0 * c;
15
+ static double clusterDistanceMeters(const ClusterPoint& a, const ClusterPoint& b) {
16
+ return calculateDistance(a.lat, a.lon, b.lat, b.lon);
27
17
  }
28
18
 
29
19
  std::vector<ClusterOutput> clusterPoints(const std::vector<ClusterPoint>& points, double radiusMeters) {
@@ -95,7 +85,7 @@ std::vector<ClusterOutput> clusterPoints(const std::vector<ClusterPoint>& points
95
85
  if (globalVisited[neighbor.index]) continue;
96
86
 
97
87
  // Precise check
98
- if (haversineMeters(p, neighbor) <= radiusMeters) {
88
+ if (clusterDistanceMeters(p, neighbor) <= radiusMeters) {
99
89
  cluster.indices.push_back(neighbor.index);
100
90
  globalVisited[neighbor.index] = true;
101
91
  }
@@ -1,20 +1,9 @@
1
1
  #pragma once
2
2
 
3
- #include <vector>
3
+ #include "ClusterTypes.hpp"
4
4
 
5
5
  namespace gaodemap {
6
6
 
7
- struct ClusterPoint {
8
- double lat;
9
- double lon;
10
- int index;
11
- };
12
-
13
- struct ClusterOutput {
14
- int centerIndex;
15
- std::vector<int> indices;
16
- };
17
-
18
7
  std::vector<ClusterOutput> clusterPoints(const std::vector<ClusterPoint>& points, double radiusMeters);
19
8
 
20
9
  }
@@ -0,0 +1,18 @@
1
+ #pragma once
2
+
3
+ #include <vector>
4
+
5
+ namespace gaodemap {
6
+
7
+ struct ClusterPoint {
8
+ double lat;
9
+ double lon;
10
+ int index;
11
+ };
12
+
13
+ struct ClusterOutput {
14
+ int centerIndex;
15
+ std::vector<int> indices;
16
+ };
17
+
18
+ }
@@ -1,5 +1,6 @@
1
1
  #include "ColorParser.hpp"
2
2
  #include <algorithm>
3
+ #include <cctype>
3
4
  #include <sstream>
4
5
  #include <vector>
5
6
  #include <map>
@@ -109,13 +110,29 @@ static const std::map<std::string, uint32_t> NAMED_COLORS = {
109
110
  {"transparent", 0x00000000}
110
111
  };
111
112
 
113
+ static bool isSpace(unsigned char ch) {
114
+ return std::isspace(ch) != 0;
115
+ }
116
+
117
+ static char toLower(unsigned char ch) {
118
+ return static_cast<char>(std::tolower(ch));
119
+ }
120
+
121
+ static bool isHexDigit(unsigned char ch) {
122
+ return std::isxdigit(ch) != 0;
123
+ }
124
+
112
125
  uint32_t parseColor(const std::string& colorString) {
113
126
  std::string str = colorString;
114
127
  // Remove whitespace
115
- str.erase(std::remove_if(str.begin(), str.end(), ::isspace), str.end());
128
+ str.erase(std::remove_if(str.begin(), str.end(), [](unsigned char ch) {
129
+ return isSpace(ch);
130
+ }), str.end());
116
131
  // Lowercase for named colors check
117
132
  std::string lowerStr = str;
118
- std::transform(lowerStr.begin(), lowerStr.end(), lowerStr.begin(), ::tolower);
133
+ std::transform(lowerStr.begin(), lowerStr.end(), lowerStr.begin(), [](unsigned char ch) {
134
+ return toLower(ch);
135
+ });
119
136
 
120
137
  if (NAMED_COLORS.count(lowerStr)) {
121
138
  return NAMED_COLORS.at(lowerStr);
@@ -125,7 +142,9 @@ uint32_t parseColor(const std::string& colorString) {
125
142
  return parseRgba(str); // pass original str with potential spaces if needed, but we removed them
126
143
  }
127
144
 
128
- if (lowerStr.find("#") == 0 || std::all_of(lowerStr.begin(), lowerStr.end(), ::isxdigit)) {
145
+ if (lowerStr.find("#") == 0 || std::all_of(lowerStr.begin(), lowerStr.end(), [](unsigned char ch) {
146
+ return isHexDigit(ch);
147
+ })) {
129
148
  return parseHex(str);
130
149
  }
131
150
 
@@ -44,7 +44,7 @@ static inline double mercatorY01(double lat) {
44
44
  return y;
45
45
  }
46
46
 
47
- static double wrappedSpan01(std::vector<double> xs) {
47
+ static double wrappedSpan01(std::vector<double>& xs) {
48
48
  if (xs.size() <= 1) {
49
49
  return 0.0;
50
50
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  #include <vector>
4
4
  #include <memory>
5
- #include "ClusterEngine.hpp"
5
+ #include "ClusterTypes.hpp"
6
6
 
7
7
  namespace gaodemap {
8
8
 
@@ -172,6 +172,9 @@ class UIManager: NSObject, MAMapViewDelegate {
172
172
  // 是否显示方向指示
173
173
  if let showsHeadingIndicator = config["showsHeadingIndicator"] as? Bool {
174
174
  representation.showsHeadingIndicator = showsHeadingIndicator
175
+ if showsHeadingIndicator {
176
+ mapView.userTrackingMode = .followWithHeading
177
+ }
175
178
  }
176
179
 
177
180
  // 精度圈填充颜色
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "expo-gaode-map-navigation",
3
- "version": "2.0.17",
4
- "description": "React Native AMap (Gaode Map) navigation module for Expo: route planning and turn-by-turn navigation, includes full map features.",
3
+ "version": "2.0.19",
4
+ "description": "Expo Modules AMap (Gaode Map) navigation for Expo/React Native: Config Plugin, route planning, turn-by-turn navigation, map features, and react-native-amap3d migration guidance.",
5
5
  "author": "TomWq <582752848@qq.com> (https://github.com/TomWq)",
6
6
  "repository": {
7
7
  "type": "git",
@@ -14,7 +14,7 @@
14
14
  "build": "expo-module build && yarn build:plugin",
15
15
  "build:plugin": "tsc --project plugin/tsconfig.json",
16
16
  "clean": "expo-module clean",
17
- "lint": "expo-module lint",
17
+ "lint": "eslint \"src/**/*.{ts,tsx}\"",
18
18
  "test": "npx jest --no-watchman --config jest.config.js --runInBand",
19
19
  "prepare": "expo-module prepare && yarn build:plugin",
20
20
  "postinstall": "node scripts/check-expo-modules.js",
@@ -25,11 +25,14 @@
25
25
  },
26
26
  "devDependencies": {
27
27
  "@expo/vector-icons": "^15.0.3",
28
- "@types/react": "~19.1.0",
29
- "expo": "^55.0.8",
30
- "expo-module-scripts": "^55.0.2",
31
- "react-native": "0.83.2",
32
- "typescript": "^5.9.3"
28
+ "@types/node": "^22.18.0",
29
+ "@types/react": "~19.2.10",
30
+ "eslint": "^9.25.1",
31
+ "expo": "^57.0.1",
32
+ "expo-font": "~57.0.0",
33
+ "expo-module-scripts": "^56.0.3",
34
+ "react-native": "0.86.0",
35
+ "typescript": "^6.0.3"
33
36
  },
34
37
  "peerDependencies": {
35
38
  "@expo/vector-icons": "*",
@@ -65,8 +68,13 @@
65
68
  "expo-gaode-map-navigation",
66
69
  "expo-amap",
67
70
  "react-native-amap",
71
+ "react-native-amap3d",
72
+ "react-native-amap3d-alternative",
68
73
  "react-native-gaode-map",
69
74
  "rn-amap-navigation",
75
+ "expo-gaode",
76
+ "eas-build",
77
+ "fabric",
70
78
  "amap",
71
79
  "gaode-map",
72
80
  "navigation",
@@ -155,12 +155,13 @@ const withGaodeMapAndroidManifest = (config, props) => {
155
155
  if (!mainApplication['activity']) {
156
156
  mainApplication['activity'] = [];
157
157
  }
158
+ const activities = mainApplication['activity'];
158
159
  const naviActivityName = 'com.amap.api.navi.AmapRouteActivity';
159
160
  const naviConfigChanges = 'orientation|keyboardHidden|screenSize|navigation';
160
161
  const naviTheme = '@android:style/Theme.NoTitleBar';
161
- const activityIndex = mainApplication['activity'].findIndex((item) => item.$?.['android:name'] === naviActivityName);
162
+ const activityIndex = activities.findIndex((item) => item.$?.['android:name'] === naviActivityName);
162
163
  if (activityIndex === -1) {
163
- mainApplication['activity'].push({
164
+ activities.push({
164
165
  $: {
165
166
  'android:name': naviActivityName,
166
167
  'android:theme': naviTheme,
@@ -169,13 +170,15 @@ const withGaodeMapAndroidManifest = (config, props) => {
169
170
  });
170
171
  }
171
172
  else {
172
- const existing = mainApplication['activity'][activityIndex];
173
- existing.$ = {
174
- ...(existing.$ || {}),
175
- 'android:name': naviActivityName,
176
- 'android:theme': existing.$?.['android:theme'] || naviTheme,
177
- 'android:configChanges': existing.$?.['android:configChanges'] || naviConfigChanges,
178
- };
173
+ const existing = activities[activityIndex];
174
+ if (existing) {
175
+ existing.$ = {
176
+ ...(existing.$ || {}),
177
+ 'android:name': naviActivityName,
178
+ 'android:theme': existing.$?.['android:theme'] || naviTheme,
179
+ 'android:configChanges': existing.$?.['android:configChanges'] || naviConfigChanges,
180
+ };
181
+ }
179
182
  }
180
183
  }
181
184
  // 添加 API Key 到 application 标签
@@ -183,10 +186,11 @@ const withGaodeMapAndroidManifest = (config, props) => {
183
186
  if (!mainApplication['meta-data']) {
184
187
  mainApplication['meta-data'] = [];
185
188
  }
189
+ const metaData = mainApplication['meta-data'];
186
190
  // 检查是否已存在
187
- const hasApiKey = mainApplication['meta-data'].some((item) => item.$?.['android:name'] === 'com.amap.api.v2.apikey');
191
+ const hasApiKey = metaData.some((item) => item.$?.['android:name'] === 'com.amap.api.v2.apikey');
188
192
  if (!hasApiKey) {
189
- mainApplication['meta-data'].push({
193
+ metaData.push({
190
194
  $: {
191
195
  'android:name': 'com.amap.api.v2.apikey',
192
196
  'android:value': props.androidKey,
@@ -195,9 +199,10 @@ const withGaodeMapAndroidManifest = (config, props) => {
195
199
  }
196
200
  else {
197
201
  // 更新现有的 API Key
198
- const apiKeyIndex = mainApplication['meta-data'].findIndex((item) => item.$?.['android:name'] === 'com.amap.api.v2.apikey');
199
- if (apiKeyIndex !== -1) {
200
- mainApplication['meta-data'][apiKeyIndex].$ = {
202
+ const apiKeyIndex = metaData.findIndex((item) => item.$?.['android:name'] === 'com.amap.api.v2.apikey');
203
+ const apiKeyMetaData = metaData[apiKeyIndex];
204
+ if (apiKeyMetaData) {
205
+ apiKeyMetaData.$ = {
201
206
  'android:name': 'com.amap.api.v2.apikey',
202
207
  'android:value': props.androidKey,
203
208
  };
@@ -1,4 +1,5 @@
1
1
  #include "ClusterEngine.hpp"
2
+ #include "GeometryEngine.hpp"
2
3
  #include "QuadTree.hpp"
3
4
  #include <cmath>
4
5
  #include <algorithm>
@@ -11,19 +12,8 @@ static inline double cluster_toRadians(double degrees) {
11
12
  return degrees * 0.017453292519943295;
12
13
  }
13
14
 
14
- static double haversineMeters(const ClusterPoint& a, const ClusterPoint& b) {
15
- const double lat1 = cluster_toRadians(a.lat);
16
- const double lat2 = cluster_toRadians(b.lat);
17
- const double dLat = lat2 - lat1;
18
- const double dLon = cluster_toRadians(b.lon - a.lon);
19
-
20
- const double sinHalfLat = std::sin(dLat * 0.5);
21
- const double sinHalfLon = std::sin(dLon * 0.5);
22
-
23
- const double h = sinHalfLat * sinHalfLat + std::cos(lat1) * std::cos(lat2) * sinHalfLon * sinHalfLon;
24
- const double c = 2.0 * std::atan2(std::sqrt(h), std::sqrt(1.0 - h));
25
-
26
- return 6371000.0 * c;
15
+ static double clusterDistanceMeters(const ClusterPoint& a, const ClusterPoint& b) {
16
+ return calculateDistance(a.lat, a.lon, b.lat, b.lon);
27
17
  }
28
18
 
29
19
  std::vector<ClusterOutput> clusterPoints(const std::vector<ClusterPoint>& points, double radiusMeters) {
@@ -95,7 +85,7 @@ std::vector<ClusterOutput> clusterPoints(const std::vector<ClusterPoint>& points
95
85
  if (globalVisited[neighbor.index]) continue;
96
86
 
97
87
  // Precise check
98
- if (haversineMeters(p, neighbor) <= radiusMeters) {
88
+ if (clusterDistanceMeters(p, neighbor) <= radiusMeters) {
99
89
  cluster.indices.push_back(neighbor.index);
100
90
  globalVisited[neighbor.index] = true;
101
91
  }
@@ -1,20 +1,9 @@
1
1
  #pragma once
2
2
 
3
- #include <vector>
3
+ #include "ClusterTypes.hpp"
4
4
 
5
5
  namespace gaodemap {
6
6
 
7
- struct ClusterPoint {
8
- double lat;
9
- double lon;
10
- int index;
11
- };
12
-
13
- struct ClusterOutput {
14
- int centerIndex;
15
- std::vector<int> indices;
16
- };
17
-
18
7
  std::vector<ClusterOutput> clusterPoints(const std::vector<ClusterPoint>& points, double radiusMeters);
19
8
 
20
9
  }
@@ -0,0 +1,18 @@
1
+ #pragma once
2
+
3
+ #include <vector>
4
+
5
+ namespace gaodemap {
6
+
7
+ struct ClusterPoint {
8
+ double lat;
9
+ double lon;
10
+ int index;
11
+ };
12
+
13
+ struct ClusterOutput {
14
+ int centerIndex;
15
+ std::vector<int> indices;
16
+ };
17
+
18
+ }