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.
- package/README.md +1 -0
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapModule.kt +17 -1
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapView.kt +52 -5
- package/android/src/main/java/expo/modules/gaodemap/managers/OverlayManager.kt +184 -6
- package/android/src/main/java/expo/modules/gaodemap/overlays/CircleView.kt +24 -51
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerView.kt +3 -0
- package/build/ExpoGaodeMap.types.d.ts.map +1 -1
- package/build/ExpoGaodeMap.types.js +0 -10
- package/build/ExpoGaodeMap.types.js.map +1 -1
- package/build/ExpoGaodeMapModule.d.ts.map +1 -1
- package/build/ExpoGaodeMapModule.js +0 -10
- package/build/ExpoGaodeMapModule.js.map +1 -1
- package/build/ExpoGaodeMapView.d.ts +39 -20
- package/build/ExpoGaodeMapView.d.ts.map +1 -1
- package/build/ExpoGaodeMapView.js +215 -31
- package/build/ExpoGaodeMapView.js.map +1 -1
- package/build/components/overlays/Circle.d.ts +0 -15
- package/build/components/overlays/Circle.d.ts.map +1 -1
- package/build/components/overlays/Circle.js +28 -46
- package/build/components/overlays/Circle.js.map +1 -1
- package/build/components/overlays/Cluster.d.ts +3 -15
- package/build/components/overlays/Cluster.d.ts.map +1 -1
- package/build/components/overlays/Cluster.js +3 -25
- package/build/components/overlays/Cluster.js.map +1 -1
- package/build/components/overlays/HeatMap.d.ts +3 -14
- package/build/components/overlays/HeatMap.d.ts.map +1 -1
- package/build/components/overlays/HeatMap.js +3 -24
- package/build/components/overlays/HeatMap.js.map +1 -1
- package/build/components/overlays/Marker.d.ts +2 -15
- package/build/components/overlays/Marker.d.ts.map +1 -1
- package/build/components/overlays/Marker.js +60 -46
- package/build/components/overlays/Marker.js.map +1 -1
- package/build/components/overlays/MultiPoint.d.ts +3 -14
- package/build/components/overlays/MultiPoint.d.ts.map +1 -1
- package/build/components/overlays/MultiPoint.js +3 -24
- package/build/components/overlays/MultiPoint.js.map +1 -1
- package/build/components/overlays/Polygon.d.ts +13 -16
- package/build/components/overlays/Polygon.d.ts.map +1 -1
- package/build/components/overlays/Polygon.js +41 -75
- package/build/components/overlays/Polygon.js.map +1 -1
- package/build/components/overlays/Polyline.d.ts +12 -14
- package/build/components/overlays/Polyline.d.ts.map +1 -1
- package/build/components/overlays/Polyline.js +34 -35
- package/build/components/overlays/Polyline.js.map +1 -1
- package/build/components/overlays/index.d.ts.map +1 -1
- package/build/components/overlays/index.js +0 -10
- package/build/components/overlays/index.js.map +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +0 -10
- package/build/index.js.map +1 -1
- package/build/modules/AMapLocation.d.ts +47 -10
- package/build/modules/AMapLocation.d.ts.map +1 -1
- package/build/modules/AMapLocation.js +48 -20
- package/build/modules/AMapLocation.js.map +1 -1
- package/build/modules/AMapPermissions.d.ts +3 -1
- package/build/modules/AMapPermissions.d.ts.map +1 -1
- package/build/modules/AMapPermissions.js +3 -11
- package/build/modules/AMapPermissions.js.map +1 -1
- package/build/modules/AMapSDK.d.ts +5 -4
- package/build/modules/AMapSDK.d.ts.map +1 -1
- package/build/modules/AMapSDK.js +5 -14
- package/build/modules/AMapSDK.js.map +1 -1
- package/build/modules/AMapView.d.ts.map +1 -1
- package/build/modules/AMapView.js +0 -8
- package/build/modules/AMapView.js.map +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/index.js +0 -10
- package/build/types/index.js.map +1 -1
- package/build/types/map-view.types.d.ts +30 -0
- package/build/types/map-view.types.d.ts.map +1 -1
- package/build/types/map-view.types.js.map +1 -1
- package/build/types/overlays.types.d.ts +25 -1
- package/build/types/overlays.types.d.ts.map +1 -1
- package/build/types/overlays.types.js.map +1 -1
- package/docs/API.md +40 -0
- package/docs/EXAMPLES.md +86 -2
- package/docs/RELEASE_GUIDE.md +178 -0
- package/expo-module.config.json +1 -1
- package/ios/ExpoGaodeMapModule.swift +42 -14
- package/ios/ExpoGaodeMapView.swift +210 -7
- package/ios/managers/OverlayManager.swift +78 -10
- package/ios/overlays/CircleView.swift +41 -12
- package/ios/overlays/MarkerView.swift +55 -3
- package/ios/overlays/PolygonView.swift +25 -5
- package/ios/overlays/PolylineView.swift +23 -4
- package/ios/utils/ColorParser.swift +0 -5
- package/package.json +1 -1
- package/src/ExpoGaodeMap.types.ts +1 -10
- package/src/ExpoGaodeMapModule.ts +1 -10
- package/src/ExpoGaodeMapView.tsx +257 -38
- package/src/components/overlays/Circle.tsx +32 -50
- package/src/components/overlays/Cluster.tsx +4 -26
- package/src/components/overlays/HeatMap.tsx +4 -25
- package/src/components/overlays/Marker.tsx +69 -52
- package/src/components/overlays/MultiPoint.tsx +4 -25
- package/src/components/overlays/Polygon.tsx +48 -78
- package/src/components/overlays/Polyline.tsx +41 -38
- package/src/components/overlays/index.ts +0 -11
- package/src/index.ts +0 -11
- package/src/modules/AMapLocation.ts +56 -20
- package/src/modules/AMapPermissions.ts +4 -11
- package/src/modules/AMapSDK.ts +7 -14
- package/src/modules/AMapView.ts +0 -8
- package/src/types/index.ts +1 -10
- package/src/types/map-view.types.ts +25 -0
- package/src/types/overlays.types.ts +30 -1
|
@@ -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
|
-
* @
|
|
8
|
-
*
|
|
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":"
|
|
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
|
-
* @
|
|
19
|
-
*
|
|
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}/>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cluster.js","sourceRoot":"","sources":["../../../src/components/overlays/Cluster.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Cluster.js","sourceRoot":"","sources":["../../../src/components/overlays/Cluster.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,aAAa,GAAG,wBAAwB,CAAC,0BAA0B,CAAC,CAAC;AAG3E;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAmB;IACjD,OAAO,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AACtC,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\nimport type { ClusterProps } from '../../types';\n\nconst NativeCluster = requireNativeViewManager('ExpoGaodeMap_ClusterView');\n\n\n/**\n * 高德地图点聚合组件\n * \n * @param props 点聚合组件的属性配置\n * @returns 渲染原生点聚合组件\n */\nexport default function Cluster(props: ClusterProps) {\n return <NativeCluster {...props} />;\n}\n"]}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { HeatMapProps } from '../../types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 高德地图热力图组件
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
8
|
-
* <MapView>
|
|
9
|
-
* <HeatMap
|
|
10
|
-
* data={[
|
|
11
|
-
* { latitude: 39.9, longitude: 116.4, intensity: 100 },
|
|
12
|
-
* { latitude: 39.91, longitude: 116.41, intensity: 80 },
|
|
13
|
-
* ]}
|
|
14
|
-
* radius={50}
|
|
15
|
-
* opacity={0.6}
|
|
16
|
-
* />
|
|
17
|
-
* </MapView>
|
|
18
|
-
* ```
|
|
6
|
+
* @param props - 热力图配置属性,继承自NativeHeatMap组件的属性
|
|
7
|
+
* @returns 渲染高德地图原生热力图组件
|
|
19
8
|
*/
|
|
20
9
|
export default function HeatMap(props: HeatMapProps): React.JSX.Element;
|
|
21
10
|
//# sourceMappingURL=HeatMap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeatMap.d.ts","sourceRoot":"","sources":["../../../src/components/overlays/HeatMap.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HeatMap.d.ts","sourceRoot":"","sources":["../../../src/components/overlays/HeatMap.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,32 +1,11 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
3
|
-
* @Date : 2025-11-13 15:02:15
|
|
4
|
-
* @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
5
|
-
* @LastEditTime : 2025-11-13 18:12:07
|
|
6
|
-
* @FilePath : /expo-gaode-map/src/components/overlays/HeatMap.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 NativeHeatMap = requireNativeViewManager('ExpoGaodeMap_HeatMapView');
|
|
14
4
|
/**
|
|
15
|
-
*
|
|
5
|
+
* 高德地图热力图组件
|
|
16
6
|
*
|
|
17
|
-
* @
|
|
18
|
-
*
|
|
19
|
-
* <MapView>
|
|
20
|
-
* <HeatMap
|
|
21
|
-
* data={[
|
|
22
|
-
* { latitude: 39.9, longitude: 116.4, intensity: 100 },
|
|
23
|
-
* { latitude: 39.91, longitude: 116.41, intensity: 80 },
|
|
24
|
-
* ]}
|
|
25
|
-
* radius={50}
|
|
26
|
-
* opacity={0.6}
|
|
27
|
-
* />
|
|
28
|
-
* </MapView>
|
|
29
|
-
* ```
|
|
7
|
+
* @param props - 热力图配置属性,继承自NativeHeatMap组件的属性
|
|
8
|
+
* @returns 渲染高德地图原生热力图组件
|
|
30
9
|
*/
|
|
31
10
|
export default function HeatMap(props) {
|
|
32
11
|
return <NativeHeatMap {...props}/>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeatMap.js","sourceRoot":"","sources":["../../../src/components/overlays/HeatMap.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"HeatMap.js","sourceRoot":"","sources":["../../../src/components/overlays/HeatMap.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,aAAa,GAAG,wBAAwB,CAAC,0BAA0B,CAAC,CAAC;AAG3E;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAmB;IACjD,OAAO,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AACtC,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\nimport type { HeatMapProps } from '../../types';\n\nconst NativeHeatMap = requireNativeViewManager('ExpoGaodeMap_HeatMapView');\n\n\n/**\n * 高德地图热力图组件\n * \n * @param props - 热力图配置属性,继承自NativeHeatMap组件的属性\n * @returns 渲染高德地图原生热力图组件\n */\nexport default function HeatMap(props: HeatMapProps) {\n return <NativeHeatMap {...props} />;\n}\n"]}
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import type { MarkerProps } from '../../types';
|
|
2
|
-
|
|
3
|
-
* 地图标记组件
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```tsx
|
|
7
|
-
* <MapView>
|
|
8
|
-
* <Marker
|
|
9
|
-
* position={{ latitude: 39.9, longitude: 116.4 }}
|
|
10
|
-
* title="标记点"
|
|
11
|
-
* onPress={() => console.log('Marker pressed')}
|
|
12
|
-
* />
|
|
13
|
-
* </MapView>
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export default function Marker(props: MarkerProps): null;
|
|
3
|
+
export default function Marker(props: MarkerProps): React.JSX.Element;
|
|
17
4
|
//# sourceMappingURL=Marker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Marker.d.ts","sourceRoot":"","sources":["../../../src/components/overlays/Marker.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Marker.d.ts","sourceRoot":"","sources":["../../../src/components/overlays/Marker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,WAAW,qBAEhD"}
|
|
@@ -1,57 +1,71 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
3
|
-
* @Date : 2025-11-13 15:01:10
|
|
4
|
-
* @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
5
|
-
* @LastEditTime : 2025-11-13 18:55:00
|
|
6
|
-
* @FilePath : /expo-gaode-map/src/components/overlays/Marker.tsx
|
|
7
|
-
* @Description : 地图标记组件 - 使用命令式 API
|
|
8
|
-
*
|
|
9
|
-
* Copyright (c) 2025 by 尚博信_王强, All Rights Reserved.
|
|
10
|
-
*/
|
|
11
1
|
import * as React from 'react';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
* 地图标记组件
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```tsx
|
|
18
|
-
* <MapView>
|
|
19
|
-
* <Marker
|
|
20
|
-
* position={{ latitude: 39.9, longitude: 116.4 }}
|
|
21
|
-
* title="标记点"
|
|
22
|
-
* onPress={() => console.log('Marker pressed')}
|
|
23
|
-
* />
|
|
24
|
-
* </MapView>
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
2
|
+
import { Image } from 'react-native';
|
|
3
|
+
import { MapContext, MarkerEventContext } from '../../ExpoGaodeMapView';
|
|
27
4
|
export default function Marker(props) {
|
|
5
|
+
return <MarkerImperative {...props}/>;
|
|
6
|
+
}
|
|
7
|
+
function MarkerImperative(props) {
|
|
28
8
|
const mapRef = React.useContext(MapContext);
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
9
|
+
const eventManager = React.useContext(MarkerEventContext);
|
|
10
|
+
const markerIdRef = React.useRef(null);
|
|
11
|
+
const propsRef = React.useRef(props);
|
|
12
|
+
React.useEffect(() => {
|
|
13
|
+
propsRef.current = props;
|
|
14
|
+
}, [props]);
|
|
32
15
|
React.useEffect(() => {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
16
|
+
const checkAndAdd = () => {
|
|
17
|
+
if (!mapRef?.current) {
|
|
18
|
+
setTimeout(checkAndAdd, 50);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const markerId = `marker_${Date.now()}_${Math.random()}`;
|
|
22
|
+
markerIdRef.current = markerId;
|
|
23
|
+
if (eventManager) {
|
|
24
|
+
eventManager.register(markerId, {
|
|
25
|
+
onPress: props.onPress,
|
|
26
|
+
onDragStart: props.onDragStart,
|
|
27
|
+
onDrag: props.onDrag,
|
|
28
|
+
onDragEnd: props.onDragEnd,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const processedProps = { ...propsRef.current };
|
|
32
|
+
if (processedProps.icon && typeof processedProps.icon === 'number') {
|
|
33
|
+
const resolved = Image.resolveAssetSource(processedProps.icon);
|
|
34
|
+
processedProps.icon = resolved;
|
|
35
|
+
}
|
|
36
|
+
mapRef.current.addMarker(markerId, processedProps);
|
|
37
|
+
};
|
|
38
|
+
checkAndAdd();
|
|
40
39
|
return () => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
if (markerIdRef.current) {
|
|
41
|
+
if (eventManager) {
|
|
42
|
+
eventManager.unregister(markerIdRef.current);
|
|
43
|
+
}
|
|
44
|
+
if (mapRef?.current) {
|
|
45
|
+
mapRef.current.removeMarker(markerIdRef.current);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
45
48
|
};
|
|
46
49
|
}, []);
|
|
47
|
-
// 监听 Props 变化,更新标记
|
|
48
50
|
React.useEffect(() => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
if (markerIdRef.current && mapRef?.current) {
|
|
52
|
+
const processedProps = { ...props };
|
|
53
|
+
if (processedProps.icon && typeof processedProps.icon === 'number') {
|
|
54
|
+
const resolved = Image.resolveAssetSource(processedProps.icon);
|
|
55
|
+
processedProps.icon = resolved;
|
|
56
|
+
}
|
|
57
|
+
mapRef.current.updateMarker(markerIdRef.current, processedProps);
|
|
58
|
+
}
|
|
59
|
+
}, [
|
|
60
|
+
props.position?.latitude,
|
|
61
|
+
props.position?.longitude,
|
|
62
|
+
props.title,
|
|
63
|
+
props.draggable,
|
|
64
|
+
props.icon,
|
|
65
|
+
props.iconWidth,
|
|
66
|
+
props.iconHeight,
|
|
67
|
+
props.pinColor
|
|
68
|
+
]);
|
|
55
69
|
return null;
|
|
56
70
|
}
|
|
57
71
|
//# sourceMappingURL=Marker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Marker.js","sourceRoot":"","sources":["../../../src/components/overlays/Marker.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Marker.js","sourceRoot":"","sources":["../../../src/components/overlays/Marker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGxE,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAkB;IAC/C,OAAO,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AACzC,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAkB;IAC1C,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,EAAE,CAAC;gBACrB,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;gBAC5B,OAAO;YACT,CAAC;YAED,MAAM,QAAQ,GAAG,UAAU,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YACzD,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;YAE/B,IAAI,YAAY,EAAE,CAAC;gBACjB,YAAY,CAAC,QAAQ,CAAC,QAAQ,EAAE;oBAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,WAAW,EAAE,KAAK,CAAC,WAAW;oBAC9B,MAAM,EAAE,KAAK,CAAC,MAAM;oBACpB,SAAS,EAAE,KAAK,CAAC,SAAS;iBAC3B,CAAC,CAAC;YACL,CAAC;YAED,MAAM,cAAc,GAAG,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;YAC/C,IAAI,cAAc,CAAC,IAAI,IAAI,OAAO,cAAc,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACnE,MAAM,QAAQ,GAAG,KAAK,CAAC,kBAAkB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;gBAC/D,cAAc,CAAC,IAAI,GAAG,QAAQ,CAAC;YACjC,CAAC;YAED,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;QACrD,CAAC,CAAC;QAEF,WAAW,EAAE,CAAC;QAEd,OAAO,GAAG,EAAE;YACV,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;gBACxB,IAAI,YAAY,EAAE,CAAC;oBACjB,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;gBAC/C,CAAC;gBACD,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;oBACpB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;gBACnD,CAAC;YACH,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,WAAW,CAAC,OAAO,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YAC3C,MAAM,cAAc,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;YACpC,IAAI,cAAc,CAAC,IAAI,IAAI,OAAO,cAAc,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACnE,MAAM,QAAQ,GAAG,KAAK,CAAC,kBAAkB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;gBAC/D,cAAc,CAAC,IAAI,GAAG,QAAQ,CAAC;YACjC,CAAC;YACD,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QACnE,CAAC;IACH,CAAC,EAAE;QACD,KAAK,CAAC,QAAQ,EAAE,QAAQ;QACxB,KAAK,CAAC,QAAQ,EAAE,SAAS;QACzB,KAAK,CAAC,KAAK;QACX,KAAK,CAAC,SAAS;QACf,KAAK,CAAC,IAAI;QACV,KAAK,CAAC,SAAS;QACf,KAAK,CAAC,UAAU;QAChB,KAAK,CAAC,QAAQ;KACf,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import * as React from 'react';\nimport { Image } from 'react-native';\nimport { MapContext, MarkerEventContext } from '../../ExpoGaodeMapView';\nimport type { MarkerProps } from '../../types';\n\nexport default function Marker(props: MarkerProps) {\n return <MarkerImperative {...props} />;\n}\n\nfunction MarkerImperative(props: MarkerProps) {\n const mapRef = React.useContext(MapContext);\n const eventManager = React.useContext(MarkerEventContext);\n const markerIdRef = 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 markerId = `marker_${Date.now()}_${Math.random()}`;\n markerIdRef.current = markerId;\n \n if (eventManager) {\n eventManager.register(markerId, {\n onPress: props.onPress,\n onDragStart: props.onDragStart,\n onDrag: props.onDrag,\n onDragEnd: props.onDragEnd,\n });\n }\n \n const processedProps = { ...propsRef.current };\n if (processedProps.icon && typeof processedProps.icon === 'number') {\n const resolved = Image.resolveAssetSource(processedProps.icon);\n processedProps.icon = resolved;\n }\n \n mapRef.current.addMarker(markerId, processedProps);\n };\n \n checkAndAdd();\n \n return () => {\n if (markerIdRef.current) {\n if (eventManager) {\n eventManager.unregister(markerIdRef.current);\n }\n if (mapRef?.current) {\n mapRef.current.removeMarker(markerIdRef.current);\n }\n }\n };\n }, []);\n\n React.useEffect(() => {\n if (markerIdRef.current && mapRef?.current) {\n const processedProps = { ...props };\n if (processedProps.icon && typeof processedProps.icon === 'number') {\n const resolved = Image.resolveAssetSource(processedProps.icon);\n processedProps.icon = resolved;\n }\n mapRef.current.updateMarker(markerIdRef.current, processedProps);\n }\n }, [\n props.position?.latitude,\n props.position?.longitude,\n props.title,\n props.draggable,\n props.icon,\n props.iconWidth,\n props.iconHeight,\n props.pinColor\n ]);\n \n return null;\n}\n"]}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { MultiPointProps } from '../../types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* 用于展示大量标记点,性能优于普通 Marker
|
|
4
|
+
* 高德地图多点标记组件
|
|
6
5
|
*
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
9
|
-
* <MapView>
|
|
10
|
-
* <MultiPoint
|
|
11
|
-
* points={[
|
|
12
|
-
* { latitude: 39.9, longitude: 116.4, id: '1' },
|
|
13
|
-
* { latitude: 39.91, longitude: 116.41, id: '2' },
|
|
14
|
-
* ]}
|
|
15
|
-
* icon={require('./marker.png')}
|
|
16
|
-
* />
|
|
17
|
-
* </MapView>
|
|
18
|
-
* ```
|
|
6
|
+
* @param props 多点标记的配置属性,继承自MultiPointProps接口
|
|
7
|
+
* @returns 渲染原生高德地图多点标记组件
|
|
19
8
|
*/
|
|
20
9
|
export default function MultiPoint(props: MultiPointProps): React.JSX.Element;
|
|
21
10
|
//# sourceMappingURL=MultiPoint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiPoint.d.ts","sourceRoot":"","sources":["../../../src/components/overlays/MultiPoint.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MultiPoint.d.ts","sourceRoot":"","sources":["../../../src/components/overlays/MultiPoint.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAKnD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,KAAK,EAAE,eAAe,qBAExD"}
|
|
@@ -1,32 +1,11 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
3
|
-
* @Date : 2025-11-13 15:02:35
|
|
4
|
-
* @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
5
|
-
* @LastEditTime : 2025-11-13 18:19:09
|
|
6
|
-
* @FilePath : /expo-gaode-map/src/components/overlays/MultiPoint.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 NativeMultiPoint = requireNativeViewManager('ExpoGaodeMap_MultiPointView');
|
|
14
4
|
/**
|
|
15
|
-
*
|
|
16
|
-
* 用于展示大量标记点,性能优于普通 Marker
|
|
5
|
+
* 高德地图多点标记组件
|
|
17
6
|
*
|
|
18
|
-
* @
|
|
19
|
-
*
|
|
20
|
-
* <MapView>
|
|
21
|
-
* <MultiPoint
|
|
22
|
-
* points={[
|
|
23
|
-
* { latitude: 39.9, longitude: 116.4, id: '1' },
|
|
24
|
-
* { latitude: 39.91, longitude: 116.41, id: '2' },
|
|
25
|
-
* ]}
|
|
26
|
-
* icon={require('./marker.png')}
|
|
27
|
-
* />
|
|
28
|
-
* </MapView>
|
|
29
|
-
* ```
|
|
7
|
+
* @param props 多点标记的配置属性,继承自MultiPointProps接口
|
|
8
|
+
* @returns 渲染原生高德地图多点标记组件
|
|
30
9
|
*/
|
|
31
10
|
export default function MultiPoint(props) {
|
|
32
11
|
return <NativeMultiPoint {...props}/>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiPoint.js","sourceRoot":"","sources":["../../../src/components/overlays/MultiPoint.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"MultiPoint.js","sourceRoot":"","sources":["../../../src/components/overlays/MultiPoint.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,gBAAgB,GAAG,wBAAwB,CAAC,6BAA6B,CAAC,CAAC;AAGjF;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,KAAsB;IACvD,OAAO,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AACzC,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\nimport type { MultiPointProps } from '../../types';\n\nconst NativeMultiPoint = requireNativeViewManager('ExpoGaodeMap_MultiPointView');\n\n\n/**\n * 高德地图多点标记组件\n * \n * @param props 多点标记的配置属性,继承自MultiPointProps接口\n * @returns 渲染原生高德地图多点标记组件\n */\nexport default function MultiPoint(props: MultiPointProps) {\n return <NativeMultiPoint {...props} />;\n}\n"]}
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import type { PolygonProps } from '../../types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* 高德地图多边形覆盖物组件
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* />
|
|
18
|
-
* </MapView>
|
|
19
|
-
* ```
|
|
5
|
+
* @param props - 多边形配置属性
|
|
6
|
+
* @param props.points - 多边形顶点坐标数组,至少需要3个点
|
|
7
|
+
* @param props.fillColor - 多边形填充颜色,十六进制格式,默认0x440000FF
|
|
8
|
+
* @param props.strokeColor - 多边形边框颜色,默认-16776961
|
|
9
|
+
* @param props.strokeWidth - 多边形边框宽度,默认10
|
|
10
|
+
* @param props.zIndex - 多边形层级,默认0
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* 组件内部会自动生成唯一ID用于标识多边形,并在组件挂载时添加到地图,
|
|
14
|
+
* 更新时同步修改多边形属性,卸载时自动移除多边形。
|
|
15
|
+
*
|
|
16
|
+
* 注意:points数组长度必须大于等于3才能有效绘制多边形。
|
|
20
17
|
*/
|
|
21
18
|
export default function Polygon(props: PolygonProps): null;
|
|
22
19
|
//# sourceMappingURL=Polygon.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Polygon.d.ts","sourceRoot":"","sources":["../../../src/components/overlays/Polygon.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Polygon.d.ts","sourceRoot":"","sources":["../../../src/components/overlays/Polygon.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EAAE,YAAY,QAuDlD"}
|
|
@@ -1,98 +1,64 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
3
|
-
* @Date : 2025-11-13 15:01:45
|
|
4
|
-
* @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
5
|
-
* @LastEditTime : 2025-11-13 19:24:22
|
|
6
|
-
* @FilePath : /expo-gaode-map/src/components/overlays/Polygon.tsx
|
|
7
|
-
* @Description : 地图多边形组件 - 命令式 API
|
|
8
|
-
*
|
|
9
|
-
* Copyright (c) 2025 by 尚博信_王强, All Rights Reserved.
|
|
10
|
-
*/
|
|
11
1
|
import { useContext, useEffect, useRef } from 'react';
|
|
12
2
|
import { MapContext } from '../../ExpoGaodeMapView';
|
|
13
3
|
/**
|
|
14
|
-
*
|
|
4
|
+
* 高德地图多边形覆盖物组件
|
|
5
|
+
*
|
|
6
|
+
* @param props - 多边形配置属性
|
|
7
|
+
* @param props.points - 多边形顶点坐标数组,至少需要3个点
|
|
8
|
+
* @param props.fillColor - 多边形填充颜色,十六进制格式,默认0x440000FF
|
|
9
|
+
* @param props.strokeColor - 多边形边框颜色,默认-16776961
|
|
10
|
+
* @param props.strokeWidth - 多边形边框宽度,默认10
|
|
11
|
+
* @param props.zIndex - 多边形层级,默认0
|
|
15
12
|
*
|
|
16
|
-
* @
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* { latitude: 39.9, longitude: 116.4 },
|
|
22
|
-
* { latitude: 39.91, longitude: 116.41 },
|
|
23
|
-
* { latitude: 39.92, longitude: 116.40 },
|
|
24
|
-
* ]}
|
|
25
|
-
* fillColor={0x44FF0000}
|
|
26
|
-
* strokeColor={-65536}
|
|
27
|
-
* strokeWidth={5}
|
|
28
|
-
* />
|
|
29
|
-
* </MapView>
|
|
30
|
-
* ```
|
|
13
|
+
* @remarks
|
|
14
|
+
* 组件内部会自动生成唯一ID用于标识多边形,并在组件挂载时添加到地图,
|
|
15
|
+
* 更新时同步修改多边形属性,卸载时自动移除多边形。
|
|
16
|
+
*
|
|
17
|
+
* 注意:points数组长度必须大于等于3才能有效绘制多边形。
|
|
31
18
|
*/
|
|
32
19
|
export default function Polygon(props) {
|
|
33
20
|
const { points, fillColor, strokeColor, strokeWidth, zIndex } = props;
|
|
34
21
|
const nativeRef = useContext(MapContext);
|
|
35
|
-
const polygonIdRef = useRef(
|
|
22
|
+
const polygonIdRef = useRef(null);
|
|
23
|
+
const propsRef = useRef(props);
|
|
36
24
|
useEffect(() => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
25
|
+
propsRef.current = props;
|
|
26
|
+
}, [props]);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const checkAndAdd = () => {
|
|
29
|
+
if (!nativeRef?.current) {
|
|
30
|
+
setTimeout(checkAndAdd, 50);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const polygonId = `polygon_${Date.now()}_${Math.random()}`;
|
|
34
|
+
polygonIdRef.current = polygonId;
|
|
35
|
+
const { points, fillColor, strokeColor, strokeWidth, zIndex } = propsRef.current;
|
|
36
|
+
if (points && points.length >= 3) {
|
|
48
37
|
nativeRef.current.addPolygon(polygonId, {
|
|
49
38
|
points,
|
|
50
|
-
fillColor: fillColor ??
|
|
51
|
-
strokeColor: strokeColor ??
|
|
39
|
+
fillColor: fillColor ?? '#880000FF',
|
|
40
|
+
strokeColor: strokeColor ?? '#FFFF0000',
|
|
52
41
|
strokeWidth: strokeWidth ?? 10,
|
|
53
42
|
zIndex: zIndex ?? 0,
|
|
54
43
|
});
|
|
55
|
-
console.log('✅ Polygon addPolygon 调用完成');
|
|
56
44
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
console.warn('⚠️ Polygon 组件条件不满足:', {
|
|
63
|
-
hasNativeRef: !!nativeRef?.current,
|
|
64
|
-
hasPoints: !!points,
|
|
65
|
-
pointsLength: points?.length,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
// 清理函数
|
|
45
|
+
};
|
|
46
|
+
checkAndAdd();
|
|
69
47
|
return () => {
|
|
70
|
-
if (nativeRef?.current) {
|
|
71
|
-
|
|
72
|
-
nativeRef.current.removePolygon(polygonId);
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
console.error('移除多边形失败:', error);
|
|
76
|
-
}
|
|
48
|
+
if (polygonIdRef.current && nativeRef?.current) {
|
|
49
|
+
nativeRef.current.removePolygon(polygonIdRef.current);
|
|
77
50
|
}
|
|
78
51
|
};
|
|
79
52
|
}, []);
|
|
80
|
-
// 更新多边形属性
|
|
81
53
|
useEffect(() => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
zIndex,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
catch (error) {
|
|
94
|
-
console.error('更新多边形失败:', error);
|
|
95
|
-
}
|
|
54
|
+
if (polygonIdRef.current && nativeRef?.current) {
|
|
55
|
+
nativeRef.current.updatePolygon(polygonIdRef.current, {
|
|
56
|
+
points,
|
|
57
|
+
fillColor,
|
|
58
|
+
strokeColor,
|
|
59
|
+
strokeWidth,
|
|
60
|
+
zIndex,
|
|
61
|
+
});
|
|
96
62
|
}
|
|
97
63
|
}, [points, fillColor, strokeColor, strokeWidth, zIndex]);
|
|
98
64
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Polygon.js","sourceRoot":"","sources":["../../../src/components/overlays/Polygon.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Polygon.js","sourceRoot":"","sources":["../../../src/components/overlays/Polygon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAmB;IACjD,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACtE,MAAM,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;IACzC,MAAM,YAAY,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE/B,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;IAC3B,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,WAAW,GAAG,GAAG,EAAE;YACvB,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC;gBACxB,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;gBAC5B,OAAO;YACT,CAAC;YAED,MAAM,SAAS,GAAG,WAAW,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3D,YAAY,CAAC,OAAO,GAAG,SAAS,CAAC;YAEjC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC;YAEjF,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;gBACjC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,EAAE;oBACtC,MAAM;oBACN,SAAS,EAAE,SAAS,IAAI,WAAW;oBACnC,WAAW,EAAE,WAAW,IAAI,WAAW;oBACvC,WAAW,EAAE,WAAW,IAAI,EAAE;oBAC9B,MAAM,EAAE,MAAM,IAAI,CAAC;iBACpB,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC;QAEF,WAAW,EAAE,CAAC;QAEd,OAAO,GAAG,EAAE;YACV,IAAI,YAAY,CAAC,OAAO,IAAI,SAAS,EAAE,OAAO,EAAE,CAAC;gBAC/C,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YACxD,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,YAAY,CAAC,OAAO,IAAI,SAAS,EAAE,OAAO,EAAE,CAAC;YAC/C,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO,EAAE;gBACpD,MAAM;gBACN,SAAS;gBACT,WAAW;gBACX,WAAW;gBACX,MAAM;aACP,CAAC,CAAC;QACL,CAAC;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;IAE1D,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { useContext, useEffect, useRef } from 'react';\nimport type { PolygonProps } from '../../types';\nimport { MapContext } from '../../ExpoGaodeMapView';\n\n\n/**\n * 高德地图多边形覆盖物组件\n * \n * @param props - 多边形配置属性\n * @param props.points - 多边形顶点坐标数组,至少需要3个点\n * @param props.fillColor - 多边形填充颜色,十六进制格式,默认0x440000FF\n * @param props.strokeColor - 多边形边框颜色,默认-16776961\n * @param props.strokeWidth - 多边形边框宽度,默认10\n * @param props.zIndex - 多边形层级,默认0\n * \n * @remarks\n * 组件内部会自动生成唯一ID用于标识多边形,并在组件挂载时添加到地图,\n * 更新时同步修改多边形属性,卸载时自动移除多边形。\n * \n * 注意:points数组长度必须大于等于3才能有效绘制多边形。\n */\nexport default function Polygon(props: PolygonProps) {\n const { points, fillColor, strokeColor, strokeWidth, zIndex } = props;\n const nativeRef = useContext(MapContext);\n const polygonIdRef = useRef<string | null>(null);\n const propsRef = useRef(props);\n \n useEffect(() => {\n propsRef.current = props;\n }, [props]);\n\n useEffect(() => {\n const checkAndAdd = () => {\n if (!nativeRef?.current) {\n setTimeout(checkAndAdd, 50);\n return;\n }\n \n const polygonId = `polygon_${Date.now()}_${Math.random()}`;\n polygonIdRef.current = polygonId;\n \n const { points, fillColor, strokeColor, strokeWidth, zIndex } = propsRef.current;\n \n if (points && points.length >= 3) {\n nativeRef.current.addPolygon(polygonId, {\n points,\n fillColor: fillColor ?? '#880000FF',\n strokeColor: strokeColor ?? '#FFFF0000',\n strokeWidth: strokeWidth ?? 10,\n zIndex: zIndex ?? 0,\n });\n }\n };\n \n checkAndAdd();\n \n return () => {\n if (polygonIdRef.current && nativeRef?.current) {\n nativeRef.current.removePolygon(polygonIdRef.current);\n }\n };\n }, []);\n\n useEffect(() => {\n if (polygonIdRef.current && nativeRef?.current) {\n nativeRef.current.updatePolygon(polygonIdRef.current, {\n points,\n fillColor,\n strokeColor,\n strokeWidth,\n zIndex,\n });\n }\n }, [points, fillColor, strokeColor, strokeWidth, zIndex]);\n\n return null;\n}\n"]}
|