expo-gaode-map 1.0.8 → 1.0.9
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/android/src/main/java/expo/modules/gaodemap/managers/OverlayManager.kt +24 -6
- package/android/src/main/java/expo/modules/gaodemap/managers/UIManager.kt +6 -2
- package/android/src/main/java/expo/modules/gaodemap/overlays/CircleView.kt +6 -3
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerView.kt +288 -26
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerViewModule.kt +16 -0
- package/android/src/main/java/expo/modules/gaodemap/utils/ColorParser.kt +25 -0
- package/build/components/overlays/Circle.d.ts +2 -1
- package/build/components/overlays/Circle.d.ts.map +1 -1
- package/build/components/overlays/Circle.js +39 -0
- package/build/components/overlays/Circle.js.map +1 -1
- package/build/components/overlays/Marker.js +19 -3
- package/build/components/overlays/Marker.js.map +1 -1
- package/build/types/location.types.d.ts +4 -0
- package/build/types/location.types.d.ts.map +1 -1
- package/build/types/location.types.js.map +1 -1
- package/build/types/overlays.types.d.ts +20 -1
- package/build/types/overlays.types.d.ts.map +1 -1
- package/build/types/overlays.types.js.map +1 -1
- package/docs/API.en.md +14 -4
- package/docs/API.md +52 -4
- package/docs/EXAMPLES.en.md +58 -1
- package/docs/EXAMPLES.md +208 -1
- package/ios/ExpoGaodeMapView.swift +17 -0
- package/ios/overlays/CircleViewModule.swift +0 -2
- package/ios/overlays/MarkerView.swift +177 -27
- package/ios/overlays/MarkerViewModule.swift +8 -0
- package/ios/overlays/PolygonViewModule.swift +0 -2
- package/ios/overlays/PolylineViewModule.swift +0 -2
- package/ios/utils/ColorParser.swift +45 -0
- package/package.json +3 -2
- package/src/components/overlays/Circle.tsx +48 -0
- package/src/components/overlays/Marker.tsx +27 -7
- package/src/types/location.types.ts +5 -0
- package/src/types/overlays.types.ts +23 -1
|
@@ -1,8 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
3
|
+
* @Date : 2025-11-13 15:02:04
|
|
4
|
+
* @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
5
|
+
* @LastEditTime : 2025-11-21 10:36:10
|
|
6
|
+
* @FilePath : /expo-gaode-map/src/components/overlays/Circle.tsx
|
|
7
|
+
* @Description :
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2025 by 尚博信_王强, All Rights Reserved.
|
|
10
|
+
*/
|
|
1
11
|
import * as React from 'react';
|
|
12
|
+
import { requireNativeViewManager } from 'expo-modules-core';
|
|
2
13
|
import type { CircleProps } from '../../types';
|
|
3
14
|
import { MapContext, CircleEventContext } from '../../ExpoGaodeMapView';
|
|
4
15
|
|
|
16
|
+
const NativeCircleView = requireNativeViewManager('CircleView');
|
|
17
|
+
|
|
5
18
|
export default function Circle(props: CircleProps) {
|
|
19
|
+
// 如果有 children,使用声明式 API
|
|
20
|
+
if (props.children) {
|
|
21
|
+
return <CircleDeclarative {...props} />;
|
|
22
|
+
}
|
|
23
|
+
// 否则使用命令式 API
|
|
24
|
+
return <CircleImperative {...props} />;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function CircleDeclarative(props: CircleProps) {
|
|
28
|
+
const eventManager = React.useContext(CircleEventContext);
|
|
29
|
+
const circleIdRef = React.useRef(`circle_${Date.now()}_${Math.random()}`);
|
|
30
|
+
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
if (eventManager) {
|
|
33
|
+
eventManager.register(circleIdRef.current, {
|
|
34
|
+
onPress: props.onPress,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return () => {
|
|
38
|
+
if (eventManager) {
|
|
39
|
+
eventManager.unregister(circleIdRef.current);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}, [props.onPress]);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<NativeCircleView
|
|
46
|
+
{...props}
|
|
47
|
+
>
|
|
48
|
+
{props.children}
|
|
49
|
+
</NativeCircleView>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function CircleImperative(props: CircleProps) {
|
|
6
54
|
const mapRef = React.useContext(MapContext);
|
|
7
55
|
const eventManager = React.useContext(CircleEventContext);
|
|
8
56
|
const circleIdRef = React.useRef<string | null>(null);
|
|
@@ -19,6 +19,16 @@ function MarkerDeclarative(props: MarkerProps) {
|
|
|
19
19
|
const eventManager = React.useContext(MarkerEventContext);
|
|
20
20
|
const markerIdRef = React.useRef(`marker_${Date.now()}_${Math.random()}`);
|
|
21
21
|
|
|
22
|
+
// 根据是否有 children 来决定使用哪个尺寸属性
|
|
23
|
+
// 有 children:使用 customViewWidth/customViewHeight(默认 80x30)
|
|
24
|
+
// 无 children:使用 iconWidth/iconHeight(用于自定义图标)
|
|
25
|
+
const containerWidth = props.children
|
|
26
|
+
? (props.customViewWidth && props.customViewWidth > 0 ? props.customViewWidth : 80)
|
|
27
|
+
: (props.iconWidth || 0);
|
|
28
|
+
const containerHeight = props.children
|
|
29
|
+
? (props.customViewHeight && props.customViewHeight > 0 ? props.customViewHeight : 30)
|
|
30
|
+
: (props.iconHeight || 0);
|
|
31
|
+
|
|
22
32
|
React.useEffect(() => {
|
|
23
33
|
if (eventManager) {
|
|
24
34
|
eventManager.register(markerIdRef.current, {
|
|
@@ -33,21 +43,27 @@ function MarkerDeclarative(props: MarkerProps) {
|
|
|
33
43
|
eventManager.unregister(markerIdRef.current);
|
|
34
44
|
}
|
|
35
45
|
};
|
|
36
|
-
}, [props.onPress, props.onDragStart, props.onDrag, props.onDragEnd]);
|
|
46
|
+
}, [eventManager, props.onPress, props.onDragStart, props.onDrag, props.onDragEnd]);
|
|
37
47
|
|
|
38
48
|
return (
|
|
39
49
|
<NativeMarkerView
|
|
40
50
|
position={props.position}
|
|
41
51
|
title={props.title}
|
|
52
|
+
snippet={props.snippet}
|
|
42
53
|
draggable={props.draggable}
|
|
54
|
+
icon={props.icon}
|
|
55
|
+
iconWidth={props.iconWidth || 0} // 传递原始的 iconWidth(用于自定义图标)
|
|
56
|
+
iconHeight={props.iconHeight || 0} // 传递原始的 iconHeight(用于自定义图标)
|
|
57
|
+
customViewWidth={containerWidth} // 新增:自定义视图宽度
|
|
58
|
+
customViewHeight={containerHeight} // 新增:自定义视图高度
|
|
59
|
+
pinColor={props.pinColor}
|
|
60
|
+
animatesDrop={props.animatesDrop}
|
|
61
|
+
centerOffset={props.centerOffset}
|
|
43
62
|
opacity={props.opacity}
|
|
44
|
-
anchor={props.anchor}
|
|
45
63
|
flat={props.flat}
|
|
46
64
|
zIndex={props.zIndex}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
onDrag={props.onDrag}
|
|
50
|
-
onDragEnd={props.onDragEnd}
|
|
65
|
+
anchor={props.anchor}
|
|
66
|
+
style={{ width: containerWidth, height: containerHeight }}
|
|
51
67
|
>
|
|
52
68
|
{props.children}
|
|
53
69
|
</NativeMarkerView>
|
|
@@ -115,7 +131,7 @@ function MarkerImperative(props: MarkerProps) {
|
|
|
115
131
|
onDragEnd: props.onDragEnd,
|
|
116
132
|
});
|
|
117
133
|
}
|
|
118
|
-
}, [props.onPress, props.onDragStart, props.onDrag, props.onDragEnd]);
|
|
134
|
+
}, [eventManager, props.onPress, props.onDragStart, props.onDrag, props.onDragEnd]);
|
|
119
135
|
|
|
120
136
|
React.useEffect(() => {
|
|
121
137
|
if (markerIdRef.current && mapRef?.current) {
|
|
@@ -127,6 +143,7 @@ function MarkerImperative(props: MarkerProps) {
|
|
|
127
143
|
mapRef.current.updateMarker(markerIdRef.current, processedProps);
|
|
128
144
|
}
|
|
129
145
|
}, [
|
|
146
|
+
mapRef,
|
|
130
147
|
props.position?.latitude,
|
|
131
148
|
props.position?.longitude,
|
|
132
149
|
props.title,
|
|
@@ -134,8 +151,11 @@ function MarkerImperative(props: MarkerProps) {
|
|
|
134
151
|
props.icon,
|
|
135
152
|
props.iconWidth,
|
|
136
153
|
props.iconHeight,
|
|
154
|
+
props.customViewWidth,
|
|
155
|
+
props.customViewHeight,
|
|
137
156
|
props.pinColor
|
|
138
157
|
]);
|
|
139
158
|
|
|
140
159
|
return null;
|
|
141
160
|
}
|
|
161
|
+
|
|
@@ -22,11 +22,13 @@ export interface MarkerProps {
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* 图标宽度(像素)
|
|
25
|
+
* 仅在使用 icon 属性时有效
|
|
25
26
|
*/
|
|
26
27
|
iconWidth?: number;
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* 图标高度(像素)
|
|
31
|
+
* 仅在使用 icon 属性时有效
|
|
30
32
|
*/
|
|
31
33
|
iconHeight?: number;
|
|
32
34
|
|
|
@@ -93,10 +95,24 @@ export interface MarkerProps {
|
|
|
93
95
|
|
|
94
96
|
/**
|
|
95
97
|
* 自定义视图
|
|
96
|
-
*
|
|
98
|
+
* 当使用 children 时,会将 React Native 组件渲染为图片显示在地图上
|
|
97
99
|
*/
|
|
98
100
|
children?: React.ReactNode;
|
|
99
101
|
|
|
102
|
+
/**
|
|
103
|
+
* 自定义视图宽度(像素)
|
|
104
|
+
* 仅在使用 children 属性时有效
|
|
105
|
+
* @default 80
|
|
106
|
+
*/
|
|
107
|
+
customViewWidth?: number;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 自定义视图高度(像素)
|
|
111
|
+
* 仅在使用 children 属性时有效
|
|
112
|
+
* @default 30
|
|
113
|
+
*/
|
|
114
|
+
customViewHeight?: number;
|
|
115
|
+
|
|
100
116
|
/**
|
|
101
117
|
* 点击事件
|
|
102
118
|
*/
|
|
@@ -254,6 +270,12 @@ export interface CircleProps {
|
|
|
254
270
|
*/
|
|
255
271
|
onPress?: () => void;
|
|
256
272
|
|
|
273
|
+
/**
|
|
274
|
+
* 自定义子元素
|
|
275
|
+
* 暂不支持
|
|
276
|
+
*/
|
|
277
|
+
children?: React.ReactNode;
|
|
278
|
+
|
|
257
279
|
}
|
|
258
280
|
|
|
259
281
|
/**
|