expo-gaode-map 1.0.2 → 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/ExpoGaodeMapView.d.ts +26 -1
- package/build/ExpoGaodeMapView.d.ts.map +1 -1
- package/build/ExpoGaodeMapView.js +82 -1
- package/build/ExpoGaodeMapView.js.map +1 -1
- package/build/components/overlays/Circle.d.ts +0 -20
- package/build/components/overlays/Circle.d.ts.map +1 -1
- package/build/components/overlays/Circle.js +28 -45
- package/build/components/overlays/Circle.js.map +1 -1
- package/build/components/overlays/Marker.d.ts +2 -16
- package/build/components/overlays/Marker.d.ts.map +1 -1
- package/build/components/overlays/Marker.js +60 -37
- package/build/components/overlays/Marker.js.map +1 -1
- package/build/components/overlays/Polygon.d.ts.map +1 -1
- package/build/components/overlays/Polygon.js +28 -49
- package/build/components/overlays/Polygon.js.map +1 -1
- package/build/components/overlays/Polyline.d.ts.map +1 -1
- package/build/components/overlays/Polyline.js +22 -11
- package/build/components/overlays/Polyline.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/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/ExpoGaodeMapView.tsx +118 -1
- package/src/components/overlays/Circle.tsx +31 -48
- package/src/components/overlays/Marker.tsx +69 -42
- package/src/components/overlays/Polygon.tsx +34 -50
- package/src/components/overlays/Polyline.tsx +29 -14
- package/src/types/map-view.types.ts +25 -0
- package/src/types/overlays.types.ts +30 -1
|
@@ -22,70 +22,54 @@ import { MapContext } from '../../ExpoGaodeMapView';
|
|
|
22
22
|
export default function Polygon(props: PolygonProps) {
|
|
23
23
|
const { points, fillColor, strokeColor, strokeWidth, zIndex } = props;
|
|
24
24
|
const nativeRef = useContext(MapContext);
|
|
25
|
-
const polygonIdRef = useRef<string>(
|
|
26
|
-
|
|
25
|
+
const polygonIdRef = useRef<string | null>(null);
|
|
26
|
+
const propsRef = useRef(props);
|
|
27
|
+
|
|
27
28
|
useEffect(() => {
|
|
28
|
-
|
|
29
|
+
propsRef.current = props;
|
|
30
|
+
}, [props]);
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const checkAndAdd = () => {
|
|
34
|
+
if (!nativeRef?.current) {
|
|
35
|
+
setTimeout(checkAndAdd, 50);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const polygonId = `polygon_${Date.now()}_${Math.random()}`;
|
|
40
|
+
polygonIdRef.current = polygonId;
|
|
41
|
+
|
|
42
|
+
const { points, fillColor, strokeColor, strokeWidth, zIndex } = propsRef.current;
|
|
43
|
+
|
|
44
|
+
if (points && points.length >= 3) {
|
|
41
45
|
nativeRef.current.addPolygon(polygonId, {
|
|
42
46
|
points,
|
|
43
|
-
fillColor: fillColor ??
|
|
44
|
-
strokeColor: strokeColor ??
|
|
47
|
+
fillColor: fillColor ?? '#880000FF',
|
|
48
|
+
strokeColor: strokeColor ?? '#FFFF0000',
|
|
45
49
|
strokeWidth: strokeWidth ?? 10,
|
|
46
50
|
zIndex: zIndex ?? 0,
|
|
47
51
|
});
|
|
48
|
-
|
|
49
|
-
console.log('✅ Polygon addPolygon 调用完成');
|
|
50
|
-
} catch (error) {
|
|
51
|
-
console.error('❌ 添加多边形失败:', error);
|
|
52
52
|
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
pointsLength: points?.length,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// 清理函数
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
checkAndAdd();
|
|
56
|
+
|
|
62
57
|
return () => {
|
|
63
|
-
if (nativeRef?.current) {
|
|
64
|
-
|
|
65
|
-
nativeRef.current.removePolygon(polygonId);
|
|
66
|
-
} catch (error) {
|
|
67
|
-
console.error('移除多边形失败:', error);
|
|
68
|
-
}
|
|
58
|
+
if (polygonIdRef.current && nativeRef?.current) {
|
|
59
|
+
nativeRef.current.removePolygon(polygonIdRef.current);
|
|
69
60
|
}
|
|
70
61
|
};
|
|
71
62
|
}, []);
|
|
72
63
|
|
|
73
|
-
// 更新多边形属性
|
|
74
64
|
useEffect(() => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
strokeWidth,
|
|
84
|
-
zIndex,
|
|
85
|
-
});
|
|
86
|
-
} catch (error) {
|
|
87
|
-
console.error('更新多边形失败:', error);
|
|
88
|
-
}
|
|
65
|
+
if (polygonIdRef.current && nativeRef?.current) {
|
|
66
|
+
nativeRef.current.updatePolygon(polygonIdRef.current, {
|
|
67
|
+
points,
|
|
68
|
+
fillColor,
|
|
69
|
+
strokeColor,
|
|
70
|
+
strokeWidth,
|
|
71
|
+
zIndex,
|
|
72
|
+
});
|
|
89
73
|
}
|
|
90
74
|
}, [points, fillColor, strokeColor, strokeWidth, zIndex]);
|
|
91
75
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { MapContext } from '../../ExpoGaodeMapView';
|
|
3
4
|
import type { PolylineProps } from '../../types';
|
|
@@ -21,24 +22,38 @@ import type { PolylineProps } from '../../types';
|
|
|
21
22
|
export default function Polyline(props: PolylineProps) {
|
|
22
23
|
const mapRef = React.useContext(MapContext);
|
|
23
24
|
const polylineIdRef = React.useRef<string | null>(null);
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const propsRef = React.useRef(props);
|
|
26
|
+
|
|
26
27
|
React.useEffect(() => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
propsRef.current = props;
|
|
29
|
+
}, [props]);
|
|
30
|
+
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
const checkAndAdd = () => {
|
|
33
|
+
if (!mapRef?.current) {
|
|
34
|
+
setTimeout(checkAndAdd, 50);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const polylineId = `polyline_${Date.now()}_${Math.random()}`;
|
|
39
|
+
polylineIdRef.current = polylineId;
|
|
40
|
+
|
|
41
|
+
const polylineProps = {
|
|
42
|
+
points: propsRef.current.points,
|
|
43
|
+
width: propsRef.current.width,
|
|
44
|
+
color: propsRef.current.color,
|
|
45
|
+
...(propsRef.current.texture && { texture: propsRef.current.texture }),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
mapRef.current.addPolyline(polylineId, polylineProps);
|
|
36
49
|
};
|
|
37
50
|
|
|
38
|
-
|
|
39
|
-
|
|
51
|
+
checkAndAdd();
|
|
52
|
+
|
|
40
53
|
return () => {
|
|
41
|
-
mapRef?.current
|
|
54
|
+
if (polylineIdRef.current && mapRef?.current) {
|
|
55
|
+
mapRef.current.removePolyline(polylineIdRef.current);
|
|
56
|
+
}
|
|
42
57
|
};
|
|
43
58
|
}, []);
|
|
44
59
|
|
|
@@ -199,6 +199,31 @@ export interface MapViewProps {
|
|
|
199
199
|
*/
|
|
200
200
|
onLocation?: (event: Location) => void;
|
|
201
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Marker 点击事件
|
|
204
|
+
*/
|
|
205
|
+
onMarkerPress?: (event: { markerId: string } & LatLng) => void;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Marker 拖拽开始事件
|
|
209
|
+
*/
|
|
210
|
+
onMarkerDragStart?: (event: { markerId: string } & LatLng) => void;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Marker 拖拽中事件
|
|
214
|
+
*/
|
|
215
|
+
onMarkerDrag?: (event: { markerId: string } & LatLng) => void;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Marker 拖拽结束事件
|
|
219
|
+
*/
|
|
220
|
+
onMarkerDragEnd?: (event: { markerId: string } & LatLng) => void;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Circle 点击事件
|
|
224
|
+
*/
|
|
225
|
+
onCirclePress?: (event: { circleId: string } & LatLng) => void;
|
|
226
|
+
|
|
202
227
|
/**
|
|
203
228
|
* 子组件
|
|
204
229
|
*/
|
|
@@ -18,7 +18,17 @@ export interface MarkerProps {
|
|
|
18
18
|
/**
|
|
19
19
|
* 图标
|
|
20
20
|
*/
|
|
21
|
-
icon?: ImageSourcePropType;
|
|
21
|
+
icon?: string | ImageSourcePropType;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 图标宽度(像素)
|
|
25
|
+
*/
|
|
26
|
+
iconWidth?: number;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 图标高度(像素)
|
|
30
|
+
*/
|
|
31
|
+
iconHeight?: number;
|
|
22
32
|
|
|
23
33
|
/**
|
|
24
34
|
* 标题
|
|
@@ -33,6 +43,7 @@ export interface MarkerProps {
|
|
|
33
43
|
/**
|
|
34
44
|
* 透明度 [0, 1]
|
|
35
45
|
* @platform android
|
|
46
|
+
* @note iOS 不支持
|
|
36
47
|
*/
|
|
37
48
|
opacity?: number;
|
|
38
49
|
|
|
@@ -44,17 +55,21 @@ export interface MarkerProps {
|
|
|
44
55
|
/**
|
|
45
56
|
* 是否平贴地图
|
|
46
57
|
* @platform android
|
|
58
|
+
* @note iOS 不支持
|
|
47
59
|
*/
|
|
48
60
|
flat?: boolean;
|
|
49
61
|
|
|
50
62
|
/**
|
|
51
63
|
* 层级
|
|
64
|
+
* @platform android
|
|
65
|
+
* @note iOS 不支持 (使用 displayPriority)
|
|
52
66
|
*/
|
|
53
67
|
zIndex?: number;
|
|
54
68
|
|
|
55
69
|
/**
|
|
56
70
|
* 覆盖物锚点比例
|
|
57
71
|
* @platform android
|
|
72
|
+
* @note iOS 使用 centerOffset
|
|
58
73
|
*/
|
|
59
74
|
anchor?: Point;
|
|
60
75
|
|
|
@@ -64,8 +79,21 @@ export interface MarkerProps {
|
|
|
64
79
|
*/
|
|
65
80
|
centerOffset?: Point;
|
|
66
81
|
|
|
82
|
+
/**
|
|
83
|
+
* 是否显示动画
|
|
84
|
+
* @platform ios
|
|
85
|
+
*/
|
|
86
|
+
animatesDrop?: boolean;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 大头针颜色
|
|
90
|
+
* @platform ios
|
|
91
|
+
*/
|
|
92
|
+
pinColor?: 'red' | 'green' | 'purple';
|
|
93
|
+
|
|
67
94
|
/**
|
|
68
95
|
* 自定义视图
|
|
96
|
+
* @note 未实现
|
|
69
97
|
*/
|
|
70
98
|
children?: React.ReactNode;
|
|
71
99
|
|
|
@@ -219,6 +247,7 @@ export interface CircleProps {
|
|
|
219
247
|
* 点击事件
|
|
220
248
|
*/
|
|
221
249
|
onPress?: () => void;
|
|
250
|
+
|
|
222
251
|
}
|
|
223
252
|
|
|
224
253
|
/**
|