expo-gaode-map 1.0.1 → 1.0.3

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 (106) hide show
  1. package/README.md +1 -0
  2. package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapModule.kt +17 -1
  3. package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapView.kt +52 -5
  4. package/android/src/main/java/expo/modules/gaodemap/managers/OverlayManager.kt +184 -6
  5. package/android/src/main/java/expo/modules/gaodemap/overlays/CircleView.kt +24 -51
  6. package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerView.kt +3 -0
  7. package/build/ExpoGaodeMap.types.d.ts.map +1 -1
  8. package/build/ExpoGaodeMap.types.js +0 -10
  9. package/build/ExpoGaodeMap.types.js.map +1 -1
  10. package/build/ExpoGaodeMapModule.d.ts.map +1 -1
  11. package/build/ExpoGaodeMapModule.js +0 -10
  12. package/build/ExpoGaodeMapModule.js.map +1 -1
  13. package/build/ExpoGaodeMapView.d.ts +39 -20
  14. package/build/ExpoGaodeMapView.d.ts.map +1 -1
  15. package/build/ExpoGaodeMapView.js +215 -31
  16. package/build/ExpoGaodeMapView.js.map +1 -1
  17. package/build/components/overlays/Circle.d.ts +0 -15
  18. package/build/components/overlays/Circle.d.ts.map +1 -1
  19. package/build/components/overlays/Circle.js +28 -46
  20. package/build/components/overlays/Circle.js.map +1 -1
  21. package/build/components/overlays/Cluster.d.ts +3 -15
  22. package/build/components/overlays/Cluster.d.ts.map +1 -1
  23. package/build/components/overlays/Cluster.js +3 -25
  24. package/build/components/overlays/Cluster.js.map +1 -1
  25. package/build/components/overlays/HeatMap.d.ts +3 -14
  26. package/build/components/overlays/HeatMap.d.ts.map +1 -1
  27. package/build/components/overlays/HeatMap.js +3 -24
  28. package/build/components/overlays/HeatMap.js.map +1 -1
  29. package/build/components/overlays/Marker.d.ts +2 -15
  30. package/build/components/overlays/Marker.d.ts.map +1 -1
  31. package/build/components/overlays/Marker.js +60 -46
  32. package/build/components/overlays/Marker.js.map +1 -1
  33. package/build/components/overlays/MultiPoint.d.ts +3 -14
  34. package/build/components/overlays/MultiPoint.d.ts.map +1 -1
  35. package/build/components/overlays/MultiPoint.js +3 -24
  36. package/build/components/overlays/MultiPoint.js.map +1 -1
  37. package/build/components/overlays/Polygon.d.ts +13 -16
  38. package/build/components/overlays/Polygon.d.ts.map +1 -1
  39. package/build/components/overlays/Polygon.js +41 -75
  40. package/build/components/overlays/Polygon.js.map +1 -1
  41. package/build/components/overlays/Polyline.d.ts +12 -14
  42. package/build/components/overlays/Polyline.d.ts.map +1 -1
  43. package/build/components/overlays/Polyline.js +34 -35
  44. package/build/components/overlays/Polyline.js.map +1 -1
  45. package/build/components/overlays/index.d.ts.map +1 -1
  46. package/build/components/overlays/index.js +0 -10
  47. package/build/components/overlays/index.js.map +1 -1
  48. package/build/index.d.ts.map +1 -1
  49. package/build/index.js +0 -10
  50. package/build/index.js.map +1 -1
  51. package/build/modules/AMapLocation.d.ts +47 -10
  52. package/build/modules/AMapLocation.d.ts.map +1 -1
  53. package/build/modules/AMapLocation.js +48 -20
  54. package/build/modules/AMapLocation.js.map +1 -1
  55. package/build/modules/AMapPermissions.d.ts +3 -1
  56. package/build/modules/AMapPermissions.d.ts.map +1 -1
  57. package/build/modules/AMapPermissions.js +3 -11
  58. package/build/modules/AMapPermissions.js.map +1 -1
  59. package/build/modules/AMapSDK.d.ts +5 -4
  60. package/build/modules/AMapSDK.d.ts.map +1 -1
  61. package/build/modules/AMapSDK.js +5 -14
  62. package/build/modules/AMapSDK.js.map +1 -1
  63. package/build/modules/AMapView.d.ts.map +1 -1
  64. package/build/modules/AMapView.js +0 -8
  65. package/build/modules/AMapView.js.map +1 -1
  66. package/build/types/index.d.ts.map +1 -1
  67. package/build/types/index.js +0 -10
  68. package/build/types/index.js.map +1 -1
  69. package/build/types/map-view.types.d.ts +30 -0
  70. package/build/types/map-view.types.d.ts.map +1 -1
  71. package/build/types/map-view.types.js.map +1 -1
  72. package/build/types/overlays.types.d.ts +25 -1
  73. package/build/types/overlays.types.d.ts.map +1 -1
  74. package/build/types/overlays.types.js.map +1 -1
  75. package/docs/API.md +40 -0
  76. package/docs/EXAMPLES.md +86 -2
  77. package/docs/RELEASE_GUIDE.md +178 -0
  78. package/expo-module.config.json +1 -1
  79. package/ios/ExpoGaodeMapModule.swift +42 -14
  80. package/ios/ExpoGaodeMapView.swift +210 -7
  81. package/ios/managers/OverlayManager.swift +78 -10
  82. package/ios/overlays/CircleView.swift +41 -12
  83. package/ios/overlays/MarkerView.swift +55 -3
  84. package/ios/overlays/PolygonView.swift +25 -5
  85. package/ios/overlays/PolylineView.swift +23 -4
  86. package/ios/utils/ColorParser.swift +0 -5
  87. package/package.json +1 -1
  88. package/src/ExpoGaodeMap.types.ts +1 -10
  89. package/src/ExpoGaodeMapModule.ts +1 -10
  90. package/src/ExpoGaodeMapView.tsx +257 -38
  91. package/src/components/overlays/Circle.tsx +32 -50
  92. package/src/components/overlays/Cluster.tsx +4 -26
  93. package/src/components/overlays/HeatMap.tsx +4 -25
  94. package/src/components/overlays/Marker.tsx +69 -52
  95. package/src/components/overlays/MultiPoint.tsx +4 -25
  96. package/src/components/overlays/Polygon.tsx +48 -78
  97. package/src/components/overlays/Polyline.tsx +41 -38
  98. package/src/components/overlays/index.ts +0 -11
  99. package/src/index.ts +0 -11
  100. package/src/modules/AMapLocation.ts +56 -20
  101. package/src/modules/AMapPermissions.ts +4 -11
  102. package/src/modules/AMapSDK.ts +7 -14
  103. package/src/modules/AMapView.ts +0 -8
  104. package/src/types/index.ts +1 -10
  105. package/src/types/map-view.types.ts +25 -0
  106. package/src/types/overlays.types.ts +30 -1
@@ -1,30 +1,49 @@
1
1
  import * as React from 'react';
2
- import type { MapViewProps, MapViewRef } from './types';
2
+ import type { MapViewProps, MapViewRef, LatLng } from './types';
3
3
  export type { MapViewRef } from './types';
4
4
  export declare const MapContext: React.Context<React.RefObject<MapViewRef | null> | null>;
5
+ type MarkerEventCallbacks = {
6
+ onPress?: () => void;
7
+ onDragStart?: () => void;
8
+ onDrag?: () => void;
9
+ onDragEnd?: (event: {
10
+ nativeEvent: LatLng;
11
+ }) => void;
12
+ };
13
+ declare class MarkerEventManager {
14
+ private callbacks;
15
+ register(markerId: string, callbacks: MarkerEventCallbacks): void;
16
+ unregister(markerId: string): void;
17
+ trigger(markerId: string, eventType: keyof MarkerEventCallbacks, data?: any): void;
18
+ }
19
+ export declare const MarkerEventContext: React.Context<MarkerEventManager | null>;
20
+ type CircleEventCallbacks = {
21
+ onPress?: () => void;
22
+ };
23
+ declare class CircleEventManager {
24
+ private callbacks;
25
+ register(circleId: string, callbacks: CircleEventCallbacks): void;
26
+ unregister(circleId: string): void;
27
+ trigger(circleId: string, eventType: keyof CircleEventCallbacks): void;
28
+ }
29
+ export declare const CircleEventContext: React.Context<CircleEventManager | null>;
5
30
  /**
6
- * 高德地图视图组件
31
+ * 高德地图视图组件,提供地图操作API和覆盖物管理功能
7
32
  *
8
- * @example
9
- * ```tsx
10
- * import { MapView } from 'expo-gaode-map';
33
+ * @param props - 组件属性
34
+ * @param ref - 外部ref引用,用于访问地图API方法
35
+ * @returns 返回包含地图视图和上下文提供者的React组件
11
36
  *
12
- * function MyMap() {
13
- * const mapRef = React.useRef(null);
37
+ * @remarks
38
+ * 该组件内部维护两个ref:
39
+ * - nativeRef: 指向原生地图视图的引用
40
+ * - internalRef: 内部使用的API引用,通过MapContext共享
14
41
  *
15
- * return (
16
- * <MapView
17
- * ref={mapRef}
18
- * style={{ flex: 1 }}
19
- * initialCameraPosition={{
20
- * target: { latitude: 39.9, longitude: 116.4 },
21
- * zoom: 10,
22
- * }}
23
- * onLoad={() => console.log('地图加载完成')}
24
- * />
25
- * );
26
- * }
27
- * ```
42
+ * 提供的主要API功能包括:
43
+ * - 相机控制(移动、缩放、获取当前位置)
44
+ * - 覆盖物管理(添加/删除/更新标记、折线、多边形、圆形等)
45
+ *
46
+ * 所有API方法都会检查地图是否已初始化,未初始化时抛出错误
28
47
  */
29
48
  declare const ExpoGaodeMapView: React.ForwardRefExoticComponent<MapViewProps & React.RefAttributes<MapViewRef>>;
30
49
  export default ExpoGaodeMapView;
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoGaodeMapView.d.ts","sourceRoot":"","sources":["../src/ExpoGaodeMapView.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EASX,MAAM,SAAS,CAAC;AAGjB,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK1C,eAAO,MAAM,UAAU,0DAAuE,CAAC;AAE/F;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,QAAA,MAAM,gBAAgB,iFAuFpB,CAAC;AAIH,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"ExpoGaodeMapView.d.ts","sourceRoot":"","sources":["../src/ExpoGaodeMapView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EAGV,MAAM,EAMP,MAAM,SAAS,CAAC;AAGjB,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK1C,eAAO,MAAM,UAAU,0DAAuE,CAAC;AAG/F,KAAK,oBAAoB,GAAG;IAC1B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACtD,CAAC;AAEF,cAAM,kBAAkB;IACtB,OAAO,CAAC,SAAS,CAA2C;IAE5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB;IAI1D,UAAU,CAAC,QAAQ,EAAE,MAAM;IAI3B,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,oBAAoB,EAAE,IAAI,CAAC,EAAE,GAAG;CAM5E;AAED,eAAO,MAAM,kBAAkB,0CAAuD,CAAC;AAGvF,KAAK,oBAAoB,GAAG;IAC1B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,cAAM,kBAAkB;IACtB,OAAO,CAAC,SAAS,CAA2C;IAE5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB;IAI1D,UAAU,CAAC,QAAQ,EAAE,MAAM;IAI3B,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,oBAAoB;CAMhE;AAED,eAAO,MAAM,kBAAkB,0CAAuD,CAAC;AAEvF;;;;;;;;;;;;;;;;;GAiBG;AACH,QAAA,MAAM,gBAAgB,iFA4QpB,CAAC;AAIH,eAAe,gBAAgB,CAAC"}
@@ -1,139 +1,323 @@
1
- /*
2
- * @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
3
- * @Date : 2025-11-13 14:03:56
4
- * @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
5
- * @LastEditTime : 2025-11-15 01:50:18
6
- * @FilePath : /expo-gaode-map/src/ExpoGaodeMapView.tsx
7
- * @Description : 高德地图视图组件
8
- *
9
- * Copyright (c) 2025 by 尚博信_王强, All Rights Reserved.
10
- */
11
1
  import { requireNativeViewManager } from 'expo-modules-core';
12
2
  import * as React from 'react';
13
3
  const NativeView = requireNativeViewManager('ExpoGaodeMap');
14
4
  // 创建 Context 用于子组件访问 MapRef
15
5
  export const MapContext = React.createContext(null);
6
+ class MarkerEventManager {
7
+ callbacks = new Map();
8
+ register(markerId, callbacks) {
9
+ this.callbacks.set(markerId, callbacks);
10
+ }
11
+ unregister(markerId) {
12
+ this.callbacks.delete(markerId);
13
+ }
14
+ trigger(markerId, eventType, data) {
15
+ const callbacks = this.callbacks.get(markerId);
16
+ if (callbacks && callbacks[eventType]) {
17
+ callbacks[eventType](data);
18
+ }
19
+ }
20
+ }
21
+ export const MarkerEventContext = React.createContext(null);
22
+ class CircleEventManager {
23
+ callbacks = new Map();
24
+ register(circleId, callbacks) {
25
+ this.callbacks.set(circleId, callbacks);
26
+ }
27
+ unregister(circleId) {
28
+ this.callbacks.delete(circleId);
29
+ }
30
+ trigger(circleId, eventType) {
31
+ const callbacks = this.callbacks.get(circleId);
32
+ if (callbacks && callbacks[eventType]) {
33
+ callbacks[eventType]();
34
+ }
35
+ }
36
+ }
37
+ export const CircleEventContext = React.createContext(null);
16
38
  /**
17
- * 高德地图视图组件
39
+ * 高德地图视图组件,提供地图操作API和覆盖物管理功能
40
+ *
41
+ * @param props - 组件属性
42
+ * @param ref - 外部ref引用,用于访问地图API方法
43
+ * @returns 返回包含地图视图和上下文提供者的React组件
18
44
  *
19
- * @example
20
- * ```tsx
21
- * import { MapView } from 'expo-gaode-map';
45
+ * @remarks
46
+ * 该组件内部维护两个ref:
47
+ * - nativeRef: 指向原生地图视图的引用
48
+ * - internalRef: 内部使用的API引用,通过MapContext共享
22
49
  *
23
- * function MyMap() {
24
- * const mapRef = React.useRef(null);
50
+ * 提供的主要API功能包括:
51
+ * - 相机控制(移动、缩放、获取当前位置)
52
+ * - 覆盖物管理(添加/删除/更新标记、折线、多边形、圆形等)
25
53
  *
26
- * return (
27
- * <MapView
28
- * ref={mapRef}
29
- * style={{ flex: 1 }}
30
- * initialCameraPosition={{
31
- * target: { latitude: 39.9, longitude: 116.4 },
32
- * zoom: 10,
33
- * }}
34
- * onLoad={() => console.log('地图加载完成')}
35
- * />
36
- * );
37
- * }
38
- * ```
54
+ * 所有API方法都会检查地图是否已初始化,未初始化时抛出错误
39
55
  */
40
56
  const ExpoGaodeMapView = React.forwardRef((props, ref) => {
41
57
  const nativeRef = React.useRef(null);
42
58
  const internalRef = React.useRef(null);
59
+ const markerEventManager = React.useRef(new MarkerEventManager()).current;
60
+ const circleEventManager = React.useRef(new CircleEventManager()).current;
61
+ // 处理 Marker 事件
62
+ const handleMarkerPress = React.useCallback((event) => {
63
+ const markerId = event.nativeEvent?.markerId;
64
+ if (markerId) {
65
+ markerEventManager.trigger(markerId, 'onPress');
66
+ }
67
+ props.onMarkerPress?.(event);
68
+ }, [props.onMarkerPress]);
69
+ const handleMarkerDragStart = React.useCallback((event) => {
70
+ const markerId = event.nativeEvent?.markerId;
71
+ if (markerId) {
72
+ markerEventManager.trigger(markerId, 'onDragStart');
73
+ }
74
+ props.onMarkerDragStart?.(event);
75
+ }, [props.onMarkerDragStart]);
76
+ const handleMarkerDrag = React.useCallback((event) => {
77
+ const markerId = event.nativeEvent?.markerId;
78
+ if (markerId) {
79
+ markerEventManager.trigger(markerId, 'onDrag');
80
+ }
81
+ props.onMarkerDrag?.(event);
82
+ }, [props.onMarkerDrag]);
83
+ const handleMarkerDragEnd = React.useCallback((event) => {
84
+ const markerId = event.nativeEvent?.markerId;
85
+ if (markerId) {
86
+ markerEventManager.trigger(markerId, 'onDragEnd', {
87
+ nativeEvent: {
88
+ latitude: event.nativeEvent.latitude,
89
+ longitude: event.nativeEvent.longitude
90
+ }
91
+ });
92
+ }
93
+ props.onMarkerDragEnd?.(event);
94
+ }, [props.onMarkerDragEnd]);
95
+ const handleCirclePress = React.useCallback((event) => {
96
+ const circleId = event.nativeEvent?.circleId;
97
+ if (circleId) {
98
+ circleEventManager.trigger(circleId, 'onPress');
99
+ }
100
+ props.onCirclePress?.(event);
101
+ }, [props.onCirclePress]);
43
102
  const apiRef = React.useMemo(() => ({
103
+ /**
104
+ * 移动地图相机到指定位置
105
+ * @param position 相机位置参数对象,包含目标经纬度、缩放级别等信息
106
+ * @param duration 动画持续时间(毫秒),默认300毫秒
107
+ * @throws 如果地图视图未初始化则抛出错误
108
+ * @returns Promise<void> 异步操作完成后的Promise
109
+ */
44
110
  moveCamera: async (position, duration = 300) => {
45
111
  if (!nativeRef.current)
46
112
  throw new Error('MapView not initialized');
47
113
  return nativeRef.current.moveCamera(position, duration);
48
114
  },
115
+ /**
116
+ * 将屏幕坐标点转换为地理坐标(经纬度)
117
+ * @param point 屏幕坐标点 {x: number, y: number}
118
+ * @returns 返回Promise,解析为对应的地理坐标 {latitude: number, longitude: number}
119
+ * @throws 如果地图视图未初始化,抛出错误 'MapView not initialized'
120
+ */
49
121
  getLatLng: async (point) => {
50
122
  if (!nativeRef.current)
51
123
  throw new Error('MapView not initialized');
52
124
  return nativeRef.current.getLatLng(point);
53
125
  },
126
+ /**
127
+ * 设置地图中心点坐标
128
+ * @param center 要设置的中心点坐标(LatLng格式)
129
+ * @param animated 是否使用动画效果移动地图(默认为false)
130
+ * @throws 如果地图视图未初始化则抛出错误
131
+ */
54
132
  setCenter: async (center, animated = false) => {
55
133
  if (!nativeRef.current)
56
134
  throw new Error('MapView not initialized');
57
135
  return nativeRef.current.setCenter(center, animated);
58
136
  },
137
+ /**
138
+ * 设置地图的缩放级别
139
+ * @param zoom 目标缩放级别
140
+ * @param animated 是否使用动画过渡效果,默认为false
141
+ * @throws 如果地图视图未初始化,抛出错误
142
+ */
59
143
  setZoom: async (zoom, animated = false) => {
60
144
  if (!nativeRef.current)
61
145
  throw new Error('MapView not initialized');
62
146
  return nativeRef.current.setZoom(zoom, animated);
63
147
  },
148
+ /**
149
+ * 获取当前地图的相机位置(视角中心点、缩放级别、倾斜角度等)
150
+ * @returns 返回一个Promise,解析为当前相机位置的对象
151
+ * @throws 如果地图视图未初始化,则抛出错误
152
+ */
64
153
  getCameraPosition: async () => {
65
154
  if (!nativeRef.current)
66
155
  throw new Error('MapView not initialized');
67
156
  return nativeRef.current.getCameraPosition();
68
157
  },
158
+ /**
159
+ * 在地图上添加圆形覆盖物
160
+ * @param id - 圆形覆盖物的唯一标识符
161
+ * @param props - 圆形覆盖物的属性配置
162
+ * @returns Promise<void> 添加操作的异步结果
163
+ * @throws 如果地图视图未初始化,抛出错误'MapView not initialized'
164
+ */
69
165
  addCircle: async (id, props) => {
70
166
  if (!nativeRef.current)
71
167
  throw new Error('MapView not initialized');
72
168
  return nativeRef.current.addCircle(id, props);
73
169
  },
170
+ /**
171
+ * 从地图上移除指定的圆形覆盖物
172
+ * @param id - 要移除的圆形覆盖物的唯一标识符
173
+ * @throws 如果地图视图未初始化,抛出错误
174
+ * @returns Promise<void> 异步操作完成
175
+ */
74
176
  removeCircle: async (id) => {
75
177
  if (!nativeRef.current)
76
178
  throw new Error('MapView not initialized');
77
179
  return nativeRef.current.removeCircle(id);
78
180
  },
181
+ /**
182
+ * 更新地图上的圆形覆盖物
183
+ * @param id 要更新的圆形覆盖物的唯一标识符
184
+ * @param props 要更新的圆形属性(部分属性)
185
+ * @throws 如果地图视图未初始化,抛出错误
186
+ * @returns Promise<void> 表示更新操作完成
187
+ */
79
188
  updateCircle: async (id, props) => {
80
189
  if (!nativeRef.current)
81
190
  throw new Error('MapView not initialized');
82
191
  return nativeRef.current.updateCircle(id, props);
83
192
  },
193
+ /**
194
+ * 添加一个标记点到地图上
195
+ * @param id 标记点的唯一标识符
196
+ * @param props 标记点的配置属性
197
+ * @returns Promise<void> 添加操作完成后的Promise
198
+ * @throws 如果地图视图未初始化则抛出错误
199
+ */
84
200
  addMarker: async (id, props) => {
85
201
  if (!nativeRef.current)
86
202
  throw new Error('MapView not initialized');
87
203
  return nativeRef.current.addMarker(id, props);
88
204
  },
205
+ /**
206
+ * 从地图上移除指定ID的标记点
207
+ * @param id 要移除的标记点ID
208
+ * @throws 如果地图视图未初始化则抛出错误
209
+ * @returns Promise<void> 异步操作完成
210
+ */
89
211
  removeMarker: async (id) => {
90
212
  if (!nativeRef.current)
91
213
  throw new Error('MapView not initialized');
92
214
  return nativeRef.current.removeMarker(id);
93
215
  },
216
+ /**
217
+ * 更新地图上指定ID的标记点属性
218
+ * @param id - 要更新的标记点唯一标识符
219
+ * @param props - 需要更新的标记点属性对象(部分属性)
220
+ * @throws 如果地图视图未初始化则抛出错误
221
+ * @returns Promise对象,表示异步更新操作
222
+ */
94
223
  updateMarker: async (id, props) => {
95
224
  if (!nativeRef.current)
96
225
  throw new Error('MapView not initialized');
97
226
  return nativeRef.current.updateMarker(id, props);
98
227
  },
228
+ /**
229
+ * 添加折线覆盖物到地图
230
+ * @param id - 折线的唯一标识符
231
+ * @param props - 折线的配置属性
232
+ * @returns Promise<void> 添加操作的异步结果
233
+ * @throws 如果地图视图未初始化则抛出错误
234
+ */
99
235
  addPolyline: async (id, props) => {
100
236
  if (!nativeRef.current)
101
237
  throw new Error('MapView not initialized');
102
238
  return nativeRef.current.addPolyline(id, props);
103
239
  },
240
+ /**
241
+ * 移除地图上的指定折线
242
+ * @param id - 要移除的折线的唯一标识符
243
+ * @throws 如果地图视图未初始化,抛出错误
244
+ * @returns Promise<void>
245
+ */
104
246
  removePolyline: async (id) => {
105
247
  if (!nativeRef.current)
106
248
  throw new Error('MapView not initialized');
107
249
  return nativeRef.current.removePolyline(id);
108
250
  },
251
+ /**
252
+ * 更新地图上的折线覆盖物
253
+ *
254
+ * @param id 要更新的折线覆盖物的唯一标识符
255
+ * @param props 要更新的折线属性,包含部分PolylineProps属性
256
+ * @returns Promise<void> 异步操作结果
257
+ * @throws 如果地图视图未初始化,抛出错误
258
+ */
109
259
  updatePolyline: async (id, props) => {
110
260
  if (!nativeRef.current)
111
261
  throw new Error('MapView not initialized');
112
262
  return nativeRef.current.updatePolyline(id, props);
113
263
  },
264
+ /**
265
+ * 向地图添加多边形覆盖物
266
+ * @param id - 多边形的唯一标识符
267
+ * @param props - 多边形的配置属性
268
+ * @returns Promise<void> 添加操作的异步结果
269
+ * @throws 如果地图视图未初始化则抛出错误
270
+ */
114
271
  addPolygon: async (id, props) => {
115
272
  if (!nativeRef.current)
116
273
  throw new Error('MapView not initialized');
117
274
  return nativeRef.current.addPolygon(id, props);
118
275
  },
276
+ /**
277
+ * 移除地图上的多边形覆盖物
278
+ * @param id - 要移除的多边形覆盖物的唯一标识符
279
+ * @throws 如果地图视图未初始化,抛出错误 'MapView not initialized'
280
+ * @returns Promise<void> 异步操作完成
281
+ */
119
282
  removePolygon: async (id) => {
120
283
  if (!nativeRef.current)
121
284
  throw new Error('MapView not initialized');
122
285
  return nativeRef.current.removePolygon(id);
123
286
  },
287
+ /**
288
+ * 更新多边形覆盖物的属性
289
+ *
290
+ * @param id - 要更新的多边形覆盖物的唯一标识符
291
+ * @param props - 要更新的多边形属性对象,包含需要更新的部分属性
292
+ * @throws {Error} 当地图视图未初始化时抛出错误
293
+ * @returns Promise<void> 异步操作完成后的Promise
294
+ */
124
295
  updatePolygon: async (id, props) => {
125
296
  if (!nativeRef.current)
126
297
  throw new Error('MapView not initialized');
127
298
  return nativeRef.current.updatePolygon(id, props);
128
299
  },
129
300
  }), []);
130
- // 设置 internalRef 和外部 ref
301
+ /**
302
+ * 将传入的apiRef赋值给internalRef.current
303
+ * 用于在组件内部保存对地图API实例的引用
304
+ */
131
305
  React.useEffect(() => {
132
306
  internalRef.current = apiRef;
133
307
  }, [apiRef]);
308
+ /**
309
+ * 获取当前地图实例的API引用
310
+ * @returns 返回地图API的引用对象,可用于调用地图相关方法
311
+ */
134
312
  React.useImperativeHandle(ref, () => apiRef, [apiRef]);
135
313
  return (<MapContext.Provider value={internalRef}>
136
- <NativeView ref={nativeRef} {...props}/>
314
+ <MarkerEventContext.Provider value={markerEventManager}>
315
+ <CircleEventContext.Provider value={circleEventManager}>
316
+ <NativeView ref={nativeRef} {...props} onMarkerPress={handleMarkerPress} onMarkerDragStart={handleMarkerDragStart} onMarkerDrag={handleMarkerDrag} onMarkerDragEnd={handleMarkerDragEnd} onCirclePress={handleCirclePress}>
317
+ {props.children}
318
+ </NativeView>
319
+ </CircleEventContext.Provider>
320
+ </MarkerEventContext.Provider>
137
321
  </MapContext.Provider>);
138
322
  });
139
323
  ExpoGaodeMapView.displayName = 'ExpoGaodeMapView';
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoGaodeMapView.js","sourceRoot":"","sources":["../src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CACtC;MAAA,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC,EACxC;IAAA,EAAE,UAAU,CAAC,QAAQ,CAAC,CACvB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAElD,eAAe,gBAAgB,CAAC","sourcesContent":["/*\n * @Author : 尚博信_王强 wangqiang03@sunboxsoft.com\n * @Date : 2025-11-13 14:03:56\n * @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com\n * @LastEditTime : 2025-11-15 01:50:18\n * @FilePath : /expo-gaode-map/src/ExpoGaodeMapView.tsx\n * @Description : 高德地图视图组件\n * \n * Copyright (c) 2025 by 尚博信_王强, All Rights Reserved. \n */\n\nimport { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\n\nimport type { \n MapViewProps, \n MapViewRef,\n NativeMapViewRef,\n CameraPosition, \n LatLng, \n Point, \n CircleProps,\n MarkerProps,\n PolylineProps,\n PolygonProps,\n} from './types';\n\n// 重新导出 MapViewRef 供外部使用\nexport type { MapViewRef } from './types';\n\nconst NativeView: React.ComponentType<MapViewProps & { ref?: React.Ref<NativeMapViewRef> }> = requireNativeViewManager('ExpoGaodeMap');\n\n// 创建 Context 用于子组件访问 MapRef\nexport const MapContext = React.createContext<React.RefObject<MapViewRef | null> | null>(null);\n\n/**\n * 高德地图视图组件\n * \n * @example\n * ```tsx\n * import { MapView } from 'expo-gaode-map';\n * \n * function MyMap() {\n * const mapRef = React.useRef(null);\n * \n * return (\n * <MapView\n * ref={mapRef}\n * style={{ flex: 1 }}\n * initialCameraPosition={{\n * target: { latitude: 39.9, longitude: 116.4 },\n * zoom: 10,\n * }}\n * onLoad={() => console.log('地图加载完成')}\n * />\n * );\n * }\n * ```\n */\nconst ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref) => {\n const nativeRef = React.useRef<NativeMapViewRef>(null);\n const internalRef = React.useRef<MapViewRef | null>(null);\n\n const apiRef: MapViewRef = React.useMemo(() => ({\n moveCamera: async (position: CameraPosition, duration: number = 300) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.moveCamera(position, duration);\n },\n getLatLng: async (point: Point) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.getLatLng(point);\n },\n setCenter: async (center: LatLng, animated: boolean = false) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.setCenter(center, animated);\n },\n setZoom: async (zoom: number, animated: boolean = false) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.setZoom(zoom, animated);\n },\n getCameraPosition: async () => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.getCameraPosition();\n },\n addCircle: async (id: string, props: CircleProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addCircle(id, props);\n },\n removeCircle: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removeCircle(id);\n },\n updateCircle: async (id: string, props: Partial<CircleProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updateCircle(id, props);\n },\n addMarker: async (id: string, props: MarkerProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addMarker(id, props);\n },\n removeMarker: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removeMarker(id);\n },\n updateMarker: async (id: string, props: Partial<MarkerProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updateMarker(id, props);\n },\n addPolyline: async (id: string, props: PolylineProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addPolyline(id, props);\n },\n removePolyline: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removePolyline(id);\n },\n updatePolyline: async (id: string, props: Partial<PolylineProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updatePolyline(id, props);\n },\n addPolygon: async (id: string, props: PolygonProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addPolygon(id, props);\n },\n removePolygon: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removePolygon(id);\n },\n updatePolygon: async (id: string, props: Partial<PolygonProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updatePolygon(id, props);\n },\n }), []);\n\n // 设置 internalRef 和外部 ref\n React.useEffect(() => {\n internalRef.current = apiRef;\n }, [apiRef]);\n\n React.useImperativeHandle(ref, () => apiRef, [apiRef]);\n\n return (\n <MapContext.Provider value={internalRef}>\n <NativeView ref={nativeRef} {...props} />\n </MapContext.Provider>\n );\n});\n\nExpoGaodeMapView.displayName = 'ExpoGaodeMapView';\n\nexport default ExpoGaodeMapView;\n"]}
1
+ {"version":3,"file":"ExpoGaodeMapView.js","sourceRoot":"","sources":["../src/ExpoGaodeMapView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAkB/B,MAAM,UAAU,GAA8E,wBAAwB,CAAC,cAAc,CAAC,CAAC;AAEvI,4BAA4B;AAC5B,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,CAA4C,IAAI,CAAC,CAAC;AAU/F,MAAM,kBAAkB;IACd,SAAS,GAAG,IAAI,GAAG,EAAgC,CAAC;IAE5D,QAAQ,CAAC,QAAgB,EAAE,SAA+B;QACxD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED,UAAU,CAAC,QAAgB;QACzB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED,OAAO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CAAC,CACvB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAElD,eAAe,gBAAgB,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\n\nimport type {\n MapViewProps,\n MapViewRef,\n NativeMapViewRef,\n CameraPosition,\n LatLng,\n Point,\n CircleProps,\n MarkerProps,\n PolylineProps,\n PolygonProps,\n} from './types';\n\n// 重新导出 MapViewRef 供外部使用\nexport type { MapViewRef } from './types';\n\nconst NativeView: React.ComponentType<MapViewProps & { ref?: React.Ref<NativeMapViewRef> }> = requireNativeViewManager('ExpoGaodeMap');\n\n// 创建 Context 用于子组件访问 MapRef\nexport const MapContext = React.createContext<React.RefObject<MapViewRef | null> | null>(null);\n\n// Marker 事件管理器\ntype MarkerEventCallbacks = {\n onPress?: () => void;\n onDragStart?: () => void;\n onDrag?: () => void;\n onDragEnd?: (event: { nativeEvent: LatLng }) => void;\n};\n\nclass MarkerEventManager {\n private callbacks = new Map<string, MarkerEventCallbacks>();\n \n register(markerId: string, callbacks: MarkerEventCallbacks) {\n this.callbacks.set(markerId, callbacks);\n }\n \n unregister(markerId: string) {\n this.callbacks.delete(markerId);\n }\n \n trigger(markerId: string, eventType: keyof MarkerEventCallbacks, data?: any) {\n const callbacks = this.callbacks.get(markerId);\n if (callbacks && callbacks[eventType]) {\n callbacks[eventType]!(data);\n }\n }\n}\n\nexport const MarkerEventContext = React.createContext<MarkerEventManager | null>(null);\n\n// Circle 事件管理器\ntype CircleEventCallbacks = {\n onPress?: () => void;\n};\n\nclass CircleEventManager {\n private callbacks = new Map<string, CircleEventCallbacks>();\n \n register(circleId: string, callbacks: CircleEventCallbacks) {\n this.callbacks.set(circleId, callbacks);\n }\n \n unregister(circleId: string) {\n this.callbacks.delete(circleId);\n }\n \n trigger(circleId: string, eventType: keyof CircleEventCallbacks) {\n const callbacks = this.callbacks.get(circleId);\n if (callbacks && callbacks[eventType]) {\n callbacks[eventType]!();\n }\n }\n}\n\nexport const CircleEventContext = React.createContext<CircleEventManager | null>(null);\n\n/**\n * 高德地图视图组件,提供地图操作API和覆盖物管理功能\n * \n * @param props - 组件属性\n * @param ref - 外部ref引用,用于访问地图API方法\n * @returns 返回包含地图视图和上下文提供者的React组件\n * \n * @remarks\n * 该组件内部维护两个ref:\n * - nativeRef: 指向原生地图视图的引用\n * - internalRef: 内部使用的API引用,通过MapContext共享\n * \n * 提供的主要API功能包括:\n * - 相机控制(移动、缩放、获取当前位置)\n * - 覆盖物管理(添加/删除/更新标记、折线、多边形、圆形等)\n * \n * 所有API方法都会检查地图是否已初始化,未初始化时抛出错误\n */\nconst ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref) => {\n const nativeRef = React.useRef<NativeMapViewRef>(null);\n const internalRef = React.useRef<MapViewRef | null>(null);\n const markerEventManager = React.useRef(new MarkerEventManager()).current;\n const circleEventManager = React.useRef(new CircleEventManager()).current;\n \n // 处理 Marker 事件\n const handleMarkerPress = React.useCallback((event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) {\n markerEventManager.trigger(markerId, 'onPress');\n }\n props.onMarkerPress?.(event);\n }, [props.onMarkerPress]);\n \n const handleMarkerDragStart = React.useCallback((event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) {\n markerEventManager.trigger(markerId, 'onDragStart');\n }\n props.onMarkerDragStart?.(event);\n }, [props.onMarkerDragStart]);\n \n const handleMarkerDrag = React.useCallback((event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) {\n markerEventManager.trigger(markerId, 'onDrag');\n }\n props.onMarkerDrag?.(event);\n }, [props.onMarkerDrag]);\n \n const handleMarkerDragEnd = React.useCallback((event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) {\n markerEventManager.trigger(markerId, 'onDragEnd', {\n nativeEvent: {\n latitude: event.nativeEvent.latitude,\n longitude: event.nativeEvent.longitude\n }\n });\n }\n props.onMarkerDragEnd?.(event);\n }, [props.onMarkerDragEnd]);\n \n const handleCirclePress = React.useCallback((event: any) => {\n const circleId = event.nativeEvent?.circleId;\n if (circleId) {\n circleEventManager.trigger(circleId, 'onPress');\n }\n props.onCirclePress?.(event);\n }, [props.onCirclePress]);\n\n const apiRef: MapViewRef = React.useMemo(() => ({\n /**\n * 移动地图相机到指定位置\n * @param position 相机位置参数对象,包含目标经纬度、缩放级别等信息\n * @param duration 动画持续时间(毫秒),默认300毫秒\n * @throws 如果地图视图未初始化则抛出错误\n * @returns Promise<void> 异步操作完成后的Promise\n */\n moveCamera: async (position: CameraPosition, duration: number = 300) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.moveCamera(position, duration);\n },\n /**\n * 将屏幕坐标点转换为地理坐标(经纬度)\n * @param point 屏幕坐标点 {x: number, y: number}\n * @returns 返回Promise,解析为对应的地理坐标 {latitude: number, longitude: number}\n * @throws 如果地图视图未初始化,抛出错误 'MapView not initialized'\n */\n getLatLng: async (point: Point) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.getLatLng(point);\n },\n /**\n * 设置地图中心点坐标\n * @param center 要设置的中心点坐标(LatLng格式)\n * @param animated 是否使用动画效果移动地图(默认为false)\n * @throws 如果地图视图未初始化则抛出错误\n */\n setCenter: async (center: LatLng, animated: boolean = false) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.setCenter(center, animated);\n },\n /**\n * 设置地图的缩放级别\n * @param zoom 目标缩放级别\n * @param animated 是否使用动画过渡效果,默认为false\n * @throws 如果地图视图未初始化,抛出错误\n */\n setZoom: async (zoom: number, animated: boolean = false) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.setZoom(zoom, animated);\n },\n /**\n * 获取当前地图的相机位置(视角中心点、缩放级别、倾斜角度等)\n * @returns 返回一个Promise,解析为当前相机位置的对象\n * @throws 如果地图视图未初始化,则抛出错误\n */\n getCameraPosition: async () => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.getCameraPosition();\n },\n /**\n * 在地图上添加圆形覆盖物\n * @param id - 圆形覆盖物的唯一标识符\n * @param props - 圆形覆盖物的属性配置\n * @returns Promise<void> 添加操作的异步结果\n * @throws 如果地图视图未初始化,抛出错误'MapView not initialized'\n */\n addCircle: async (id: string, props: CircleProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addCircle(id, props);\n },\n /**\n * 从地图上移除指定的圆形覆盖物\n * @param id - 要移除的圆形覆盖物的唯一标识符\n * @throws 如果地图视图未初始化,抛出错误\n * @returns Promise<void> 异步操作完成\n */\n removeCircle: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removeCircle(id);\n },\n /**\n * 更新地图上的圆形覆盖物\n * @param id 要更新的圆形覆盖物的唯一标识符\n * @param props 要更新的圆形属性(部分属性)\n * @throws 如果地图视图未初始化,抛出错误\n * @returns Promise<void> 表示更新操作完成\n */\n updateCircle: async (id: string, props: Partial<CircleProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updateCircle(id, props);\n },\n /**\n * 添加一个标记点到地图上\n * @param id 标记点的唯一标识符\n * @param props 标记点的配置属性\n * @returns Promise<void> 添加操作完成后的Promise\n * @throws 如果地图视图未初始化则抛出错误\n */\n addMarker: async (id: string, props: MarkerProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addMarker(id, props);\n },\n /**\n * 从地图上移除指定ID的标记点\n * @param id 要移除的标记点ID\n * @throws 如果地图视图未初始化则抛出错误\n * @returns Promise<void> 异步操作完成\n */\n removeMarker: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removeMarker(id);\n },\n /**\n * 更新地图上指定ID的标记点属性\n * @param id - 要更新的标记点唯一标识符\n * @param props - 需要更新的标记点属性对象(部分属性)\n * @throws 如果地图视图未初始化则抛出错误\n * @returns Promise对象,表示异步更新操作\n */\n updateMarker: async (id: string, props: Partial<MarkerProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updateMarker(id, props);\n },\n /**\n * 添加折线覆盖物到地图\n * @param id - 折线的唯一标识符\n * @param props - 折线的配置属性\n * @returns Promise<void> 添加操作的异步结果\n * @throws 如果地图视图未初始化则抛出错误\n */\n addPolyline: async (id: string, props: PolylineProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addPolyline(id, props);\n },\n /**\n * 移除地图上的指定折线\n * @param id - 要移除的折线的唯一标识符\n * @throws 如果地图视图未初始化,抛出错误\n * @returns Promise<void>\n */\n removePolyline: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removePolyline(id);\n },\n /**\n * 更新地图上的折线覆盖物\n * \n * @param id 要更新的折线覆盖物的唯一标识符\n * @param props 要更新的折线属性,包含部分PolylineProps属性\n * @returns Promise<void> 异步操作结果\n * @throws 如果地图视图未初始化,抛出错误\n */\n updatePolyline: async (id: string, props: Partial<PolylineProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updatePolyline(id, props);\n },\n /**\n * 向地图添加多边形覆盖物\n * @param id - 多边形的唯一标识符\n * @param props - 多边形的配置属性\n * @returns Promise<void> 添加操作的异步结果\n * @throws 如果地图视图未初始化则抛出错误\n */\n addPolygon: async (id: string, props: PolygonProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addPolygon(id, props);\n },\n /**\n * 移除地图上的多边形覆盖物\n * @param id - 要移除的多边形覆盖物的唯一标识符\n * @throws 如果地图视图未初始化,抛出错误 'MapView not initialized'\n * @returns Promise<void> 异步操作完成\n */\n removePolygon: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removePolygon(id);\n },\n /**\n * 更新多边形覆盖物的属性\n * \n * @param id - 要更新的多边形覆盖物的唯一标识符\n * @param props - 要更新的多边形属性对象,包含需要更新的部分属性\n * @throws {Error} 当地图视图未初始化时抛出错误\n * @returns Promise<void> 异步操作完成后的Promise\n */\n updatePolygon: async (id: string, props: Partial<PolygonProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updatePolygon(id, props);\n },\n }), []);\n\n /**\n * 将传入的apiRef赋值给internalRef.current\n * 用于在组件内部保存对地图API实例的引用\n */\n React.useEffect(() => {\n internalRef.current = apiRef;\n }, [apiRef]);\n\n /**\n * 获取当前地图实例的API引用\n * @returns 返回地图API的引用对象,可用于调用地图相关方法\n */\n React.useImperativeHandle(ref, () => apiRef, [apiRef]);\n\n return (\n <MapContext.Provider value={internalRef}>\n <MarkerEventContext.Provider value={markerEventManager}>\n <CircleEventContext.Provider value={circleEventManager}>\n <NativeView\n ref={nativeRef}\n {...props}\n onMarkerPress={handleMarkerPress}\n onMarkerDragStart={handleMarkerDragStart}\n onMarkerDrag={handleMarkerDrag}\n onMarkerDragEnd={handleMarkerDragEnd}\n onCirclePress={handleCirclePress}\n >\n {props.children}\n </NativeView>\n </CircleEventContext.Provider>\n </MarkerEventContext.Provider>\n </MapContext.Provider>\n );\n});\n\nExpoGaodeMapView.displayName = 'ExpoGaodeMapView';\n\nexport default ExpoGaodeMapView;\n"]}
@@ -1,18 +1,3 @@
1
1
  import type { CircleProps } from '../../types';
2
- /**
3
- * 地图圆形组件
4
- *
5
- * @example
6
- * ```tsx
7
- * <MapView>
8
- * <Circle
9
- * center={{ latitude: 39.9, longitude: 116.4 }}
10
- * radius={1000}
11
- * fillColor={0x440000FF}
12
- * strokeColor={0xFFFF0000}
13
- * />
14
- * </MapView>
15
- * ```
16
- */
17
2
  export default function Circle(props: CircleProps): null;
18
3
  //# sourceMappingURL=Circle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Circle.d.ts","sourceRoot":"","sources":["../../../src/components/overlays/Circle.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,WAAW,QA0ChD"}
1
+ {"version":3,"file":"Circle.d.ts","sourceRoot":"","sources":["../../../src/components/overlays/Circle.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,WAAW,QAkDhD"}
@@ -1,63 +1,45 @@
1
- /*
2
- * @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
3
- * @Date : 2025-11-13 15:02:00
4
- * @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
5
- * @LastEditTime : 2025-11-13 18:43:00
6
- * @FilePath : /expo-gaode-map/src/components/overlays/Circle.tsx
7
- * @Description : 地图圆形组件 - 使用命令式 API
8
- *
9
- * Copyright (c) 2025 by 尚博信_王强, All Rights Reserved.
10
- */
11
1
  import * as React from 'react';
12
- import { MapContext } from '../../ExpoGaodeMapView';
13
- /**
14
- * 地图圆形组件
15
- *
16
- * @example
17
- * ```tsx
18
- * <MapView>
19
- * <Circle
20
- * center={{ latitude: 39.9, longitude: 116.4 }}
21
- * radius={1000}
22
- * fillColor={0x440000FF}
23
- * strokeColor={0xFFFF0000}
24
- * />
25
- * </MapView>
26
- * ```
27
- */
2
+ import { MapContext, CircleEventContext } from '../../ExpoGaodeMapView';
28
3
  export default function Circle(props) {
29
4
  const mapRef = React.useContext(MapContext);
5
+ const eventManager = React.useContext(CircleEventContext);
30
6
  const circleIdRef = React.useRef(null);
31
- console.log('Circle 组件渲染,props:', JSON.stringify(props));
7
+ const propsRef = React.useRef(props);
32
8
  React.useEffect(() => {
33
- console.log('Circle useEffect - 添加圆形到地图');
34
- if (!mapRef?.current) {
35
- console.warn('MapRef 不可用');
36
- return;
37
- }
38
- // 添加圆形
39
- const circleId = `circle_${Date.now()}_${Math.random()}`;
40
- circleIdRef.current = circleId;
41
- mapRef.current.addCircle(circleId, props);
42
- console.log('✅ 圆形已添加:', circleId);
43
- // 清理函数 - 移除圆形
9
+ propsRef.current = props;
10
+ }, [props]);
11
+ React.useEffect(() => {
12
+ const checkAndAdd = () => {
13
+ if (!mapRef?.current) {
14
+ setTimeout(checkAndAdd, 50);
15
+ return;
16
+ }
17
+ const circleId = `circle_${Date.now()}_${Math.random()}`;
18
+ circleIdRef.current = circleId;
19
+ if (eventManager && props.onPress) {
20
+ eventManager.register(circleId, {
21
+ onPress: props.onPress,
22
+ });
23
+ }
24
+ mapRef.current.addCircle(circleId, propsRef.current);
25
+ };
26
+ checkAndAdd();
44
27
  return () => {
45
- console.log('Circle useEffect cleanup - 移除圆形');
46
- if (circleIdRef.current && mapRef?.current) {
47
- mapRef.current.removeCircle(circleIdRef.current);
48
- console.log('✅ 圆形已移除:', circleIdRef.current);
28
+ if (circleIdRef.current) {
29
+ if (eventManager) {
30
+ eventManager.unregister(circleIdRef.current);
31
+ }
32
+ if (mapRef?.current) {
33
+ mapRef.current.removeCircle(circleIdRef.current);
34
+ }
49
35
  }
50
36
  };
51
37
  }, []);
52
- // 当 props 变化时更新圆形
53
38
  React.useEffect(() => {
54
- console.log('Circle props 变化,更新圆形');
55
39
  if (circleIdRef.current && mapRef?.current) {
56
40
  mapRef.current.updateCircle(circleIdRef.current, props);
57
- console.log('✅ 圆形已更新:', circleIdRef.current);
58
41
  }
59
42
  }, [props.center, props.radius, props.fillColor, props.strokeColor, props.strokeWidth]);
60
- // 不渲染任何 UI
61
43
  return null;
62
44
  }
63
45
  //# sourceMappingURL=Circle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Circle.js","sourceRoot":"","sources":["../../../src/components/overlays/Circle.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;A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ACnB,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QACpC,IAAI,WAAW,CAAC,OAAO,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YAC3C,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YACxD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAExF,WAAW;IACX,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/*\n * @Author : 尚博信_王强 wangqiang03@sunboxsoft.com\n * @Date : 2025-11-13 15:02:00\n * @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com\n * @LastEditTime : 2025-11-13 18:43:00\n * @FilePath : /expo-gaode-map/src/components/overlays/Circle.tsx\n * @Description : 地图圆形组件 - 使用命令式 API\n * \n * Copyright (c) 2025 by 尚博信_王强, All Rights Reserved. \n */\n\nimport * as React from 'react';\nimport type { CircleProps } from '../../types';\nimport { MapContext } from '../../ExpoGaodeMapView';\n\n/**\n * 地图圆形组件\n * \n * @example\n * ```tsx\n * <MapView>\n * <Circle\n * center={{ latitude: 39.9, longitude: 116.4 }}\n * radius={1000}\n * fillColor={0x440000FF}\n * strokeColor={0xFFFF0000}\n * />\n * </MapView>\n * ```\n */\nexport default function Circle(props: CircleProps) {\n const mapRef = React.useContext(MapContext);\n const circleIdRef = React.useRef<string | null>(null);\n \n console.log('Circle 组件渲染,props:', JSON.stringify(props));\n \n React.useEffect(() => {\n console.log('Circle useEffect - 添加圆形到地图');\n \n if (!mapRef?.current) {\n console.warn('MapRef 不可用');\n return;\n }\n \n // 添加圆形\n const circleId = `circle_${Date.now()}_${Math.random()}`;\n circleIdRef.current = circleId;\n \n mapRef.current.addCircle(circleId, props);\n console.log('✅ 圆形已添加:', circleId);\n \n // 清理函数 - 移除圆形\n return () => {\n console.log('Circle useEffect cleanup - 移除圆形');\n if (circleIdRef.current && mapRef?.current) {\n mapRef.current.removeCircle(circleIdRef.current);\n console.log('✅ 圆形已移除:', circleIdRef.current);\n }\n };\n }, []);\n \n // 当 props 变化时更新圆形\n React.useEffect(() => {\n console.log('Circle props 变化,更新圆形');\n if (circleIdRef.current && mapRef?.current) {\n mapRef.current.updateCircle(circleIdRef.current, props);\n console.log('✅ 圆形已更新:', circleIdRef.current);\n }\n }, [props.center, props.radius, props.fillColor, props.strokeColor, props.strokeWidth]);\n \n // 不渲染任何 UI\n return null;\n}\n"]}
1
+ {"version":3,"file":"Circle.js","sourceRoot":"","sources":["../../../src/components/overlays/Circle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAExE,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAkB;IAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,YAAY,GAAG,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAC1D,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAgB,IAAI,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAErC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;IAC3B,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,WAAW,GAAG,GAAG,EAAE;YACvB,IAAI,CAAC,MAAM,EAAE,OAAO,EA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AC,CAAC,CAAC;IAExF,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import * as React from 'react';\nimport type { CircleProps } from '../../types';\nimport { MapContext, CircleEventContext } from '../../ExpoGaodeMapView';\n\nexport default function Circle(props: CircleProps) {\n const mapRef = React.useContext(MapContext);\n const eventManager = React.useContext(CircleEventContext);\n const circleIdRef = React.useRef<string | null>(null);\n const propsRef = React.useRef(props);\n \n React.useEffect(() => {\n propsRef.current = props;\n }, [props]);\n \n React.useEffect(() => {\n const checkAndAdd = () => {\n if (!mapRef?.current) {\n setTimeout(checkAndAdd, 50);\n return;\n }\n \n const circleId = `circle_${Date.now()}_${Math.random()}`;\n circleIdRef.current = circleId;\n \n if (eventManager && props.onPress) {\n eventManager.register(circleId, {\n onPress: props.onPress,\n });\n }\n \n mapRef.current.addCircle(circleId, propsRef.current);\n };\n \n checkAndAdd();\n \n return () => {\n if (circleIdRef.current) {\n if (eventManager) {\n eventManager.unregister(circleIdRef.current);\n }\n if (mapRef?.current) {\n mapRef.current.removeCircle(circleIdRef.current);\n }\n }\n };\n }, []);\n\n React.useEffect(() => {\n if (circleIdRef.current && mapRef?.current) {\n mapRef.current.updateCircle(circleIdRef.current, props);\n }\n }, [props.center, props.radius, props.fillColor, props.strokeColor, props.strokeWidth]);\n \n return null;\n}\n"]}