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,171 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { useEffect, useRef, useState } from 'react';
3
+ import { Platform } from 'react-native';
4
+ import MapView from '../ExpoGaodeMapView';
5
+ import { PlatformDetector, DeviceInfo, FoldState } from '../utils/PlatformDetector';
6
+ import { MapViewProps, MapViewRef } from '../types';
7
+ export const FoldableMapView = ({ foldableConfig, ...mapProps }) => {
8
+ const mapRef = useRef(null);
9
+ const [currentFoldState, setCurrentFoldState] = useState(FoldState.UNKNOWN);
10
+ const [deviceInfo, setDeviceInfo] = useState(PlatformDetector.getDeviceInfo());
11
+ const config = {
12
+ autoAdjustZoom: true,
13
+ unfoldedZoomDelta: 1,
14
+ keepCenterOnFold: true,
15
+ onFoldStateChange: () => { },
16
+ debug: false,
17
+ ...foldableConfig,
18
+ };
19
+ useEffect(() => {
20
+ // 仅在 Android 折叠屏设备上启用
21
+ if (Platform.OS !== 'android' || !deviceInfo.isFoldable) {
22
+ if (config.debug) {
23
+ console.log('[FoldableMapView] 非折叠屏设备,跳过适配');
24
+ }
25
+ return;
26
+ }
27
+ if (config.debug) {
28
+ console.log('[FoldableMapView] 初始化折叠屏适配');
29
+ console.log('设备信息:', deviceInfo);
30
+ console.log('初始折叠状态:', currentFoldState);
31
+ }
32
+ // 监听屏幕尺寸变化
33
+ const removeListener = PlatformDetector.addDimensionChangeListener(async (newInfo) => {
34
+ const newFoldState = PlatformDetector.getFoldState();
35
+ if (config.debug) {
36
+ console.log('[FoldableMapView] 屏幕尺寸变化');
37
+ console.log('新设备信息:', newInfo);
38
+ console.log('新折叠状态:', newFoldState);
39
+ }
40
+ // 折叠状态变化时的处理
41
+ if (newFoldState !== currentFoldState && currentFoldState !== FoldState.UNKNOWN) {
42
+ await handleFoldStateChange(currentFoldState, newFoldState, newInfo);
43
+ }
44
+ setCurrentFoldState(newFoldState);
45
+ setDeviceInfo(newInfo);
46
+ // 触发回调
47
+ config.onFoldStateChange(newFoldState, newInfo);
48
+ });
49
+ // 设置初始状态
50
+ const initialState = PlatformDetector.getFoldState();
51
+ setCurrentFoldState(initialState);
52
+ return () => {
53
+ removeListener();
54
+ };
55
+ }, []);
56
+ /**
57
+ * 处理折叠状态变化
58
+ */
59
+ const handleFoldStateChange = async (oldState, newState, newInfo) => {
60
+ if (!mapRef.current) {
61
+ return;
62
+ }
63
+ try {
64
+ // 获取当前地图状态
65
+ const currentCamera = await mapRef.current.getCameraPosition?.();
66
+ if (!currentCamera) {
67
+ if (config.debug) {
68
+ console.warn('[FoldableMapView] 无法获取相机位置');
69
+ }
70
+ return;
71
+ }
72
+ const isUnfolding = newState === FoldState.UNFOLDED && oldState === FoldState.FOLDED;
73
+ const isFolding = newState === FoldState.FOLDED && oldState === FoldState.UNFOLDED;
74
+ if (config.debug) {
75
+ console.log('[FoldableMapView] 折叠状态变化:', {
76
+ oldState,
77
+ newState,
78
+ isUnfolding,
79
+ isFolding,
80
+ currentZoom: currentCamera.zoom,
81
+ });
82
+ }
83
+ // 展开时增加缩放级别,折叠时减少
84
+ if (config.autoAdjustZoom && (isUnfolding || isFolding)) {
85
+ const currentZoom = currentCamera.zoom ?? 15;
86
+ const zoomDelta = isUnfolding ? config.unfoldedZoomDelta : -config.unfoldedZoomDelta;
87
+ const newZoom = Math.max(3, Math.min(20, currentZoom + zoomDelta));
88
+ if (config.debug) {
89
+ console.log('[FoldableMapView] 调整缩放:', {
90
+ oldZoom: currentZoom,
91
+ newZoom,
92
+ delta: zoomDelta,
93
+ });
94
+ }
95
+ // 保持中心点,只调整缩放
96
+ await mapRef.current.moveCamera({
97
+ target: config.keepCenterOnFold ? currentCamera.target : undefined,
98
+ zoom: newZoom,
99
+ }, 300);
100
+ }
101
+ }
102
+ catch (error) {
103
+ if (config.debug) {
104
+ console.error('[FoldableMapView] 处理折叠状态变化失败:');
105
+ }
106
+ }
107
+ };
108
+ return (_jsx(MapView, { ref: mapRef, ...mapProps }));
109
+ };
110
+ /**
111
+ * 折叠屏适配 Hook
112
+ *
113
+ * 用于在现有地图组件中添加折叠屏适配功能
114
+ */
115
+ export function useFoldableMap(mapRef, config) {
116
+ const [foldState, setFoldState] = useState(FoldState.UNKNOWN);
117
+ const [deviceInfo, setDeviceInfo] = useState(PlatformDetector.getDeviceInfo());
118
+ const mergedConfig = {
119
+ autoAdjustZoom: true,
120
+ unfoldedZoomDelta: 1,
121
+ keepCenterOnFold: true,
122
+ onFoldStateChange: () => { },
123
+ debug: false,
124
+ ...config,
125
+ };
126
+ useEffect(() => {
127
+ if (Platform.OS !== 'android' || !deviceInfo.isFoldable) {
128
+ return;
129
+ }
130
+ const removeListener = PlatformDetector.addDimensionChangeListener(async (newInfo) => {
131
+ const newFoldState = PlatformDetector.getFoldState();
132
+ if (newFoldState !== foldState && foldState !== FoldState.UNKNOWN) {
133
+ // 处理折叠状态变化
134
+ if (mapRef.current && mergedConfig.autoAdjustZoom) {
135
+ try {
136
+ const currentCamera = await mapRef.current.getCameraPosition();
137
+ if (currentCamera) {
138
+ const currentZoom = currentCamera.zoom ?? 15;
139
+ const isUnfolding = newFoldState === FoldState.UNFOLDED && foldState === FoldState.FOLDED;
140
+ const zoomDelta = isUnfolding ? mergedConfig.unfoldedZoomDelta : -mergedConfig.unfoldedZoomDelta;
141
+ const newZoom = Math.max(3, Math.min(20, currentZoom + zoomDelta));
142
+ await mapRef.current.moveCamera({
143
+ target: mergedConfig.keepCenterOnFold ? currentCamera.target : undefined,
144
+ zoom: newZoom,
145
+ }, 300);
146
+ }
147
+ }
148
+ catch (error) {
149
+ if (mergedConfig.debug) {
150
+ console.error('[useFoldableMap] 调整失败:');
151
+ }
152
+ }
153
+ }
154
+ }
155
+ setFoldState(newFoldState);
156
+ setDeviceInfo(newInfo);
157
+ mergedConfig.onFoldStateChange(newFoldState, newInfo);
158
+ });
159
+ const initialState = PlatformDetector.getFoldState();
160
+ setFoldState(initialState);
161
+ return () => {
162
+ removeListener();
163
+ };
164
+ }, [foldState, deviceInfo.isFoldable]);
165
+ return {
166
+ foldState,
167
+ deviceInfo,
168
+ isFoldable: deviceInfo.isFoldable,
169
+ };
170
+ }
171
+ //# sourceMappingURL=FoldableMapView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FoldableMapView.js","sourceRoot":"","sources":["../../../../src/map/components/FoldableMapView.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AA4BpD,MAAM,CAAC,MAAM,eAAe,GAAmC,CAAC,EAC9D,cAAc,EACd,GA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;AACJ,CAAC","sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { Platform } from 'react-native';\nimport MapView from '../ExpoGaodeMapView';\n\nimport { PlatformDetector, DeviceInfo, FoldState } from '../utils/PlatformDetector';\nimport { MapViewProps, MapViewRef } from '../types';\n\n/**\n * 折叠屏适配配置\n */\nexport interface FoldableConfig {\n /** 折叠时是否自动调整缩放级别 */\n autoAdjustZoom?: boolean;\n /** 展开时的缩放级别增量 */\n unfoldedZoomDelta?: number;\n /** 是否在折叠/展开时保持中心点 */\n keepCenterOnFold?: boolean;\n /** 折叠状态变化回调 */\n onFoldStateChange?: (state: FoldState, deviceInfo: DeviceInfo) => void;\n /** 是否启用调试日志 */\n debug?: boolean;\n}\n\n/**\n * 折叠屏地图视图组件\n * \n * 自动适配折叠屏设备的展开/折叠状态变化\n */\nexport interface FoldableMapViewProps extends MapViewProps {\n /** 折叠屏适配配置 */\n foldableConfig?: FoldableConfig;\n}\n\nexport const FoldableMapView: React.FC<FoldableMapViewProps> = ({\n foldableConfig,\n ...mapProps\n}) => {\n const mapRef = useRef<MapViewRef>(null);\n const [currentFoldState, setCurrentFoldState] = useState<FoldState>(FoldState.UNKNOWN);\n const [deviceInfo, setDeviceInfo] = useState<DeviceInfo>(PlatformDetector.getDeviceInfo());\n\n const config: Required<FoldableConfig> = {\n autoAdjustZoom: true,\n unfoldedZoomDelta: 1,\n keepCenterOnFold: true,\n onFoldStateChange: () => {},\n debug: false,\n ...foldableConfig,\n };\n\n useEffect(() => {\n // 仅在 Android 折叠屏设备上启用\n if (Platform.OS !== 'android' || !deviceInfo.isFoldable) {\n if (config.debug) {\n console.log('[FoldableMapView] 非折叠屏设备,跳过适配');\n }\n return;\n }\n\n if (config.debug) {\n console.log('[FoldableMapView] 初始化折叠屏适配');\n console.log('设备信息:', deviceInfo);\n console.log('初始折叠状态:', currentFoldState);\n }\n\n // 监听屏幕尺寸变化\n const removeListener = PlatformDetector.addDimensionChangeListener(\n async (newInfo: DeviceInfo) => {\n const newFoldState = PlatformDetector.getFoldState();\n \n if (config.debug) {\n console.log('[FoldableMapView] 屏幕尺寸变化');\n console.log('新设备信息:', newInfo);\n console.log('新折叠状态:', newFoldState);\n }\n\n // 折叠状态变化时的处理\n if (newFoldState !== currentFoldState && currentFoldState !== FoldState.UNKNOWN) {\n await handleFoldStateChange(currentFoldState, newFoldState, newInfo);\n }\n\n setCurrentFoldState(newFoldState);\n setDeviceInfo(newInfo);\n \n // 触发回调\n config.onFoldStateChange(newFoldState, newInfo);\n }\n );\n\n // 设置初始状态\n const initialState = PlatformDetector.getFoldState();\n setCurrentFoldState(initialState);\n\n return () => {\n removeListener();\n };\n }, []);\n\n /**\n * 处理折叠状态变化\n */\n const handleFoldStateChange = async (\n oldState: FoldState,\n newState: FoldState,\n newInfo: DeviceInfo\n ) => {\n if (!mapRef.current) {\n return;\n }\n\n try {\n // 获取当前地图状态\n const currentCamera = await mapRef.current.getCameraPosition?.();\n \n if (!currentCamera) {\n if (config.debug) {\n console.warn('[FoldableMapView] 无法获取相机位置');\n }\n return;\n }\n\n const isUnfolding = newState === FoldState.UNFOLDED && oldState === FoldState.FOLDED;\n const isFolding = newState === FoldState.FOLDED && oldState === FoldState.UNFOLDED;\n\n if (config.debug) {\n console.log('[FoldableMapView] 折叠状态变化:', {\n oldState,\n newState,\n isUnfolding,\n isFolding,\n currentZoom: currentCamera.zoom,\n });\n }\n\n // 展开时增加缩放级别,折叠时减少\n if (config.autoAdjustZoom && (isUnfolding || isFolding)) {\n const currentZoom = currentCamera.zoom ?? 15;\n const zoomDelta = isUnfolding ? config.unfoldedZoomDelta : -config.unfoldedZoomDelta;\n const newZoom = Math.max(3, Math.min(20, currentZoom + zoomDelta));\n\n if (config.debug) {\n console.log('[FoldableMapView] 调整缩放:', {\n oldZoom: currentZoom,\n newZoom,\n delta: zoomDelta,\n });\n }\n\n // 保持中心点,只调整缩放\n await mapRef.current.moveCamera({\n target: config.keepCenterOnFold ? currentCamera.target : undefined,\n zoom: newZoom,\n }, 300);\n }\n } catch (error) {\n if (config.debug) {\n console.error('[FoldableMapView] 处理折叠状态变化失败:');\n }\n }\n };\n\n \n\n return (\n <MapView\n ref={mapRef}\n {...mapProps}\n />\n );\n};\n\n/**\n * 折叠屏适配 Hook\n * \n * 用于在现有地图组件中添加折叠屏适配功能\n */\nexport function useFoldableMap(\n mapRef: React.RefObject<MapViewRef>,\n config?: FoldableConfig\n) {\n const [foldState, setFoldState] = useState<FoldState>(FoldState.UNKNOWN);\n const [deviceInfo, setDeviceInfo] = useState<DeviceInfo>(PlatformDetector.getDeviceInfo());\n\n const mergedConfig: Required<FoldableConfig> = {\n autoAdjustZoom: true,\n unfoldedZoomDelta: 1,\n keepCenterOnFold: true,\n onFoldStateChange: () => {},\n debug: false,\n ...config,\n };\n\n useEffect(() => {\n if (Platform.OS !== 'android' || !deviceInfo.isFoldable) {\n return;\n }\n\n const removeListener = PlatformDetector.addDimensionChangeListener(\n async (newInfo: DeviceInfo) => {\n const newFoldState = PlatformDetector.getFoldState();\n \n if (newFoldState !== foldState && foldState !== FoldState.UNKNOWN) {\n // 处理折叠状态变化\n if (mapRef.current && mergedConfig.autoAdjustZoom) {\n try {\n const currentCamera = await mapRef.current.getCameraPosition();\n if (currentCamera) {\n const currentZoom = currentCamera.zoom ?? 15;\n const isUnfolding = newFoldState === FoldState.UNFOLDED && foldState === FoldState.FOLDED;\n const zoomDelta = isUnfolding ? mergedConfig.unfoldedZoomDelta : -mergedConfig.unfoldedZoomDelta;\n const newZoom = Math.max(3, Math.min(20, currentZoom + zoomDelta));\n\n await mapRef.current.moveCamera({\n target: mergedConfig.keepCenterOnFold ? currentCamera.target : undefined,\n zoom: newZoom,\n }, 300);\n }\n } catch (error) {\n if (mergedConfig.debug) {\n console.error('[useFoldableMap] 调整失败:');\n }\n }\n }\n }\n\n setFoldState(newFoldState);\n setDeviceInfo(newInfo);\n mergedConfig.onFoldStateChange(newFoldState, newInfo);\n }\n );\n\n const initialState = PlatformDetector.getFoldState();\n setFoldState(initialState);\n\n return () => {\n removeListener();\n };\n }, [foldState, deviceInfo.isFoldable]);\n\n return {\n foldState,\n deviceInfo,\n isFoldable: deviceInfo.isFoldable,\n };\n}"]}
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import type { MapViewRef } from '../types';
3
+ /**
4
+ * 地图上下文
5
+ * 用于在子组件中访问地图实例的方法
6
+ */
7
+ export declare const MapContext: React.Context<MapViewRef | null>;
8
+ /**
9
+ * Hook: 获取地图实例引用
10
+ * 只能在 MapView 的子组件中使用
11
+ */
12
+ export declare function useMap(): MapViewRef;
13
+ //# sourceMappingURL=MapContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapContext.d.ts","sourceRoot":"","sources":["../../../../src/map/components/MapContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,UAAU,kCAA+C,CAAC;AAEvE;;;GAGG;AACH,wBAAgB,MAAM,IAAI,UAAU,CAMnC"}
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * 地图上下文
4
+ * 用于在子组件中访问地图实例的方法
5
+ */
6
+ export const MapContext = React.createContext(null);
7
+ /**
8
+ * Hook: 获取地图实例引用
9
+ * 只能在 MapView 的子组件中使用
10
+ */
11
+ export function useMap() {
12
+ const context = React.useContext(MapContext);
13
+ if (!context) {
14
+ throw new Error('useMap must be used within a MapView component');
15
+ }
16
+ return context;
17
+ }
18
+ //# sourceMappingURL=MapContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapContext.js","sourceRoot":"","sources":["../../../../src/map/components/MapContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,CAAoB,IAAI,CAAC,CAAC;AAEvE;;;GAGG;AACH,MAAM,UAAU,MAAM;IACpB,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import * as React from 'react';\nimport type { MapViewRef } from '../types';\n\n/**\n * 地图上下文\n * 用于在子组件中访问地图实例的方法\n */\nexport const MapContext = React.createContext<MapViewRef | null>(null);\n\n/**\n * Hook: 获取地图实例引用\n * 只能在 MapView 的子组件中使用\n */\nexport function useMap(): MapViewRef {\n const context = React.useContext(MapContext);\n if (!context) {\n throw new Error('useMap must be used within a MapView component');\n }\n return context;\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ /**
3
+ * MapUI 组件
4
+ * 用于包裹不需要作为地图原生子组件(如 Marker)的普通 React 组件。
5
+ * 被此组件包裹的内容将渲染在地图视图的上方(兄弟节点),而不是内部。
6
+ * 这解决了在地图内部放置普通 View 导致的触摸事件冲突问题。
7
+ *
8
+ * 示例:
9
+ * <MapView>
10
+ * <Marker ... />
11
+ * <MapUI>
12
+ * <View style={{ position: 'absolute', ... }}>
13
+ * <Text>悬浮层</Text>
14
+ * </View>
15
+ * </MapUI>
16
+ * </MapView>
17
+ */
18
+ export declare const MapUI: React.FC<React.PropsWithChildren<{}>>;
19
+ //# sourceMappingURL=MapUI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapUI.d.ts","sourceRoot":"","sources":["../../../../src/map/components/MapUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAEvD,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ /**
4
+ * MapUI 组件
5
+ * 用于包裹不需要作为地图原生子组件(如 Marker)的普通 React 组件。
6
+ * 被此组件包裹的内容将渲染在地图视图的上方(兄弟节点),而不是内部。
7
+ * 这解决了在地图内部放置普通 View 导致的触摸事件冲突问题。
8
+ *
9
+ * 示例:
10
+ * <MapView>
11
+ * <Marker ... />
12
+ * <MapUI>
13
+ * <View style={{ position: 'absolute', ... }}>
14
+ * <Text>悬浮层</Text>
15
+ * </View>
16
+ * </MapUI>
17
+ * </MapView>
18
+ */
19
+ export const MapUI = ({ children }) => {
20
+ return _jsx(_Fragment, { children: children });
21
+ };
22
+ // 静态标志,用于识别
23
+ MapUI.isMapUI = true;
24
+ //# sourceMappingURL=MapUI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapUI.js","sourceRoot":"","sources":["../../../../src/map/components/MapUI.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,KAAK,GAA0C,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC3E,OAAO,4BAAG,QAAQ,GAAI,CAAC;AACzB,CAAC,CAAC;AAEF,YAAY;AACX,KAAyC,CAAC,OAAO,GAAG,IAAI,CAAC","sourcesContent":["import React from 'react';\n\n/**\n * MapUI 组件\n * 用于包裹不需要作为地图原生子组件(如 Marker)的普通 React 组件。\n * 被此组件包裹的内容将渲染在地图视图的上方(兄弟节点),而不是内部。\n * 这解决了在地图内部放置普通 View 导致的触摸事件冲突问题。\n * \n * 示例:\n * <MapView>\n * <Marker ... />\n * <MapUI>\n * <View style={{ position: 'absolute', ... }}>\n * <Text>悬浮层</Text>\n * </View>\n * </MapUI>\n * </MapView>\n */\nexport const MapUI: React.FC<React.PropsWithChildren<{}>> = ({ children }) => {\n return <>{children}</>;\n};\n\n// 静态标志,用于识别\n(MapUI as React.FC & { isMapUI: boolean }).isMapUI = true;\n"]}
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import type { CircleProps } from '../../types';
3
+ /**
4
+ * 高德地图圆形覆盖物组件(声明式)
5
+ *
6
+ *
7
+ * @param props 圆形组件的属性配置
8
+ * @returns 渲染原生圆形组件
9
+ */
10
+ declare function Circle(props: CircleProps): import("react/jsx-runtime").JSX.Element;
11
+ declare const _default: React.MemoExoticComponent<typeof Circle>;
12
+ export default _default;
13
+ //# sourceMappingURL=Circle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Circle.d.ts","sourceRoot":"","sources":["../../../../../src/map/components/overlays/Circle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM/C;;;;;;GAMG;AACH,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,2CAWjC;;AAED,wBAAkC"}
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import { normalizeLatLng } from '../../utils/GeoUtils';
4
+ import { createLazyNativeViewManager } from '../../utils/lazyNativeViewManager';
5
+ const getNativeCircleView = createLazyNativeViewManager('CircleView');
6
+ /**
7
+ * 高德地图圆形覆盖物组件(声明式)
8
+ *
9
+ *
10
+ * @param props 圆形组件的属性配置
11
+ * @returns 渲染原生圆形组件
12
+ */
13
+ function Circle(props) {
14
+ const NativeCircleView = React.useMemo(() => getNativeCircleView(), []);
15
+ const { center, ...restProps } = props;
16
+ const normalizedCenter = normalizeLatLng(center);
17
+ return (_jsx(NativeCircleView, { center: normalizedCenter, ...restProps }));
18
+ }
19
+ export default React.memo(Circle);
20
+ //# sourceMappingURL=Circle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Circle.js","sourceRoot":"","sources":["../../../../../src/map/components/overlays/Circle.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAEhF,MAAM,mBAAmB,GAAG,2BAA2B,CAAc,YAAY,CAAC,CAAC;AAEnF;;;;;;GAMG;AACH,SAAS,MAAM,CAAC,KAAkB;IAChC,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,mBAAmB,EAAE,EAAE,EAAE,CAAC,CAAC;IACxE,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACvC,MAAM,gBAAgB,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAEjD,OAAO,CACL,KAAC,gBAAgB,IACf,MAAM,EAAE,gBAAgB,KACpB,SAAS,GACb,CACH,CAAC;AACJ,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport type { CircleProps } from '../../types';\nimport { normalizeLatLng } from '../../utils/GeoUtils';\nimport { createLazyNativeViewManager } from '../../utils/lazyNativeViewManager';\n\nconst getNativeCircleView = createLazyNativeViewManager<CircleProps>('CircleView');\n\n/**\n * 高德地图圆形覆盖物组件(声明式)\n *\n *\n * @param props 圆形组件的属性配置\n * @returns 渲染原生圆形组件\n */\nfunction Circle(props: CircleProps) {\n const NativeCircleView = React.useMemo(() => getNativeCircleView(), []);\n const { center, ...restProps } = props;\n const normalizedCenter = normalizeLatLng(center);\n \n return (\n <NativeCircleView \n center={normalizedCenter}\n {...restProps} \n />\n );\n}\n\nexport default React.memo(Circle);\n"]}
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import type { ClusterProps } from '../../types';
3
+ /**
4
+ * 高德地图点聚合组件
5
+ *
6
+ * @param props 点聚合组件的属性配置
7
+ * @returns 渲染原生点聚合组件
8
+ */
9
+ declare function Cluster(props: ClusterProps): import("react/jsx-runtime").JSX.Element;
10
+ declare const _default: React.MemoExoticComponent<typeof Cluster>;
11
+ export default _default;
12
+ //# sourceMappingURL=Cluster.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cluster.d.ts","sourceRoot":"","sources":["../../../../../src/map/components/overlays/Cluster.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD;;;;;GAKG;AACH,iBAAS,OAAO,CAAC,KAAK,EAAE,YAAY,2CAGnC;;AAED,wBAAmC"}
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import { createLazyNativeViewManager } from '../../utils/lazyNativeViewManager';
4
+ const getNativeCluster = createLazyNativeViewManager('ClusterView');
5
+ /**
6
+ * 高德地图点聚合组件
7
+ *
8
+ * @param props 点聚合组件的属性配置
9
+ * @returns 渲染原生点聚合组件
10
+ */
11
+ function Cluster(props) {
12
+ const NativeCluster = React.useMemo(() => getNativeCluster(), []);
13
+ return _jsx(NativeCluster, { ...props });
14
+ }
15
+ export default React.memo(Cluster);
16
+ //# sourceMappingURL=Cluster.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cluster.js","sourceRoot":"","sources":["../../../../../src/map/components/overlays/Cluster.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAEhF,MAAM,gBAAgB,GAAG,2BAA2B,CAAe,aAAa,CAAC,CAAC;AAElF;;;;;GAKG;AACH,SAAS,OAAO,CAAC,KAAmB;IAClC,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,gBAAgB,EAAE,EAAE,EAAE,CAAC,CAAC;IAClE,OAAO,KAAC,aAAa,OAAK,KAAK,GAAI,CAAC;AACtC,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport type { ClusterProps } from '../../types';\nimport { createLazyNativeViewManager } from '../../utils/lazyNativeViewManager';\n\nconst getNativeCluster = createLazyNativeViewManager<ClusterProps>('ClusterView');\n\n/**\n * 高德地图点聚合组件\n *\n * @param props 点聚合组件的属性配置\n * @returns 渲染原生点聚合组件\n */\nfunction Cluster(props: ClusterProps) {\n const NativeCluster = React.useMemo(() => getNativeCluster(), []);\n return <NativeCluster {...props} />;\n}\n\nexport default React.memo(Cluster);\n"]}
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import type { HeatMapProps } from '../../types';
3
+ /**
4
+ * 高德地图热力图组件
5
+ *
6
+ * @param props - 热力图配置属性,继承自NativeHeatMap组件的属性
7
+ * @returns 渲染高德地图原生热力图组件
8
+ */
9
+ declare function HeatMap(props: HeatMapProps): import("react/jsx-runtime").JSX.Element;
10
+ declare const _default: React.MemoExoticComponent<typeof HeatMap>;
11
+ export default _default;
12
+ //# sourceMappingURL=HeatMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeatMap.d.ts","sourceRoot":"","sources":["../../../../../src/map/components/overlays/HeatMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAmBhD;;;;;GAKG;AACH,iBAAS,OAAO,CAAC,KAAK,EAAE,YAAY,2CAcnC;;AA+BD,wBAAmC"}
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import { StyleSheet } from 'react-native';
4
+ import { normalizeLatLng } from '../../utils/GeoUtils';
5
+ import { createLazyNativeViewManager } from '../../utils/lazyNativeViewManager';
6
+ const getNativeHeatMap = createLazyNativeViewManager('HeatMapView');
7
+ /**
8
+ * 高德地图热力图组件
9
+ *
10
+ * @param props - 热力图配置属性,继承自NativeHeatMap组件的属性
11
+ * @returns 渲染高德地图原生热力图组件
12
+ */
13
+ function HeatMap(props) {
14
+ const NativeHeatMap = React.useMemo(() => getNativeHeatMap(), []);
15
+ const { data, ...restProps } = props;
16
+ const normalizedData = React.useMemo(() => normalizeHeatMapData(data), [data]);
17
+ return (_jsx(NativeHeatMap, { data: normalizedData, ...restProps, collapsable: false, pointerEvents: "none", style: styles.hidden }));
18
+ }
19
+ const styles = StyleSheet.create({
20
+ hidden: {
21
+ width: 0,
22
+ height: 0,
23
+ backgroundColor: 'transparent',
24
+ },
25
+ });
26
+ function normalizeHeatMapData(data) {
27
+ return data.map((point) => {
28
+ const normalized = normalizeLatLng(point);
29
+ if (Array.isArray(point)) {
30
+ return {
31
+ ...normalized,
32
+ intensity: typeof point[2] === 'number' ? point[2] : undefined,
33
+ };
34
+ }
35
+ const extra = point;
36
+ return {
37
+ ...normalized,
38
+ intensity: typeof extra.intensity === 'number' ? extra.intensity : undefined,
39
+ weight: typeof extra.weight === 'number' ? extra.weight : undefined,
40
+ count: typeof extra.count === 'number' ? extra.count : undefined,
41
+ value: typeof extra.value === 'number' ? extra.value : undefined,
42
+ };
43
+ });
44
+ }
45
+ export default React.memo(HeatMap);
46
+ //# sourceMappingURL=HeatMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeatMap.js","sourceRoot":"","sources":["../../../../../src/map/components/overlays/HeatMap.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAahF,MAAM,gBAAgB,GAAG,2BAA2B,CAA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AC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;YAC5E,MAAM,EAAE,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;YACnE,KAAK,EAAE,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YAChE,KAAK,EAAE,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SACjE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { StyleSheet } from 'react-native';\nimport type { ViewProps } from 'react-native';\nimport type { HeatMapProps } from '../../types';\nimport type { LatLng } from '../../types';\nimport { normalizeLatLng } from '../../utils/GeoUtils';\nimport { createLazyNativeViewManager } from '../../utils/lazyNativeViewManager';\n\ntype NativeHeatMapPoint = LatLng & {\n intensity?: number;\n weight?: number;\n count?: number;\n value?: number;\n};\n\ntype NativeHeatMapProps = Omit<HeatMapProps, 'data'> & ViewProps & {\n data: NativeHeatMapPoint[];\n};\n\nconst getNativeHeatMap = createLazyNativeViewManager<NativeHeatMapProps>('HeatMapView');\n\n\n/**\n * 高德地图热力图组件\n *\n * @param props - 热力图配置属性,继承自NativeHeatMap组件的属性\n * @returns 渲染高德地图原生热力图组件\n */\nfunction HeatMap(props: HeatMapProps) {\n const NativeHeatMap = React.useMemo(() => getNativeHeatMap(), []);\n const { data, ...restProps } = props;\n const normalizedData = React.useMemo(() => normalizeHeatMapData(data), [data]);\n\n return (\n <NativeHeatMap\n data={normalizedData}\n {...restProps}\n collapsable={false}\n pointerEvents=\"none\"\n style={styles.hidden}\n />\n );\n}\n\nconst styles = StyleSheet.create({\n hidden: {\n width: 0,\n height: 0,\n backgroundColor: 'transparent',\n },\n});\n\nfunction normalizeHeatMapData(data: HeatMapProps['data']): NativeHeatMapPoint[] {\n return data.map((point) => {\n const normalized = normalizeLatLng(point);\n if (Array.isArray(point)) {\n return {\n ...normalized,\n intensity: typeof point[2] === 'number' ? point[2] : undefined,\n };\n }\n\n const extra = point as Partial<NativeHeatMapPoint>;\n return {\n ...normalized,\n intensity: typeof extra.intensity === 'number' ? extra.intensity : undefined,\n weight: typeof extra.weight === 'number' ? extra.weight : undefined,\n count: typeof extra.count === 'number' ? extra.count : undefined,\n value: typeof extra.value === 'number' ? extra.value : undefined,\n };\n });\n}\n\nexport default React.memo(HeatMap);\n"]}
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ import type { MarkerProps } from '../../types';
3
+ /**
4
+ * Marker 组件 - 完全声明式 API
5
+ *
6
+ * 支持:
7
+ * - 自定义图标(icon)
8
+ * - 自定义内容(children)- 自动测量尺寸
9
+ * - 大头针样式(pinColor)
10
+ * - 拖拽功能
11
+ * - 所有事件回调
12
+ */
13
+ declare function Marker(props: MarkerProps): import("react/jsx-runtime").JSX.Element;
14
+ declare const _default: React.MemoExoticComponent<typeof Marker>;
15
+ export default _default;
16
+ //# sourceMappingURL=Marker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Marker.d.ts","sourceRoot":"","sources":["../../../../../src/map/components/overlays/Marker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgB/C;;;;;;;;;GASG;AACH,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,2CAiJjC;;AAED,wBAAkC"}
@@ -0,0 +1,125 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import { StyleSheet, View } from 'react-native';
4
+ import ExpoGaodeMapModule from '../../ExpoGaodeMapModule';
5
+ import { normalizeLatLng, normalizeLatLngList } from '../../utils/GeoUtils';
6
+ import { createLazyNativeViewManager } from '../../utils/lazyNativeViewManager';
7
+ const getNativeMarkerView = createLazyNativeViewManager('MarkerView');
8
+ const AUTO_SIZE_FALLBACK = { width: 0, height: 0 };
9
+ /**
10
+ * Marker 组件 - 完全声明式 API
11
+ *
12
+ * 支持:
13
+ * - 自定义图标(icon)
14
+ * - 自定义内容(children)- 自动测量尺寸
15
+ * - 大头针样式(pinColor)
16
+ * - 拖拽功能
17
+ * - 所有事件回调
18
+ */
19
+ function Marker(props) {
20
+ const NativeMarkerView = React.useMemo(() => getNativeMarkerView(), []);
21
+ const [measuredSize, setMeasuredSize] = React.useState(AUTO_SIZE_FALLBACK);
22
+ // 从 props 中排除 position 属性,避免传递到原生层
23
+ const { position, iconWidth, iconHeight, children, smoothMovePath, cacheKey, ...restProps } = props;
24
+ // 归一化坐标处理
25
+ const normalizedPosition = normalizeLatLng(position);
26
+ const normalizedSmoothMovePath = smoothMovePath ? normalizeLatLngList(smoothMovePath) : undefined;
27
+ // 根据是否有 children 来决定使用哪个尺寸属性
28
+ const hasChildren = !!children;
29
+ const shouldWrapChildrenForMeasurement = hasChildren;
30
+ // Android 的 children marker 之前始终透传 0 尺寸,点击后重新快照时容易直接消失。
31
+ // 统一走自动测量后,两个平台都会拿到稳定尺寸。
32
+ const shouldUseAutoMeasuredSize = hasChildren;
33
+ const resolvedContentWidth = shouldUseAutoMeasuredSize ? measuredSize.width : 0;
34
+ const resolvedContentHeight = shouldUseAutoMeasuredSize ? measuredSize.height : 0;
35
+ React.useEffect(() => {
36
+ if (!normalizedSmoothMovePath ||
37
+ normalizedSmoothMovePath.length < 2 ||
38
+ !props.smoothMoveDuration ||
39
+ props.smoothMoveDuration <= 0) {
40
+ return undefined;
41
+ }
42
+ const totalDistance = ExpoGaodeMapModule.calculatePathLength(normalizedSmoothMovePath);
43
+ if (totalDistance <= 0) {
44
+ props.onSmoothMoveEnd?.({
45
+ nativeEvent: {
46
+ position: normalizedSmoothMovePath[normalizedSmoothMovePath.length - 1],
47
+ angle: 0,
48
+ totalDistance,
49
+ },
50
+ });
51
+ return undefined;
52
+ }
53
+ const durationMs = props.smoothMoveDuration * 1000;
54
+ const startedAt = Date.now();
55
+ const tick = () => {
56
+ const progress = Math.min(1, (Date.now() - startedAt) / durationMs);
57
+ const distance = totalDistance * progress;
58
+ const pointInfo = ExpoGaodeMapModule.getPointAtDistance(normalizedSmoothMovePath, distance);
59
+ const point = pointInfo
60
+ ? { latitude: pointInfo.latitude, longitude: pointInfo.longitude }
61
+ : normalizedSmoothMovePath[normalizedSmoothMovePath.length - 1];
62
+ const angle = pointInfo?.angle ?? 0;
63
+ props.onSmoothMoveProgress?.({
64
+ nativeEvent: {
65
+ position: point,
66
+ angle,
67
+ progress,
68
+ distance,
69
+ totalDistance,
70
+ },
71
+ });
72
+ if (progress >= 1) {
73
+ props.onSmoothMoveEnd?.({
74
+ nativeEvent: {
75
+ position: point,
76
+ angle,
77
+ totalDistance,
78
+ },
79
+ });
80
+ }
81
+ };
82
+ tick();
83
+ const intervalId = setInterval(() => {
84
+ tick();
85
+ if (Date.now() - startedAt >= durationMs) {
86
+ clearInterval(intervalId);
87
+ }
88
+ }, 100);
89
+ return () => clearInterval(intervalId);
90
+ }, [
91
+ normalizedSmoothMovePath,
92
+ props.onSmoothMoveEnd,
93
+ props.onSmoothMoveProgress,
94
+ props.smoothMoveDuration,
95
+ ]);
96
+ const handleAutoMeasure = (event) => {
97
+ const nextWidth = Math.ceil(event.nativeEvent.layout.width);
98
+ const nextHeight = Math.ceil(event.nativeEvent.layout.height);
99
+ if (nextWidth === measuredSize.width && nextHeight === measuredSize.height) {
100
+ return;
101
+ }
102
+ setMeasuredSize({
103
+ width: nextWidth,
104
+ height: nextHeight,
105
+ });
106
+ };
107
+ // 智能尺寸计算
108
+ const finalIconWidth = hasChildren
109
+ ? resolvedContentWidth
110
+ : (iconWidth && iconWidth > 0 ? iconWidth : 40);
111
+ const finalIconHeight = hasChildren
112
+ ? resolvedContentHeight
113
+ : (iconHeight && iconHeight > 0 ? iconHeight : 40);
114
+ const optionalNativeProps = cacheKey != null ? { cacheKey } : undefined;
115
+ return (_jsx(NativeMarkerView, { ...restProps, ...optionalNativeProps, latitude: normalizedPosition.latitude, longitude: normalizedPosition.longitude, iconWidth: finalIconWidth, iconHeight: finalIconHeight, contentWidth: hasChildren ? finalIconWidth : 0, contentHeight: hasChildren ? finalIconHeight : 0, smoothMovePath: normalizedSmoothMovePath, children: hasChildren && shouldWrapChildrenForMeasurement ? (_jsx(View, { collapsable: false, onLayout: handleAutoMeasure, style: styles.measureContainer, children: children })) : children }));
116
+ }
117
+ export default React.memo(Marker);
118
+ const styles = StyleSheet.create({
119
+ measureContainer: {
120
+ alignSelf: 'flex-start',
121
+ alignItems: 'flex-start',
122
+ flexShrink: 0,
123
+ },
124
+ });
125
+ //# sourceMappingURL=Marker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Marker.js","sourceRoot":"","sources":["../../../../../src/map/components/overlays/Marker.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAShF,MAAM,mBAAmB,GAAG,2BAA2B,CAAwB,YAAY,CAAC,CAAC;AAE7F,MAAM,kBAAkB,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;AAEnD;;;;;;;;;GASG;AACH,SAAS,MAAM,CAAC,KAAkB;IAChC,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,mBAAmB,EAAE,EAAE,EAAE,C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AG,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAExE,OAAO,CACL,KAAC,gBAAgB,OACX,SAAS,KACT,mBAAmB,EACvB,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,EACrC,SAAS,EAAE,kBAAkB,CAAC,SAAS,EACvC,SAAS,EAAE,cAAc,EACzB,UAAU,EAAE,eAAe,EAC3B,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAC9C,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAChD,cAAc,EAAE,wBAAwB,YAEvC,WAAW,IAAI,gCAAgC,CAAC,CAAC,CAAC,CACjD,KAAC,IAAI,IACH,WAAW,EAAE,KAAK,EAClB,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,EAAE,MAAM,CAAC,gBAAgB,YAE7B,QAAQ,GACJ,CACR,CAAC,CAAC,CAAC,QAAQ,GACK,CACpB,CAAC;AACJ,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAElC,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,gBAAgB,EAAE;QAChB,SAAS,EAAE,YAAY;QACvB,UAAU,EAAE,YAAY;QACxB,UAAU,EAAE,CAAC;KACd;CACF,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport type { LayoutChangeEvent } from 'react-native';\nimport { StyleSheet, View } from 'react-native';\nimport type { MarkerProps } from '../../types';\nimport ExpoGaodeMapModule from '../../ExpoGaodeMapModule';\nimport { normalizeLatLng, normalizeLatLngList } from '../../utils/GeoUtils';\nimport { createLazyNativeViewManager } from '../../utils/lazyNativeViewManager';\n\ntype NativeMarkerViewProps = Omit<MarkerProps, 'position'> & {\n latitude: number;\n longitude: number;\n contentWidth?: number;\n contentHeight?: number;\n};\n\nconst getNativeMarkerView = createLazyNativeViewManager<NativeMarkerViewProps>('MarkerView');\n\nconst AUTO_SIZE_FALLBACK = { width: 0, height: 0 };\n\n/**\n * Marker 组件 - 完全声明式 API\n *\n * 支持:\n * - 自定义图标(icon)\n * - 自定义内容(children)- 自动测量尺寸\n * - 大头针样式(pinColor)\n * - 拖拽功能\n * - 所有事件回调\n */\nfunction Marker(props: MarkerProps) {\n const NativeMarkerView = React.useMemo(() => getNativeMarkerView(), []);\n const [measuredSize, setMeasuredSize] = React.useState(AUTO_SIZE_FALLBACK);\n // 从 props 中排除 position 属性,避免传递到原生层\n const {\n position,\n iconWidth,\n iconHeight,\n children,\n smoothMovePath,\n cacheKey,\n ...restProps\n } = props;\n\n // 归一化坐标处理\n const normalizedPosition = normalizeLatLng(position);\n const normalizedSmoothMovePath = smoothMovePath ? normalizeLatLngList(smoothMovePath) : undefined;\n\n // 根据是否有 children 来决定使用哪个尺寸属性\n const hasChildren = !!children;\n const shouldWrapChildrenForMeasurement = hasChildren;\n // Android 的 children marker 之前始终透传 0 尺寸,点击后重新快照时容易直接消失。\n // 统一走自动测量后,两个平台都会拿到稳定尺寸。\n const shouldUseAutoMeasuredSize = hasChildren;\n const resolvedContentWidth = shouldUseAutoMeasuredSize ? measuredSize.width : 0;\n const resolvedContentHeight = shouldUseAutoMeasuredSize ? measuredSize.height : 0;\n\n React.useEffect(() => {\n if (\n !normalizedSmoothMovePath ||\n normalizedSmoothMovePath.length < 2 ||\n !props.smoothMoveDuration ||\n props.smoothMoveDuration <= 0\n ) {\n return undefined;\n }\n\n const totalDistance = ExpoGaodeMapModule.calculatePathLength(normalizedSmoothMovePath);\n if (totalDistance <= 0) {\n props.onSmoothMoveEnd?.({\n nativeEvent: {\n position: normalizedSmoothMovePath[normalizedSmoothMovePath.length - 1],\n angle: 0,\n totalDistance,\n },\n } as never);\n return undefined;\n }\n\n const durationMs = props.smoothMoveDuration * 1000;\n const startedAt = Date.now();\n const tick = () => {\n const progress = Math.min(1, (Date.now() - startedAt) / durationMs);\n const distance = totalDistance * progress;\n const pointInfo = ExpoGaodeMapModule.getPointAtDistance(normalizedSmoothMovePath, distance);\n const point = pointInfo\n ? { latitude: pointInfo.latitude, longitude: pointInfo.longitude }\n : normalizedSmoothMovePath[normalizedSmoothMovePath.length - 1];\n const angle = pointInfo?.angle ?? 0;\n\n props.onSmoothMoveProgress?.({\n nativeEvent: {\n position: point,\n angle,\n progress,\n distance,\n totalDistance,\n },\n } as never);\n\n if (progress >= 1) {\n props.onSmoothMoveEnd?.({\n nativeEvent: {\n position: point,\n angle,\n totalDistance,\n },\n } as never);\n }\n };\n\n tick();\n const intervalId = setInterval(() => {\n tick();\n if (Date.now() - startedAt >= durationMs) {\n clearInterval(intervalId);\n }\n }, 100);\n\n return () => clearInterval(intervalId);\n }, [\n normalizedSmoothMovePath,\n props.onSmoothMoveEnd,\n props.onSmoothMoveProgress,\n props.smoothMoveDuration,\n ]);\n\n const handleAutoMeasure = (event: LayoutChangeEvent) => {\n const nextWidth = Math.ceil(event.nativeEvent.layout.width);\n const nextHeight = Math.ceil(event.nativeEvent.layout.height);\n\n if (nextWidth === measuredSize.width && nextHeight === measuredSize.height) {\n return;\n }\n\n setMeasuredSize({\n width: nextWidth,\n height: nextHeight,\n });\n };\n\n // 智能尺寸计算\n const finalIconWidth = hasChildren\n ? resolvedContentWidth\n : (iconWidth && iconWidth > 0 ? iconWidth : 40);\n\n const finalIconHeight = hasChildren\n ? resolvedContentHeight\n : (iconHeight && iconHeight > 0 ? iconHeight : 40);\n\n const optionalNativeProps = cacheKey != null ? { cacheKey } : undefined;\n\n return (\n <NativeMarkerView\n {...restProps}\n {...optionalNativeProps}\n latitude={normalizedPosition.latitude}\n longitude={normalizedPosition.longitude}\n iconWidth={finalIconWidth}\n iconHeight={finalIconHeight}\n contentWidth={hasChildren ? finalIconWidth : 0}\n contentHeight={hasChildren ? finalIconHeight : 0}\n smoothMovePath={normalizedSmoothMovePath}\n >\n {hasChildren && shouldWrapChildrenForMeasurement ? (\n <View\n collapsable={false}\n onLayout={handleAutoMeasure}\n style={styles.measureContainer}\n >\n {children}\n </View>\n ) : children}\n </NativeMarkerView>\n );\n}\n\nexport default React.memo(Marker);\n\nconst styles = StyleSheet.create({\n measureContainer: {\n alignSelf: 'flex-start',\n alignItems: 'flex-start',\n flexShrink: 0,\n },\n});\n"]}