expo-gaode-map 1.0.1 → 1.0.2

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 (81) hide show
  1. package/build/ExpoGaodeMap.types.d.ts.map +1 -1
  2. package/build/ExpoGaodeMap.types.js +0 -10
  3. package/build/ExpoGaodeMap.types.js.map +1 -1
  4. package/build/ExpoGaodeMapModule.d.ts.map +1 -1
  5. package/build/ExpoGaodeMapModule.js +0 -10
  6. package/build/ExpoGaodeMapModule.js.map +1 -1
  7. package/build/ExpoGaodeMapView.d.ts +13 -19
  8. package/build/ExpoGaodeMapView.d.ts.map +1 -1
  9. package/build/ExpoGaodeMapView.js +133 -30
  10. package/build/ExpoGaodeMapView.js.map +1 -1
  11. package/build/components/overlays/Circle.d.ts +17 -12
  12. package/build/components/overlays/Circle.d.ts.map +1 -1
  13. package/build/components/overlays/Circle.js +22 -23
  14. package/build/components/overlays/Circle.js.map +1 -1
  15. package/build/components/overlays/Cluster.d.ts +3 -15
  16. package/build/components/overlays/Cluster.d.ts.map +1 -1
  17. package/build/components/overlays/Cluster.js +3 -25
  18. package/build/components/overlays/Cluster.js.map +1 -1
  19. package/build/components/overlays/HeatMap.d.ts +3 -14
  20. package/build/components/overlays/HeatMap.d.ts.map +1 -1
  21. package/build/components/overlays/HeatMap.js +3 -24
  22. package/build/components/overlays/HeatMap.js.map +1 -1
  23. package/build/components/overlays/Marker.d.ts +12 -11
  24. package/build/components/overlays/Marker.d.ts.map +1 -1
  25. package/build/components/overlays/Marker.js +12 -21
  26. package/build/components/overlays/Marker.js.map +1 -1
  27. package/build/components/overlays/MultiPoint.d.ts +3 -14
  28. package/build/components/overlays/MultiPoint.d.ts.map +1 -1
  29. package/build/components/overlays/MultiPoint.js +3 -24
  30. package/build/components/overlays/MultiPoint.js.map +1 -1
  31. package/build/components/overlays/Polygon.d.ts +13 -16
  32. package/build/components/overlays/Polygon.d.ts.map +1 -1
  33. package/build/components/overlays/Polygon.js +13 -26
  34. package/build/components/overlays/Polygon.js.map +1 -1
  35. package/build/components/overlays/Polyline.d.ts +12 -14
  36. package/build/components/overlays/Polyline.d.ts.map +1 -1
  37. package/build/components/overlays/Polyline.js +12 -24
  38. package/build/components/overlays/Polyline.js.map +1 -1
  39. package/build/components/overlays/index.d.ts.map +1 -1
  40. package/build/components/overlays/index.js +0 -10
  41. package/build/components/overlays/index.js.map +1 -1
  42. package/build/index.d.ts.map +1 -1
  43. package/build/index.js +0 -10
  44. package/build/index.js.map +1 -1
  45. package/build/modules/AMapLocation.d.ts +47 -10
  46. package/build/modules/AMapLocation.d.ts.map +1 -1
  47. package/build/modules/AMapLocation.js +48 -20
  48. package/build/modules/AMapLocation.js.map +1 -1
  49. package/build/modules/AMapPermissions.d.ts +3 -1
  50. package/build/modules/AMapPermissions.d.ts.map +1 -1
  51. package/build/modules/AMapPermissions.js +3 -11
  52. package/build/modules/AMapPermissions.js.map +1 -1
  53. package/build/modules/AMapSDK.d.ts +5 -4
  54. package/build/modules/AMapSDK.d.ts.map +1 -1
  55. package/build/modules/AMapSDK.js +5 -14
  56. package/build/modules/AMapSDK.js.map +1 -1
  57. package/build/modules/AMapView.d.ts.map +1 -1
  58. package/build/modules/AMapView.js +0 -8
  59. package/build/modules/AMapView.js.map +1 -1
  60. package/build/types/index.d.ts.map +1 -1
  61. package/build/types/index.js +0 -10
  62. package/build/types/index.js.map +1 -1
  63. package/docs/RELEASE_GUIDE.md +178 -0
  64. package/package.json +1 -1
  65. package/src/ExpoGaodeMap.types.ts +1 -10
  66. package/src/ExpoGaodeMapModule.ts +1 -10
  67. package/src/ExpoGaodeMapView.tsx +139 -37
  68. package/src/components/overlays/Circle.tsx +24 -25
  69. package/src/components/overlays/Cluster.tsx +4 -26
  70. package/src/components/overlays/HeatMap.tsx +4 -25
  71. package/src/components/overlays/Marker.tsx +12 -22
  72. package/src/components/overlays/MultiPoint.tsx +4 -25
  73. package/src/components/overlays/Polygon.tsx +14 -28
  74. package/src/components/overlays/Polyline.tsx +13 -25
  75. package/src/components/overlays/index.ts +0 -11
  76. package/src/index.ts +0 -11
  77. package/src/modules/AMapLocation.ts +56 -20
  78. package/src/modules/AMapPermissions.ts +4 -11
  79. package/src/modules/AMapSDK.ts +7 -14
  80. package/src/modules/AMapView.ts +0 -8
  81. package/src/types/index.ts +1 -10
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoGaodeMap.types.d.ts","sourceRoot":"","sources":["../src/ExpoGaodeMap.types.ts"],"names":[],"mappings":"AAYA,cAAc,SAAS,CAAC;AAGxB,YAAY,EAEV,MAAM,EACN,KAAK,EACL,cAAc,EACd,YAAY,EACZ,MAAM,EAGN,YAAY,EACZ,WAAW,EAGX,WAAW,EACX,SAAS,EACT,eAAe,EAGf,WAAW,EACX,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,eAAe,EACf,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,OAAO,EACP,YAAY,EACZ,gBAAgB,EAChB,cAAc,GACf,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,gBAAgB,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC;IAE1C;;OAEG;IACH,eAAe,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACrE,CAAC;AAEF;;GAEG;AACH,YAAY,EAAE,YAAY,IAAI,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"ExpoGaodeMap.types.d.ts","sourceRoot":"","sources":["../src/ExpoGaodeMap.types.ts"],"names":[],"mappings":"AAGA,cAAc,SAAS,CAAC;AAGxB,YAAY,EAEV,MAAM,EACN,KAAK,EACL,cAAc,EACd,YAAY,EACZ,MAAM,EAGN,YAAY,EACZ,WAAW,EAGX,WAAW,EACX,SAAS,EACT,eAAe,EAGf,WAAW,EACX,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,eAAe,EACf,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,OAAO,EACP,YAAY,EACZ,gBAAgB,EAChB,cAAc,GACf,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,gBAAgB,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC;IAE1C;;OAEG;IACH,eAAe,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACrE,CAAC;AAEF;;GAEG;AACH,YAAY,EAAE,YAAY,IAAI,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
@@ -1,13 +1,3 @@
1
- /*
2
- * @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
3
- * @Date : 2025-11-13 14:03:56
4
- * @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
5
- * @LastEditTime : 2025-11-13 14:30:00
6
- * @FilePath : /expo-gaode-map/src/ExpoGaodeMap.types.ts
7
- * @Description : 高德地图 Expo Module 主类型定义文件
8
- *
9
- * Copyright (c) 2025 by 尚博信_王强, All Rights Reserved.
10
- */
11
1
  // 导出所有类型定义
12
2
  export * from './types';
13
3
  export { MapType, LocationMode, LocationAccuracy, CoordinateType, } from './types';
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoGaodeMap.types.js","sourceRoot":"","sources":["../src/ExpoGaodeMap.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,WAAW;AACX,cAAc,SAAS,CAAC;AA8BxB,OAAO,EACL,OAAO,EACP,YAAY,EACZ,gBAAgB,EAChB,cAAc,GACf,MAAM,SAAS,CAAC","sourcesContent":["/*\n * @Author : 尚博信_王强 wangqiang03@sunboxsoft.com\n * @Date : 2025-11-13 14:03:56\n * @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com\n * @LastEditTime : 2025-11-13 14:30:00\n * @FilePath : /expo-gaode-map/src/ExpoGaodeMap.types.ts\n * @Description : 高德地图 Expo Module 主类型定义文件\n * \n * Copyright (c) 2025 by 尚博信_王强, All Rights Reserved. \n */\n\n// 导出所有类型定义\nexport * from './types';\n\n// 重新导出常用类型,方便直接从主模块导入\nexport type {\n // 通用类型\n LatLng,\n Point,\n CameraPosition,\n LatLngBounds,\n MapPoi,\n \n // 地图视图\n MapViewProps,\n CameraEvent,\n \n // 定位\n Coordinates,\n ReGeocode,\n LocationOptions,\n \n // 覆盖物\n MarkerProps,\n PolylineProps,\n PolygonProps,\n CircleProps,\n HeatMapProps,\n MultiPointProps,\n ClusterProps,\n} from './types';\n\nexport {\n MapType,\n LocationMode,\n LocationAccuracy,\n CoordinateType,\n} from './types';\n\n/**\n * Expo 模块事件类型\n */\nexport type ExpoGaodeMapModuleEvents = {\n /**\n * 定位更新事件\n */\n onLocationUpdate: (location: any) => void;\n \n /**\n * 定位错误事件\n */\n onLocationError: (error: { code: number; message: string }) => void;\n};\n\n/**\n * Expo 地图视图属性(用于主视图组件)\n */\nexport type { MapViewProps as ExpoGaodeMapViewProps } from './types';\n"]}
1
+ {"version":3,"file":"ExpoGaodeMap.types.js","sourceRoot":"","sources":["../src/ExpoGaodeMap.types.ts"],"names":[],"mappings":"AAEA,WAAW;AACX,cAAc,SAAS,CAAC;AA8BxB,OAAO,EACL,OAAO,EACP,YAAY,EACZ,gBAAgB,EAChB,cAAc,GACf,MAAM,SAAS,CAAC","sourcesContent":["\n\n// 导出所有类型定义\nexport * from './types';\n\n// 重新导出常用类型,方便直接从主模块导入\nexport type {\n // 通用类型\n LatLng,\n Point,\n CameraPosition,\n LatLngBounds,\n MapPoi,\n \n // 地图视图\n MapViewProps,\n CameraEvent,\n \n // 定位\n Coordinates,\n ReGeocode,\n LocationOptions,\n \n // 覆盖物\n MarkerProps,\n PolylineProps,\n PolygonProps,\n CircleProps,\n HeatMapProps,\n MultiPointProps,\n ClusterProps,\n} from './types';\n\nexport {\n MapType,\n LocationMode,\n LocationAccuracy,\n CoordinateType,\n} from './types';\n\n/**\n * Expo 模块事件类型\n */\nexport type ExpoGaodeMapModuleEvents = {\n /**\n * 定位更新事件\n */\n onLocationUpdate: (location: any) => void;\n \n /**\n * 定位错误事件\n */\n onLocationError: (error: { code: number; message: string }) => void;\n};\n\n/**\n * Expo 地图视图属性(用于主视图组件)\n */\nexport type { MapViewProps as ExpoGaodeMapViewProps } from './types';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoGaodeMapModule.d.ts","sourceRoot":"","sources":["../src/ExpoGaodeMapModule.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AACzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGrE,OAAO,OAAO,kBAAmB,SAAQ,YAAY,CAAC,wBAAwB,CAAC;CAG9E;;AAGD,wBAAuE"}
1
+ {"version":3,"file":"ExpoGaodeMapModule.d.ts","sourceRoot":"","sources":["../src/ExpoGaodeMapModule.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AACzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGrE,OAAO,OAAO,kBAAmB,SAAQ,YAAY,CAAC,wBAAwB,CAAC;CAG9E;;AAGD,wBAAuE"}
@@ -1,13 +1,3 @@
1
- /*
2
- * @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
3
- * @Date : 2025-11-13 14:03:56
4
- * @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
5
- * @LastEditTime : 2025-11-13 14:58:00
6
- * @FilePath : /expo-gaode-map/src/ExpoGaodeMapModule.ts
7
- * @Description :
8
- *
9
- * Copyright (c) 2025 by 尚博信_王强, All Rights Reserved.
10
- */
11
1
  import { requireNativeModule } from 'expo';
12
2
  // This call loads the native module object from the JSI.
13
3
  export default requireNativeModule('ExpoGaodeMap');
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoGaodeMapModule.js","sourceRoot":"","sources":["../src/ExpoGaodeMapModule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AASzD,yDAAyD;AACzD,eAAe,mBAAmB,CAAqB,cAAc,CAAC,CAAC","sourcesContent":["/*\n * @Author : 尚博信_王强 wangqiang03@sunboxsoft.com\n * @Date : 2025-11-13 14:03:56\n * @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com\n * @LastEditTime : 2025-11-13 14:58:00\n * @FilePath : /expo-gaode-map/src/ExpoGaodeMapModule.ts\n * @Description : \n * \n * Copyright (c) 2025 by 尚博信_王强, All Rights Reserved. \n */\nimport { NativeModule, requireNativeModule } from 'expo';\nimport type { ExpoGaodeMapModuleEvents } from './ExpoGaodeMap.types';\n\n\ndeclare class ExpoGaodeMapModule extends NativeModule<ExpoGaodeMapModuleEvents> {\n // 地图控制方法已移至 MapView 的 ref 调用\n // 使用方式: mapRef.current.moveCamera() 等\n}\n\n// This call loads the native module object from the JSI.\nexport default requireNativeModule<ExpoGaodeMapModule>('ExpoGaodeMap');\n"]}
1
+ {"version":3,"file":"ExpoGaodeMapModule.js","sourceRoot":"","sources":["../src/ExpoGaodeMapModule.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AASzD,yDAAyD;AACzD,eAAe,mBAAmB,CAAqB,cAAc,CAAC,CAAC","sourcesContent":["\nimport { NativeModule, requireNativeModule } from 'expo';\nimport type { ExpoGaodeMapModuleEvents } from './ExpoGaodeMap.types';\n\n\ndeclare class ExpoGaodeMapModule extends NativeModule<ExpoGaodeMapModuleEvents> {\n // 地图控制方法已移至 MapView 的 ref 调用\n // 使用方式: mapRef.current.moveCamera() 等\n}\n\n// This call loads the native module object from the JSI.\nexport default requireNativeModule<ExpoGaodeMapModule>('ExpoGaodeMap');\n"]}
@@ -3,28 +3,22 @@ import type { MapViewProps, MapViewRef } from './types';
3
3
  export type { MapViewRef } from './types';
4
4
  export declare const MapContext: React.Context<React.RefObject<MapViewRef | null> | null>;
5
5
  /**
6
- * 高德地图视图组件
6
+ * 高德地图视图组件,提供地图操作API和覆盖物管理功能
7
7
  *
8
- * @example
9
- * ```tsx
10
- * import { MapView } from 'expo-gaode-map';
8
+ * @param props - 组件属性
9
+ * @param ref - 外部ref引用,用于访问地图API方法
10
+ * @returns 返回包含地图视图和上下文提供者的React组件
11
11
  *
12
- * function MyMap() {
13
- * const mapRef = React.useRef(null);
12
+ * @remarks
13
+ * 该组件内部维护两个ref:
14
+ * - nativeRef: 指向原生地图视图的引用
15
+ * - internalRef: 内部使用的API引用,通过MapContext共享
14
16
  *
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
- * ```
17
+ * 提供的主要API功能包括:
18
+ * - 相机控制(移动、缩放、获取当前位置)
19
+ * - 覆盖物管理(添加/删除/更新标记、折线、多边形、圆形等)
20
+ *
21
+ * 所有API方法都会检查地图是否已初始化,未初始化时抛出错误
28
22
  */
29
23
  declare const ExpoGaodeMapView: React.ForwardRefExoticComponent<MapViewProps & React.RefAttributes<MapViewRef>>;
30
24
  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,EASX,MAAM,SAAS,CAAC;AAGjB,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK1C,eAAO,MAAM,UAAU,0DAAuE,CAAC;AAE/F;;;;;;;;;;;;;;;;;GAiBG;AACH,QAAA,MAAM,gBAAgB,iFA8MpB,CAAC;AAIH,eAAe,gBAAgB,CAAC"}
@@ -1,136 +1,239 @@
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);
16
6
  /**
17
- * 高德地图视图组件
7
+ * 高德地图视图组件,提供地图操作API和覆盖物管理功能
8
+ *
9
+ * @param props - 组件属性
10
+ * @param ref - 外部ref引用,用于访问地图API方法
11
+ * @returns 返回包含地图视图和上下文提供者的React组件
18
12
  *
19
- * @example
20
- * ```tsx
21
- * import { MapView } from 'expo-gaode-map';
13
+ * @remarks
14
+ * 该组件内部维护两个ref:
15
+ * - nativeRef: 指向原生地图视图的引用
16
+ * - internalRef: 内部使用的API引用,通过MapContext共享
22
17
  *
23
- * function MyMap() {
24
- * const mapRef = React.useRef(null);
18
+ * 提供的主要API功能包括:
19
+ * - 相机控制(移动、缩放、获取当前位置)
20
+ * - 覆盖物管理(添加/删除/更新标记、折线、多边形、圆形等)
25
21
  *
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
- * ```
22
+ * 所有API方法都会检查地图是否已初始化,未初始化时抛出错误
39
23
  */
40
24
  const ExpoGaodeMapView = React.forwardRef((props, ref) => {
41
25
  const nativeRef = React.useRef(null);
42
26
  const internalRef = React.useRef(null);
43
27
  const apiRef = React.useMemo(() => ({
28
+ /**
29
+ * 移动地图相机到指定位置
30
+ * @param position 相机位置参数对象,包含目标经纬度、缩放级别等信息
31
+ * @param duration 动画持续时间(毫秒),默认300毫秒
32
+ * @throws 如果地图视图未初始化则抛出错误
33
+ * @returns Promise<void> 异步操作完成后的Promise
34
+ */
44
35
  moveCamera: async (position, duration = 300) => {
45
36
  if (!nativeRef.current)
46
37
  throw new Error('MapView not initialized');
47
38
  return nativeRef.current.moveCamera(position, duration);
48
39
  },
40
+ /**
41
+ * 将屏幕坐标点转换为地理坐标(经纬度)
42
+ * @param point 屏幕坐标点 {x: number, y: number}
43
+ * @returns 返回Promise,解析为对应的地理坐标 {latitude: number, longitude: number}
44
+ * @throws 如果地图视图未初始化,抛出错误 'MapView not initialized'
45
+ */
49
46
  getLatLng: async (point) => {
50
47
  if (!nativeRef.current)
51
48
  throw new Error('MapView not initialized');
52
49
  return nativeRef.current.getLatLng(point);
53
50
  },
51
+ /**
52
+ * 设置地图中心点坐标
53
+ * @param center 要设置的中心点坐标(LatLng格式)
54
+ * @param animated 是否使用动画效果移动地图(默认为false)
55
+ * @throws 如果地图视图未初始化则抛出错误
56
+ */
54
57
  setCenter: async (center, animated = false) => {
55
58
  if (!nativeRef.current)
56
59
  throw new Error('MapView not initialized');
57
60
  return nativeRef.current.setCenter(center, animated);
58
61
  },
62
+ /**
63
+ * 设置地图的缩放级别
64
+ * @param zoom 目标缩放级别
65
+ * @param animated 是否使用动画过渡效果,默认为false
66
+ * @throws 如果地图视图未初始化,抛出错误
67
+ */
59
68
  setZoom: async (zoom, animated = false) => {
60
69
  if (!nativeRef.current)
61
70
  throw new Error('MapView not initialized');
62
71
  return nativeRef.current.setZoom(zoom, animated);
63
72
  },
73
+ /**
74
+ * 获取当前地图的相机位置(视角中心点、缩放级别、倾斜角度等)
75
+ * @returns 返回一个Promise,解析为当前相机位置的对象
76
+ * @throws 如果地图视图未初始化,则抛出错误
77
+ */
64
78
  getCameraPosition: async () => {
65
79
  if (!nativeRef.current)
66
80
  throw new Error('MapView not initialized');
67
81
  return nativeRef.current.getCameraPosition();
68
82
  },
83
+ /**
84
+ * 在地图上添加圆形覆盖物
85
+ * @param id - 圆形覆盖物的唯一标识符
86
+ * @param props - 圆形覆盖物的属性配置
87
+ * @returns Promise<void> 添加操作的异步结果
88
+ * @throws 如果地图视图未初始化,抛出错误'MapView not initialized'
89
+ */
69
90
  addCircle: async (id, props) => {
70
91
  if (!nativeRef.current)
71
92
  throw new Error('MapView not initialized');
72
93
  return nativeRef.current.addCircle(id, props);
73
94
  },
95
+ /**
96
+ * 从地图上移除指定的圆形覆盖物
97
+ * @param id - 要移除的圆形覆盖物的唯一标识符
98
+ * @throws 如果地图视图未初始化,抛出错误
99
+ * @returns Promise<void> 异步操作完成
100
+ */
74
101
  removeCircle: async (id) => {
75
102
  if (!nativeRef.current)
76
103
  throw new Error('MapView not initialized');
77
104
  return nativeRef.current.removeCircle(id);
78
105
  },
106
+ /**
107
+ * 更新地图上的圆形覆盖物
108
+ * @param id 要更新的圆形覆盖物的唯一标识符
109
+ * @param props 要更新的圆形属性(部分属性)
110
+ * @throws 如果地图视图未初始化,抛出错误
111
+ * @returns Promise<void> 表示更新操作完成
112
+ */
79
113
  updateCircle: async (id, props) => {
80
114
  if (!nativeRef.current)
81
115
  throw new Error('MapView not initialized');
82
116
  return nativeRef.current.updateCircle(id, props);
83
117
  },
118
+ /**
119
+ * 添加一个标记点到地图上
120
+ * @param id 标记点的唯一标识符
121
+ * @param props 标记点的配置属性
122
+ * @returns Promise<void> 添加操作完成后的Promise
123
+ * @throws 如果地图视图未初始化则抛出错误
124
+ */
84
125
  addMarker: async (id, props) => {
85
126
  if (!nativeRef.current)
86
127
  throw new Error('MapView not initialized');
87
128
  return nativeRef.current.addMarker(id, props);
88
129
  },
130
+ /**
131
+ * 从地图上移除指定ID的标记点
132
+ * @param id 要移除的标记点ID
133
+ * @throws 如果地图视图未初始化则抛出错误
134
+ * @returns Promise<void> 异步操作完成
135
+ */
89
136
  removeMarker: async (id) => {
90
137
  if (!nativeRef.current)
91
138
  throw new Error('MapView not initialized');
92
139
  return nativeRef.current.removeMarker(id);
93
140
  },
141
+ /**
142
+ * 更新地图上指定ID的标记点属性
143
+ * @param id - 要更新的标记点唯一标识符
144
+ * @param props - 需要更新的标记点属性对象(部分属性)
145
+ * @throws 如果地图视图未初始化则抛出错误
146
+ * @returns Promise对象,表示异步更新操作
147
+ */
94
148
  updateMarker: async (id, props) => {
95
149
  if (!nativeRef.current)
96
150
  throw new Error('MapView not initialized');
97
151
  return nativeRef.current.updateMarker(id, props);
98
152
  },
153
+ /**
154
+ * 添加折线覆盖物到地图
155
+ * @param id - 折线的唯一标识符
156
+ * @param props - 折线的配置属性
157
+ * @returns Promise<void> 添加操作的异步结果
158
+ * @throws 如果地图视图未初始化则抛出错误
159
+ */
99
160
  addPolyline: async (id, props) => {
100
161
  if (!nativeRef.current)
101
162
  throw new Error('MapView not initialized');
102
163
  return nativeRef.current.addPolyline(id, props);
103
164
  },
165
+ /**
166
+ * 移除地图上的指定折线
167
+ * @param id - 要移除的折线的唯一标识符
168
+ * @throws 如果地图视图未初始化,抛出错误
169
+ * @returns Promise<void>
170
+ */
104
171
  removePolyline: async (id) => {
105
172
  if (!nativeRef.current)
106
173
  throw new Error('MapView not initialized');
107
174
  return nativeRef.current.removePolyline(id);
108
175
  },
176
+ /**
177
+ * 更新地图上的折线覆盖物
178
+ *
179
+ * @param id 要更新的折线覆盖物的唯一标识符
180
+ * @param props 要更新的折线属性,包含部分PolylineProps属性
181
+ * @returns Promise<void> 异步操作结果
182
+ * @throws 如果地图视图未初始化,抛出错误
183
+ */
109
184
  updatePolyline: async (id, props) => {
110
185
  if (!nativeRef.current)
111
186
  throw new Error('MapView not initialized');
112
187
  return nativeRef.current.updatePolyline(id, props);
113
188
  },
189
+ /**
190
+ * 向地图添加多边形覆盖物
191
+ * @param id - 多边形的唯一标识符
192
+ * @param props - 多边形的配置属性
193
+ * @returns Promise<void> 添加操作的异步结果
194
+ * @throws 如果地图视图未初始化则抛出错误
195
+ */
114
196
  addPolygon: async (id, props) => {
115
197
  if (!nativeRef.current)
116
198
  throw new Error('MapView not initialized');
117
199
  return nativeRef.current.addPolygon(id, props);
118
200
  },
201
+ /**
202
+ * 移除地图上的多边形覆盖物
203
+ * @param id - 要移除的多边形覆盖物的唯一标识符
204
+ * @throws 如果地图视图未初始化,抛出错误 'MapView not initialized'
205
+ * @returns Promise<void> 异步操作完成
206
+ */
119
207
  removePolygon: async (id) => {
120
208
  if (!nativeRef.current)
121
209
  throw new Error('MapView not initialized');
122
210
  return nativeRef.current.removePolygon(id);
123
211
  },
212
+ /**
213
+ * 更新多边形覆盖物的属性
214
+ *
215
+ * @param id - 要更新的多边形覆盖物的唯一标识符
216
+ * @param props - 要更新的多边形属性对象,包含需要更新的部分属性
217
+ * @throws {Error} 当地图视图未初始化时抛出错误
218
+ * @returns Promise<void> 异步操作完成后的Promise
219
+ */
124
220
  updatePolygon: async (id, props) => {
125
221
  if (!nativeRef.current)
126
222
  throw new Error('MapView not initialized');
127
223
  return nativeRef.current.updatePolygon(id, props);
128
224
  },
129
225
  }), []);
130
- // 设置 internalRef 和外部 ref
226
+ /**
227
+ * 将传入的apiRef赋值给internalRef.current
228
+ * 用于在组件内部保存对地图API实例的引用
229
+ */
131
230
  React.useEffect(() => {
132
231
  internalRef.current = apiRef;
133
232
  }, [apiRef]);
233
+ /**
234
+ * 获取当前地图实例的API引用
235
+ * @returns 返回地图API的引用对象,可用于调用地图相关方法
236
+ */
134
237
  React.useImperativeHandle(ref, () => apiRef, [apiRef]);
135
238
  return (<MapContext.Provider value={internalRef}>
136
239
  <NativeView ref={nativeRef} {...props}/>
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoGaodeMapView.js","sourceRoot":"","sources":["../src/ExpoGaodeMapView.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,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;AAE/F;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,gBAAgB,GAAG,KAAK,CAAC,UAAU,CAA2B,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACjF,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAmB,IAAI,CAAC,CAAC;IACvD,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAoB,IAAI,CAAC,CAAC;IAE1D,MAAM,MAAM,GAAe,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC9C,UAAU,EAAE,KAAK,EAAE,QAAwB,EAAE,WAAmB,GAAG,EAAE,EAAE;YACrE,IAAI,CAAC,SAAS,CAAC,OA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AK,CAAC,yBAAyB,CAAC,CAAC;YACnE,OAAO,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACpD,CAAC;KACF,CAAC,EAAE,EAAE,CAAC,CAAC;IAER,yBAAyB;IACzB,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,WAAW,CAAC,OAAO,GAAG,MAAM,CAAC;IAC/B,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,KAAK,CAAC,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEvD,OAAO,CACL,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,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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AmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEvD,OAAO,CACL,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,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":["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/**\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\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 <NativeView ref={nativeRef} {...props} />\n </MapContext.Provider>\n );\n});\n\nExpoGaodeMapView.displayName = 'ExpoGaodeMapView';\n\nexport default ExpoGaodeMapView;\n"]}
@@ -1,18 +1,23 @@
1
1
  import type { CircleProps } from '../../types';
2
2
  /**
3
- * 地图圆形组件
3
+ * Circle 组件 - 高德地图圆形覆盖物
4
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
- * ```
5
+ * 该组件用于在高德地图上绘制圆形覆盖物,支持动态更新圆形属性。
6
+ *
7
+ * @param {CircleProps} props - 圆形属性配置
8
+ * @param {LatLng} props.center - 圆形中心点坐标
9
+ * @param {number} props.radius - 圆形半径(米)
10
+ * @param {string} props.fillColor - 填充颜色(十六进制或RGBA)
11
+ * @param {string} props.strokeColor - 边框颜色(十六进制或RGBA)
12
+ * @param {number} props.strokeWidth - 边框宽度(像素)
13
+ *
14
+ * @returns {null} 该组件不渲染任何UI元素
15
+ *
16
+ * @remarks
17
+ * 1. 组件挂载时自动添加圆形到地图
18
+ * 2. 组件卸载时自动移除圆形
19
+ * 3. 当中心点、半径、颜色等属性变化时自动更新圆形
20
+ * 4. 使用 React Context 获取地图实例引用
16
21
  */
17
22
  export default function Circle(props: CircleProps): null;
18
23
  //# 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;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,WAAW,QA+ChD"}
@@ -1,29 +1,24 @@
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
2
  import { MapContext } from '../../ExpoGaodeMapView';
13
3
  /**
14
- * 地图圆形组件
4
+ * Circle 组件 - 高德地图圆形覆盖物
5
+ *
6
+ * 该组件用于在高德地图上绘制圆形覆盖物,支持动态更新圆形属性。
7
+ *
8
+ * @param {CircleProps} props - 圆形属性配置
9
+ * @param {LatLng} props.center - 圆形中心点坐标
10
+ * @param {number} props.radius - 圆形半径(米)
11
+ * @param {string} props.fillColor - 填充颜色(十六进制或RGBA)
12
+ * @param {string} props.strokeColor - 边框颜色(十六进制或RGBA)
13
+ * @param {number} props.strokeWidth - 边框宽度(像素)
14
+ *
15
+ * @returns {null} 该组件不渲染任何UI元素
15
16
  *
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
- * ```
17
+ * @remarks
18
+ * 1. 组件挂载时自动添加圆形到地图
19
+ * 2. 组件卸载时自动移除圆形
20
+ * 3. 当中心点、半径、颜色等属性变化时自动更新圆形
21
+ * 4. 使用 React Context 获取地图实例引用
27
22
  */
28
23
  export default function Circle(props) {
29
24
  const mapRef = React.useContext(MapContext);
@@ -49,7 +44,11 @@ export default function Circle(props) {
49
44
  }
50
45
  };
51
46
  }, []);
52
- // 当 props 变化时更新圆形
47
+ /**
48
+ * 当Circle组件的props发生变化时,更新地图上的圆形覆盖物
49
+ * 如果圆形ID和地图引用都存在,则调用地图实例的updateCircle方法更新圆形
50
+ * 更新成功后会打印日志确认
51
+ */
53
52
  React.useEffect(() => {
54
53
  console.log('Circle props 变化,更新圆形');
55
54
  if (circleIdRef.current && mapRef?.current) {
@@ -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;AAEpD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAkB;IAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAgB,IAAI,CAAC,CAAC;IAEtD,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAEzD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;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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,MAAM,wBAAwB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAkB;IAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAgB,IAAI,CAAC,CAAC;IAEtD,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAEzD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QAE1C,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC3B,OAAO;QACT,CAAC;QAED,OAAO;QACP,MAAM,QAAQ,GAAG,UAAU,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QACzD,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;QAE/B,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAElC,cAAc;QACd,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;YAC/C,IAAI,WAAW,CAAC,OAAO,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;gBAC3C,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;gBACjD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAGP;;;;OAIG;IACH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,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":["import * as React from 'react';\nimport type { CircleProps } from '../../types';\nimport { MapContext } from '../../ExpoGaodeMapView';\n\n/**\n * Circle 组件 - 高德地图圆形覆盖物\n * \n * 该组件用于在高德地图上绘制圆形覆盖物,支持动态更新圆形属性。\n * \n * @param {CircleProps} props - 圆形属性配置\n * @param {LatLng} props.center - 圆形中心点坐标\n * @param {number} props.radius - 圆形半径(米)\n * @param {string} props.fillColor - 填充颜色(十六进制或RGBA)\n * @param {string} props.strokeColor - 边框颜色(十六进制或RGBA)\n * @param {number} props.strokeWidth - 边框宽度(像素)\n * \n * @returns {null} 该组件不渲染任何UI元素\n * \n * @remarks\n * 1. 组件挂载时自动添加圆形到地图\n * 2. 组件卸载时自动移除圆形\n * 3. 当中心点、半径、颜色等属性变化时自动更新圆形\n * 4. 使用 React Context 获取地图实例引用\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\n /**\n *Circle组件的props发生变化时,更新地图上的圆形覆盖物\n * 如果圆形ID和地图引用都存在,则调用地图实例的updateCircle方法更新圆形\n * 更新成功后会打印日志确认\n */\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,22 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import type { ClusterProps } from '../../types';
3
3
  /**
4
- * 地图点聚合组件
5
- * 将相近的标记点聚合显示,提高大量标记的展示性能
4
+ * 高德地图点聚合组件
6
5
  *
7
- * @example
8
- * ```tsx
9
- * <MapView>
10
- * <Cluster
11
- * points={[
12
- * { latitude: 39.9, longitude: 116.4, id: '1' },
13
- * { latitude: 39.91, longitude: 116.41, id: '2' },
14
- * ]}
15
- * radius={60}
16
- * minClusterSize={2}
17
- * />
18
- * </MapView>
19
- * ```
6
+ * @param props 点聚合组件的属性配置
7
+ * @returns 渲染原生点聚合组件
20
8
  */
21
9
  export default function Cluster(props: ClusterProps): React.JSX.Element;
22
10
  //# sourceMappingURL=Cluster.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Cluster.d.ts","sourceRoot":"","sources":["../../../src/components/overlays/Cluster.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EAAE,YAAY,qBAElD"}
1
+ {"version":3,"file":"Cluster.d.ts","sourceRoot":"","sources":["../../../src/components/overlays/Cluster.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EAAE,YAAY,qBAElD"}
@@ -1,33 +1,11 @@
1
- /*
2
- * @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
3
- * @Date : 2025-11-13 15:02:50
4
- * @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
5
- * @LastEditTime : 2025-11-13 18:19:20
6
- * @FilePath : /expo-gaode-map/src/components/overlays/Cluster.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 NativeCluster = requireNativeViewManager('ExpoGaodeMap_ClusterView');
14
4
  /**
15
- * 地图点聚合组件
16
- * 将相近的标记点聚合显示,提高大量标记的展示性能
5
+ * 高德地图点聚合组件
17
6
  *
18
- * @example
19
- * ```tsx
20
- * <MapView>
21
- * <Cluster
22
- * points={[
23
- * { latitude: 39.9, longitude: 116.4, id: '1' },
24
- * { latitude: 39.91, longitude: 116.41, id: '2' },
25
- * ]}
26
- * radius={60}
27
- * minClusterSize={2}
28
- * />
29
- * </MapView>
30
- * ```
7
+ * @param props 点聚合组件的属性配置
8
+ * @returns 渲染原生点聚合组件
31
9
  */
32
10
  export default function Cluster(props) {
33
11
  return <NativeCluster {...props}/>;