expo-gaode-map 1.0.9 → 1.1.1
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/overlays/MarkerView.kt +138 -21
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerViewModule.kt +18 -13
- package/build/ExpoGaodeMapView.d.ts +6 -7
- package/build/ExpoGaodeMapView.d.ts.map +1 -1
- package/build/ExpoGaodeMapView.js +7 -12
- package/build/ExpoGaodeMapView.js.map +1 -1
- package/build/components/overlays/Marker.js +1 -1
- package/build/components/overlays/Marker.js.map +1 -1
- package/build/types/map-view.types.d.ts +22 -23
- 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 +13 -17
- package/build/types/overlays.types.d.ts.map +1 -1
- package/build/types/overlays.types.js.map +1 -1
- package/docs/API.en.md +10 -10
- package/docs/API.md +10 -10
- package/docs/EXAMPLES.en.md +8 -8
- package/docs/EXAMPLES.md +11 -11
- package/ios/overlays/MarkerView.swift +67 -1
- package/ios/overlays/MarkerViewModule.swift +7 -2
- package/package.json +1 -1
- package/src/ExpoGaodeMapView.tsx +13 -17
- package/src/components/overlays/Marker.tsx +2 -1
- package/src/types/map-view.types.ts +16 -16
- package/src/types/overlays.types.ts +10 -10
|
@@ -35,6 +35,8 @@ class MarkerView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
35
35
|
private var marker: Marker? = null
|
|
36
36
|
private var aMap: AMap? = null
|
|
37
37
|
private var pendingPosition: LatLng? = null
|
|
38
|
+
private var pendingLatitude: Double? = null // 临时存储纬度
|
|
39
|
+
private var pendingLongitude: Double? = null // 临时存储经度
|
|
38
40
|
private var iconWidth: Int = 0 // 用于自定义图标的宽度
|
|
39
41
|
private var iconHeight: Int = 0 // 用于自定义图标的高度
|
|
40
42
|
private var customViewWidth: Int = 0 // 用于自定义视图(children)的宽度
|
|
@@ -76,29 +78,107 @@ class MarkerView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
/**
|
|
79
|
-
*
|
|
81
|
+
* 设置纬度
|
|
82
|
+
*/
|
|
83
|
+
fun setLatitude(lat: Double) {
|
|
84
|
+
try {
|
|
85
|
+
// 验证坐标范围
|
|
86
|
+
if (lat < -90 || lat > 90) {
|
|
87
|
+
android.util.Log.e("MarkerView", "❌ 纬度超出有效范围: $lat")
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
android.util.Log.d("MarkerView", "📍 setLatitude: $lat")
|
|
92
|
+
pendingLatitude = lat
|
|
93
|
+
|
|
94
|
+
// 如果经度也已设置,则更新位置
|
|
95
|
+
pendingLongitude?.let { lng ->
|
|
96
|
+
updatePosition(lat, lng)
|
|
97
|
+
}
|
|
98
|
+
} catch (e: Exception) {
|
|
99
|
+
android.util.Log.e("MarkerView", "❌ setLatitude 发生异常", e)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 设置经度
|
|
105
|
+
*/
|
|
106
|
+
fun setLongitude(lng: Double) {
|
|
107
|
+
try {
|
|
108
|
+
// 验证坐标范围
|
|
109
|
+
if (lng < -180 || lng > 180) {
|
|
110
|
+
android.util.Log.e("MarkerView", "❌ 经度超出有效范围: $lng")
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
android.util.Log.d("MarkerView", "📍 setLongitude: $lng")
|
|
115
|
+
pendingLongitude = lng
|
|
116
|
+
|
|
117
|
+
// 如果纬度也已设置,则更新位置
|
|
118
|
+
pendingLatitude?.let { lat ->
|
|
119
|
+
updatePosition(lat, lng)
|
|
120
|
+
}
|
|
121
|
+
} catch (e: Exception) {
|
|
122
|
+
android.util.Log.e("MarkerView", "❌ setLongitude 发生异常", e)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* 更新标记位置(当经纬度都设置后)
|
|
128
|
+
*/
|
|
129
|
+
private fun updatePosition(lat: Double, lng: Double) {
|
|
130
|
+
try {
|
|
131
|
+
val latLng = LatLng(lat, lng)
|
|
132
|
+
|
|
133
|
+
android.util.Log.d("MarkerView", "📍 updatePosition: ($lat, $lng), marker = $marker, aMap = $aMap")
|
|
134
|
+
|
|
135
|
+
marker?.let {
|
|
136
|
+
android.util.Log.d("MarkerView", "✅ 更新现有 marker 位置")
|
|
137
|
+
it.position = latLng
|
|
138
|
+
pendingPosition = null
|
|
139
|
+
pendingLatitude = null
|
|
140
|
+
pendingLongitude = null
|
|
141
|
+
} ?: run {
|
|
142
|
+
android.util.Log.d("MarkerView", "❌ marker 为 null")
|
|
143
|
+
if (aMap != null) {
|
|
144
|
+
android.util.Log.d("MarkerView", "🔧 aMap 存在,创建新 marker")
|
|
145
|
+
createOrUpdateMarker()
|
|
146
|
+
marker?.position = latLng
|
|
147
|
+
pendingLatitude = null
|
|
148
|
+
pendingLongitude = null
|
|
149
|
+
} else {
|
|
150
|
+
android.util.Log.d("MarkerView", "⏳ aMap 为 null,保存位置等待 setMap")
|
|
151
|
+
pendingPosition = latLng
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
} catch (e: Exception) {
|
|
155
|
+
android.util.Log.e("MarkerView", "❌ updatePosition 发生异常", e)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 设置标记位置(兼容旧的 API)
|
|
80
161
|
*/
|
|
81
162
|
fun setPosition(position: Map<String, Double>) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
createOrUpdateMarker()
|
|
97
|
-
marker?.position = latLng
|
|
98
|
-
} else {
|
|
99
|
-
android.util.Log.d("MarkerView", "⏳ aMap 为 null,保存位置等待 setMap")
|
|
100
|
-
pendingPosition = latLng
|
|
163
|
+
try {
|
|
164
|
+
val lat = position["latitude"]
|
|
165
|
+
val lng = position["longitude"]
|
|
166
|
+
|
|
167
|
+
// 验证坐标有效性
|
|
168
|
+
if (lat == null || lng == null) {
|
|
169
|
+
android.util.Log.e("MarkerView", "❌ 无效的位置数据: latitude=$lat, longitude=$lng")
|
|
170
|
+
return
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// 验证坐标范围
|
|
174
|
+
if (lat < -90 || lat > 90 || lng < -180 || lng > 180) {
|
|
175
|
+
android.util.Log.e("MarkerView", "❌ 坐标超出有效范围: ($lat, $lng)")
|
|
176
|
+
return
|
|
101
177
|
}
|
|
178
|
+
|
|
179
|
+
updatePosition(lat, lng)
|
|
180
|
+
} catch (e: Exception) {
|
|
181
|
+
android.util.Log.e("MarkerView", "❌ setPosition 发生异常", e)
|
|
102
182
|
}
|
|
103
183
|
}
|
|
104
184
|
|
|
@@ -465,8 +545,45 @@ class MarkerView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
465
545
|
}
|
|
466
546
|
|
|
467
547
|
|
|
548
|
+
override fun removeView(child: View?) {
|
|
549
|
+
android.util.Log.d("MarkerView", "➖ removeView 被调用,child = $child, childCount = $childCount")
|
|
550
|
+
super.removeView(child)
|
|
551
|
+
|
|
552
|
+
// 子视图被移除后,清除图标或恢复默认图标
|
|
553
|
+
mainHandler.postDelayed({
|
|
554
|
+
android.util.Log.d("MarkerView", "⏰ removeView 延迟更新,childCount = $childCount")
|
|
555
|
+
if (childCount == 0 && marker != null) {
|
|
556
|
+
android.util.Log.d("MarkerView", "📍 所有子视图已移除,恢复默认图标")
|
|
557
|
+
marker?.setIcon(BitmapDescriptorFactory.defaultMarker())
|
|
558
|
+
marker?.setAnchor(0.5f, 1.0f)
|
|
559
|
+
}
|
|
560
|
+
}, 50)
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
override fun removeViewAt(index: Int) {
|
|
564
|
+
android.util.Log.d("MarkerView", "➖ removeViewAt 被调用,index = $index, childCount = $childCount")
|
|
565
|
+
if (index >= 0 && index < childCount) {
|
|
566
|
+
super.removeViewAt(index)
|
|
567
|
+
|
|
568
|
+
// 子视图被移除后,清除图标或恢复默认图标
|
|
569
|
+
mainHandler.postDelayed({
|
|
570
|
+
android.util.Log.d("MarkerView", "⏰ removeViewAt 延迟更新,childCount = $childCount")
|
|
571
|
+
if (childCount == 0 && marker != null) {
|
|
572
|
+
android.util.Log.d("MarkerView", "📍 所有子视图已移除,恢复默认图标")
|
|
573
|
+
marker?.setIcon(BitmapDescriptorFactory.defaultMarker())
|
|
574
|
+
marker?.setAnchor(0.5f, 1.0f)
|
|
575
|
+
} else if (childCount > 0 && marker != null) {
|
|
576
|
+
android.util.Log.d("MarkerView", "🔄 还有子视图,更新图标")
|
|
577
|
+
updateMarkerIcon()
|
|
578
|
+
}
|
|
579
|
+
}, 50)
|
|
580
|
+
} else {
|
|
581
|
+
android.util.Log.w("MarkerView", "⚠️ removeViewAt: 无效的索引 $index,childCount = $childCount")
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
468
585
|
override fun addView(child: View?, index: Int, params: android.view.ViewGroup.LayoutParams?) {
|
|
469
|
-
android.util.Log.d("MarkerView", "➕ addView 被调用,child = $child")
|
|
586
|
+
android.util.Log.d("MarkerView", "➕ addView 被调用,child = $child, index = $index, childCount = $childCount")
|
|
470
587
|
super.addView(child, index, params)
|
|
471
588
|
|
|
472
589
|
// 延迟更新图标,等待 React Native 样式和内容渲染
|
|
@@ -13,51 +13,56 @@ class MarkerViewModule : Module() {
|
|
|
13
13
|
View(MarkerView::class) {
|
|
14
14
|
Events("onPress", "onDragStart", "onDrag", "onDragEnd")
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// 拆分 position 为两个独立属性以兼容 React Native 旧架构
|
|
17
|
+
Prop<Double>("latitude") { view, lat ->
|
|
18
|
+
view.setLatitude(lat)
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
Prop<
|
|
21
|
+
Prop<Double>("longitude") { view, lng ->
|
|
22
|
+
view.setLongitude(lng)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Prop<String>("title") { view, title ->
|
|
21
26
|
view.setTitle(title)
|
|
22
27
|
}
|
|
23
28
|
|
|
24
|
-
Prop<String>("description") { view
|
|
29
|
+
Prop<String>("description") { view, description ->
|
|
25
30
|
view.setDescription(description)
|
|
26
31
|
}
|
|
27
32
|
|
|
28
|
-
Prop<Boolean>("draggable") { view
|
|
33
|
+
Prop<Boolean>("draggable") { view, draggable ->
|
|
29
34
|
view.setDraggable(draggable)
|
|
30
35
|
}
|
|
31
36
|
|
|
32
|
-
Prop<Float>("opacity") { view
|
|
37
|
+
Prop<Float>("opacity") { view, opacity ->
|
|
33
38
|
view.setOpacity(opacity)
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
Prop<Boolean>("flat") { view
|
|
41
|
+
Prop<Boolean>("flat") { view, flat ->
|
|
37
42
|
view.setFlat(flat)
|
|
38
43
|
}
|
|
39
44
|
|
|
40
|
-
Prop<Float>("zIndex") { view
|
|
45
|
+
Prop<Float>("zIndex") { view, zIndex ->
|
|
41
46
|
view.setZIndex(zIndex)
|
|
42
47
|
}
|
|
43
48
|
|
|
44
|
-
Prop<Map<String, Float>>("anchor") { view
|
|
49
|
+
Prop<Map<String, Float>>("anchor") { view, anchor ->
|
|
45
50
|
view.setAnchor(anchor)
|
|
46
51
|
}
|
|
47
52
|
|
|
48
|
-
Prop<Int>("iconWidth") { view
|
|
53
|
+
Prop<Int>("iconWidth") { view, width ->
|
|
49
54
|
view.setIconWidth(width)
|
|
50
55
|
}
|
|
51
56
|
|
|
52
|
-
Prop<Int>("iconHeight") { view
|
|
57
|
+
Prop<Int>("iconHeight") { view, height ->
|
|
53
58
|
view.setIconHeight(height)
|
|
54
59
|
}
|
|
55
60
|
|
|
56
|
-
Prop<Int>("customViewWidth") { view
|
|
61
|
+
Prop<Int>("customViewWidth") { view, width ->
|
|
57
62
|
view.setCustomViewWidth(width)
|
|
58
63
|
}
|
|
59
64
|
|
|
60
|
-
Prop<Int>("customViewHeight") { view
|
|
65
|
+
Prop<Int>("customViewHeight") { view, height ->
|
|
61
66
|
view.setCustomViewHeight(height)
|
|
62
67
|
}
|
|
63
68
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { NativeSyntheticEvent } from 'react-native';
|
|
2
3
|
import { EventManager } from './utils/EventManager';
|
|
3
4
|
import type { MapViewProps, MapViewRef, LatLng } from './types';
|
|
4
5
|
export type { MapViewRef } from './types';
|
|
5
6
|
export declare const MapContext: React.Context<React.RefObject<MapViewRef | null> | null>;
|
|
6
7
|
type MarkerEventCallbacks = {
|
|
7
|
-
onPress?: () => void;
|
|
8
|
-
onDragStart?: () => void;
|
|
9
|
-
onDrag?: () => void;
|
|
10
|
-
onDragEnd?: (event:
|
|
11
|
-
nativeEvent: LatLng;
|
|
12
|
-
}) => void;
|
|
8
|
+
onPress?: (event: NativeSyntheticEvent<{}>) => void;
|
|
9
|
+
onDragStart?: (event: NativeSyntheticEvent<LatLng>) => void;
|
|
10
|
+
onDrag?: (event: NativeSyntheticEvent<LatLng>) => void;
|
|
11
|
+
onDragEnd?: (event: NativeSyntheticEvent<LatLng>) => void;
|
|
13
12
|
};
|
|
14
13
|
type OverlayEventCallbacks = {
|
|
15
|
-
onPress?: () => void;
|
|
14
|
+
onPress?: (event: NativeSyntheticEvent<{}>) => void;
|
|
16
15
|
};
|
|
17
16
|
export declare const MarkerEventContext: React.Context<EventManager<MarkerEventCallbacks> | null>;
|
|
18
17
|
export declare const CircleEventContext: React.Context<EventManager<OverlayEventCallbacks> | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoGaodeMapView.d.ts","sourceRoot":"","sources":["../src/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CAAC,KAAK,IAAI,CAAC;CACrD,CAAC;AAEF,eAAO,MAAM,kBAAkB,0DAAuE,CAAC;AACvG,eAAO,MAAM,kBAAkB,2DAAwE,CAAC;AACxG,eAAO,MAAM,mBAAmB,2DAAwE,CAAC;AACzG,eAAO,MAAM,oBAAoB,2DAAwE,CAAC;AAE1G;;;;;;;;;;;;;;;;;GAiBG;AACH,QAAA,MAAM,gBAAgB,iFAiRpB,CAAC;AAIH,eAAe,gBAAgB,CAAC"}
|
|
@@ -35,49 +35,44 @@ const ExpoGaodeMapView = React.forwardRef((props, ref) => {
|
|
|
35
35
|
const handleMarkerPress = (event) => {
|
|
36
36
|
const markerId = event.nativeEvent?.markerId;
|
|
37
37
|
if (markerId)
|
|
38
|
-
markerEventManager.trigger(markerId, 'onPress');
|
|
38
|
+
markerEventManager.trigger(markerId, 'onPress', event);
|
|
39
39
|
props.onMarkerPress?.(event);
|
|
40
40
|
};
|
|
41
41
|
const handleMarkerDragStart = (event) => {
|
|
42
42
|
const markerId = event.nativeEvent?.markerId;
|
|
43
43
|
if (markerId)
|
|
44
|
-
markerEventManager.trigger(markerId, 'onDragStart');
|
|
44
|
+
markerEventManager.trigger(markerId, 'onDragStart', event);
|
|
45
45
|
props.onMarkerDragStart?.(event);
|
|
46
46
|
};
|
|
47
47
|
const handleMarkerDrag = (event) => {
|
|
48
48
|
const markerId = event.nativeEvent?.markerId;
|
|
49
49
|
if (markerId)
|
|
50
|
-
markerEventManager.trigger(markerId, 'onDrag');
|
|
50
|
+
markerEventManager.trigger(markerId, 'onDrag', event);
|
|
51
51
|
props.onMarkerDrag?.(event);
|
|
52
52
|
};
|
|
53
53
|
const handleMarkerDragEnd = (event) => {
|
|
54
54
|
const markerId = event.nativeEvent?.markerId;
|
|
55
55
|
if (markerId) {
|
|
56
|
-
markerEventManager.trigger(markerId, 'onDragEnd',
|
|
57
|
-
nativeEvent: {
|
|
58
|
-
latitude: event.nativeEvent.latitude,
|
|
59
|
-
longitude: event.nativeEvent.longitude
|
|
60
|
-
}
|
|
61
|
-
});
|
|
56
|
+
markerEventManager.trigger(markerId, 'onDragEnd', event);
|
|
62
57
|
}
|
|
63
58
|
props.onMarkerDragEnd?.(event);
|
|
64
59
|
};
|
|
65
60
|
const handleCirclePress = (event) => {
|
|
66
61
|
const circleId = event.nativeEvent?.circleId;
|
|
67
62
|
if (circleId)
|
|
68
|
-
circleEventManager.trigger(circleId, 'onPress');
|
|
63
|
+
circleEventManager.trigger(circleId, 'onPress', event);
|
|
69
64
|
props.onCirclePress?.(event);
|
|
70
65
|
};
|
|
71
66
|
const handlePolygonPress = (event) => {
|
|
72
67
|
const polygonId = event.nativeEvent?.polygonId;
|
|
73
68
|
if (polygonId)
|
|
74
|
-
polygonEventManager.trigger(polygonId, 'onPress');
|
|
69
|
+
polygonEventManager.trigger(polygonId, 'onPress', event);
|
|
75
70
|
props.onPolygonPress?.(event);
|
|
76
71
|
};
|
|
77
72
|
const handlePolylinePress = (event) => {
|
|
78
73
|
const polylineId = event.nativeEvent?.polylineId;
|
|
79
74
|
if (polylineId)
|
|
80
|
-
polylineEventManager.trigger(polylineId, 'onPress');
|
|
75
|
+
polylineEventManager.trigger(polylineId, 'onPress', event);
|
|
81
76
|
props.onPolylinePress?.(event);
|
|
82
77
|
};
|
|
83
78
|
const apiRef = React.useMemo(() => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoGaodeMapView.js","sourceRoot":"","sources":["../src/ExpoGaodeMapView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAgBpD,MAAM,UAAU,GAA8E,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;AAE3I,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,CAA4C,IAAI,CAAC,CAAC;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AAA,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';\nimport { EventManager } from './utils/EventManager';\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\nexport type { MapViewRef } from './types';\n\nconst NativeView: React.ComponentType<MapViewProps & { ref?: React.Ref<NativeMapViewRef> }> = requireNativeViewManager('ExpoGaodeMapView');\n\nexport const MapContext = React.createContext<React.RefObject<MapViewRef | null> | null>(null);\n\ntype MarkerEventCallbacks = {\n onPress?: () => void;\n onDragStart?: () => void;\n onDrag?: () => void;\n onDragEnd?: (event: { nativeEvent: LatLng }) => void;\n};\n\ntype OverlayEventCallbacks = {\n onPress?: () => void;\n};\n\nexport const MarkerEventContext = React.createContext<EventManager<MarkerEventCallbacks> | null>(null);\nexport const CircleEventContext = React.createContext<EventManager<OverlayEventCallbacks> | null>(null);\nexport const PolygonEventContext = React.createContext<EventManager<OverlayEventCallbacks> | null>(null);\nexport const PolylineEventContext = React.createContext<EventManager<OverlayEventCallbacks> | null>(null);\n\n/**\n * 高德地图视图组件,提供地图操作API和覆盖物管理功能\n * \n * @param props - 组件属性\n * @param ref - 外部ref引用,用于访问地图API方法\n * @returns 返回包含地图视图和上下文提供者的React组件\n * \n * @remarks\n * 该组件内部维护两个ref:\n * - nativeRef: 指向原生地图视图的引用\n * - internalRef: 内部使用的API引用,通过MapContext共享\n * \n * 提供的主要API功能包括:\n * - 相机控制(移动、缩放、获取当前位置)\n * - 覆盖物管理(添加/删除/更新标记、折线、多边形、圆形等)\n * \n * 所有API方法都会检查地图是否已初始化,未初始化时抛出错误\n */\nconst ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref) => {\n const nativeRef = React.useRef<NativeMapViewRef>(null);\n const internalRef = React.useRef<MapViewRef | null>(null);\n const markerEventManager = React.useMemo(() => new EventManager<MarkerEventCallbacks>(), []);\n const circleEventManager = React.useMemo(() => new EventManager<OverlayEventCallbacks>(), []);\n const polygonEventManager = React.useMemo(() => new EventManager<OverlayEventCallbacks>(), []);\n const polylineEventManager = React.useMemo(() => new EventManager<OverlayEventCallbacks>(), []);\n const handleMarkerPress = (event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) markerEventManager.trigger(markerId, 'onPress');\n props.onMarkerPress?.(event);\n };\n \n const handleMarkerDragStart = (event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) markerEventManager.trigger(markerId, 'onDragStart');\n props.onMarkerDragStart?.(event);\n };\n \n const handleMarkerDrag = (event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) markerEventManager.trigger(markerId, 'onDrag');\n props.onMarkerDrag?.(event);\n };\n \n const handleMarkerDragEnd = (event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) {\n markerEventManager.trigger(markerId, 'onDragEnd', {\n nativeEvent: {\n latitude: event.nativeEvent.latitude,\n longitude: event.nativeEvent.longitude\n }\n });\n }\n props.onMarkerDragEnd?.(event);\n };\n \n const handleCirclePress = (event: any) => {\n const circleId = event.nativeEvent?.circleId;\n if (circleId) circleEventManager.trigger(circleId, 'onPress');\n props.onCirclePress?.(event);\n };\n \n const handlePolygonPress = (event: any) => {\n const polygonId = event.nativeEvent?.polygonId;\n if (polygonId) polygonEventManager.trigger(polygonId, 'onPress');\n props.onPolygonPress?.(event);\n };\n \n const handlePolylinePress = (event: any) => {\n const polylineId = event.nativeEvent?.polylineId;\n if (polylineId) polylineEventManager.trigger(polylineId, 'onPress');\n props.onPolylinePress?.(event);\n };\n\n const apiRef: MapViewRef = React.useMemo(() => ({\n /**\n * 移动地图相机到指定位置\n * @param position 相机位置参数对象,包含目标经纬度、缩放级别等信息\n * @param duration 动画持续时间(毫秒),默认300毫秒\n * @throws 如果地图视图未初始化则抛出错误\n * @returns Promise<void> 异步操作完成后的Promise\n */\n moveCamera: async (position: CameraPosition, duration: number = 300) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.moveCamera(position, duration);\n },\n /**\n * 将屏幕坐标点转换为地理坐标(经纬度)\n * @param point 屏幕坐标点 {x: number, y: number}\n * @returns 返回Promise,解析为对应的地理坐标 {latitude: number, longitude: number}\n * @throws 如果地图视图未初始化,抛出错误 'MapView not initialized'\n */\n getLatLng: async (point: Point) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.getLatLng(point);\n },\n /**\n * 设置地图中心点坐标\n * @param center 要设置的中心点坐标(LatLng格式)\n * @param animated 是否使用动画效果移动地图(默认为false)\n * @throws 如果地图视图未初始化则抛出错误\n */\n setCenter: async (center: LatLng, animated: boolean = false) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.setCenter(center, animated);\n },\n /**\n * 设置地图的缩放级别\n * @param zoom 目标缩放级别\n * @param animated 是否使用动画过渡效果,默认为false\n * @throws 如果地图视图未初始化,抛出错误\n */\n setZoom: async (zoom: number, animated: boolean = false) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.setZoom(zoom, animated);\n },\n /**\n * 获取当前地图的相机位置(视角中心点、缩放级别、倾斜角度等)\n * @returns 返回一个Promise,解析为当前相机位置的对象\n * @throws 如果地图视图未初始化,则抛出错误\n */\n getCameraPosition: async () => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.getCameraPosition();\n },\n /**\n * 在地图上添加圆形覆盖物\n * @param id - 圆形覆盖物的唯一标识符\n * @param props - 圆形覆盖物的属性配置\n * @returns Promise<void> 添加操作的异步结果\n * @throws 如果地图视图未初始化,抛出错误'MapView not initialized'\n */\n addCircle: async (id: string, props: CircleProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addCircle(id, props);\n },\n /**\n * 从地图上移除指定的圆形覆盖物\n * @param id - 要移除的圆形覆盖物的唯一标识符\n * @throws 如果地图视图未初始化,抛出错误\n * @returns Promise<void> 异步操作完成\n */\n removeCircle: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removeCircle(id);\n },\n /**\n * 更新地图上的圆形覆盖物\n * @param id 要更新的圆形覆盖物的唯一标识符\n * @param props 要更新的圆形属性(部分属性)\n * @throws 如果地图视图未初始化,抛出错误\n * @returns Promise<void> 表示更新操作完成\n */\n updateCircle: async (id: string, props: Partial<CircleProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updateCircle(id, props);\n },\n /**\n * 添加一个标记点到地图上\n * @param id 标记点的唯一标识符\n * @param props 标记点的配置属性\n * @returns Promise<void> 添加操作完成后的Promise\n * @throws 如果地图视图未初始化则抛出错误\n */\n addMarker: async (id: string, props: MarkerProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addMarker(id, props);\n },\n /**\n * 从地图上移除指定ID的标记点\n * @param id 要移除的标记点ID\n * @throws 如果地图视图未初始化则抛出错误\n * @returns Promise<void> 异步操作完成\n */\n removeMarker: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removeMarker(id);\n },\n /**\n * 更新地图上指定ID的标记点属性\n * @param id - 要更新的标记点唯一标识符\n * @param props - 需要更新的标记点属性对象(部分属性)\n * @throws 如果地图视图未初始化则抛出错误\n * @returns Promise对象,表示异步更新操作\n */\n updateMarker: async (id: string, props: Partial<MarkerProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updateMarker(id, props);\n },\n /**\n * 添加折线覆盖物到地图\n * @param id - 折线的唯一标识符\n * @param props - 折线的配置属性\n * @returns Promise<void> 添加操作的异步结果\n * @throws 如果地图视图未初始化则抛出错误\n */\n addPolyline: async (id: string, props: PolylineProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addPolyline(id, props);\n },\n /**\n * 移除地图上的指定折线\n * @param id - 要移除的折线的唯一标识符\n * @throws 如果地图视图未初始化,抛出错误\n * @returns Promise<void>\n */\n removePolyline: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removePolyline(id);\n },\n /**\n * 更新地图上的折线覆盖物\n * \n * @param id 要更新的折线覆盖物的唯一标识符\n * @param props 要更新的折线属性,包含部分PolylineProps属性\n * @returns Promise<void> 异步操作结果\n * @throws 如果地图视图未初始化,抛出错误\n */\n updatePolyline: async (id: string, props: Partial<PolylineProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updatePolyline(id, props);\n },\n /**\n * 向地图添加多边形覆盖物\n * @param id - 多边形的唯一标识符\n * @param props - 多边形的配置属性\n * @returns Promise<void> 添加操作的异步结果\n * @throws 如果地图视图未初始化则抛出错误\n */\n addPolygon: async (id: string, props: PolygonProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addPolygon(id, props);\n },\n /**\n * 移除地图上的多边形覆盖物\n * @param id - 要移除的多边形覆盖物的唯一标识符\n * @throws 如果地图视图未初始化,抛出错误 'MapView not initialized'\n * @returns Promise<void> 异步操作完成\n */\n removePolygon: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removePolygon(id);\n },\n /**\n * 更新多边形覆盖物的属性\n * \n * @param id - 要更新的多边形覆盖物的唯一标识符\n * @param props - 要更新的多边形属性对象,包含需要更新的部分属性\n * @throws {Error} 当地图视图未初始化时抛出错误\n * @returns Promise<void> 异步操作完成后的Promise\n */\n updatePolygon: async (id: string, props: Partial<PolygonProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updatePolygon(id, props);\n },\n }), []);\n\n /**\n * 将传入的apiRef赋值给internalRef.current\n * 用于在组件内部保存对地图API实例的引用\n */\n React.useEffect(() => {\n internalRef.current = apiRef;\n }, [apiRef]);\n\n /**\n * 获取当前地图实例的API引用\n * @returns 返回地图API的引用对象,可用于调用地图相关方法\n */\n React.useImperativeHandle(ref, () => apiRef, [apiRef]);\n\n return (\n <MapContext.Provider value={internalRef}>\n <MarkerEventContext.Provider value={markerEventManager}>\n <CircleEventContext.Provider value={circleEventManager}>\n <PolygonEventContext.Provider value={polygonEventManager}>\n <PolylineEventContext.Provider value={polylineEventManager}>\n <NativeView\n ref={nativeRef}\n {...props}\n onMarkerPress={handleMarkerPress}\n onMarkerDragStart={handleMarkerDragStart}\n onMarkerDrag={handleMarkerDrag}\n onMarkerDragEnd={handleMarkerDragEnd}\n onCirclePress={handleCirclePress}\n onPolygonPress={handlePolygonPress}\n onPolylinePress={handlePolylinePress}\n >\n {props.children}\n </NativeView>\n </PolylineEventContext.Provider>\n </PolygonEventContext.Provider>\n </CircleEventContext.Provider>\n </MarkerEventContext.Provider>\n </MapContext.Provider>\n );\n});\n\nExpoGaodeMapView.displayName = 'ExpoGaodeMapView';\n\nexport default ExpoGaodeMapView;\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoGaodeMapView.js","sourceRoot":"","sources":["../src/ExpoGaodeMapView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAgBpD,MAAM,UAAU,GAA8E,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;AAE3I,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,CAA4C,IAAI,CAAC,CAAC;AAa/F,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,aAAa,CAA4C,IAAI,CAAC,CAAC;AACvG,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,aAAa,CAA6C,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import { NativeSyntheticEvent } from 'react-native';\nimport { EventManager } from './utils/EventManager';\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\nexport type { MapViewRef } from './types';\n\nconst NativeView: React.ComponentType<MapViewProps & { ref?: React.Ref<NativeMapViewRef> }> = requireNativeViewManager('ExpoGaodeMapView');\n\nexport const MapContext = React.createContext<React.RefObject<MapViewRef | null> | null>(null);\n\ntype MarkerEventCallbacks = {\n onPress?: (event: NativeSyntheticEvent<{}>) => void;\n onDragStart?: (event: NativeSyntheticEvent<LatLng>) => void;\n onDrag?: (event: NativeSyntheticEvent<LatLng>) => void;\n onDragEnd?: (event: NativeSyntheticEvent<LatLng>) => void;\n};\n\ntype OverlayEventCallbacks = {\n onPress?: (event: NativeSyntheticEvent<{}>) => void;\n};\n\nexport const MarkerEventContext = React.createContext<EventManager<MarkerEventCallbacks> | null>(null);\nexport const CircleEventContext = React.createContext<EventManager<OverlayEventCallbacks> | null>(null);\nexport const PolygonEventContext = React.createContext<EventManager<OverlayEventCallbacks> | null>(null);\nexport const PolylineEventContext = React.createContext<EventManager<OverlayEventCallbacks> | null>(null);\n\n/**\n * 高德地图视图组件,提供地图操作API和覆盖物管理功能\n * \n * @param props - 组件属性\n * @param ref - 外部ref引用,用于访问地图API方法\n * @returns 返回包含地图视图和上下文提供者的React组件\n * \n * @remarks\n * 该组件内部维护两个ref:\n * - nativeRef: 指向原生地图视图的引用\n * - internalRef: 内部使用的API引用,通过MapContext共享\n * \n * 提供的主要API功能包括:\n * - 相机控制(移动、缩放、获取当前位置)\n * - 覆盖物管理(添加/删除/更新标记、折线、多边形、圆形等)\n * \n * 所有API方法都会检查地图是否已初始化,未初始化时抛出错误\n */\nconst ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref) => {\n const nativeRef = React.useRef<NativeMapViewRef>(null);\n const internalRef = React.useRef<MapViewRef | null>(null);\n const markerEventManager = React.useMemo(() => new EventManager<MarkerEventCallbacks>(), []);\n const circleEventManager = React.useMemo(() => new EventManager<OverlayEventCallbacks>(), []);\n const polygonEventManager = React.useMemo(() => new EventManager<OverlayEventCallbacks>(), []);\n const polylineEventManager = React.useMemo(() => new EventManager<OverlayEventCallbacks>(), []);\n const handleMarkerPress = (event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) markerEventManager.trigger(markerId, 'onPress', event);\n props.onMarkerPress?.(event);\n };\n \n const handleMarkerDragStart = (event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) markerEventManager.trigger(markerId, 'onDragStart', event);\n props.onMarkerDragStart?.(event);\n };\n \n const handleMarkerDrag = (event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) markerEventManager.trigger(markerId, 'onDrag', event);\n props.onMarkerDrag?.(event);\n };\n \n const handleMarkerDragEnd = (event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) {\n markerEventManager.trigger(markerId, 'onDragEnd', event);\n }\n props.onMarkerDragEnd?.(event);\n };\n \n const handleCirclePress = (event: any) => {\n const circleId = event.nativeEvent?.circleId;\n if (circleId) circleEventManager.trigger(circleId, 'onPress', event);\n props.onCirclePress?.(event);\n };\n \n const handlePolygonPress = (event: any) => {\n const polygonId = event.nativeEvent?.polygonId;\n if (polygonId) polygonEventManager.trigger(polygonId, 'onPress', event);\n props.onPolygonPress?.(event);\n };\n \n const handlePolylinePress = (event: any) => {\n const polylineId = event.nativeEvent?.polylineId;\n if (polylineId) polylineEventManager.trigger(polylineId, 'onPress', event);\n props.onPolylinePress?.(event);\n };\n\n const apiRef: MapViewRef = React.useMemo(() => ({\n /**\n * 移动地图相机到指定位置\n * @param position 相机位置参数对象,包含目标经纬度、缩放级别等信息\n * @param duration 动画持续时间(毫秒),默认300毫秒\n * @throws 如果地图视图未初始化则抛出错误\n * @returns Promise<void> 异步操作完成后的Promise\n */\n moveCamera: async (position: CameraPosition, duration: number = 300) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.moveCamera(position, duration);\n },\n /**\n * 将屏幕坐标点转换为地理坐标(经纬度)\n * @param point 屏幕坐标点 {x: number, y: number}\n * @returns 返回Promise,解析为对应的地理坐标 {latitude: number, longitude: number}\n * @throws 如果地图视图未初始化,抛出错误 'MapView not initialized'\n */\n getLatLng: async (point: Point) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.getLatLng(point);\n },\n /**\n * 设置地图中心点坐标\n * @param center 要设置的中心点坐标(LatLng格式)\n * @param animated 是否使用动画效果移动地图(默认为false)\n * @throws 如果地图视图未初始化则抛出错误\n */\n setCenter: async (center: LatLng, animated: boolean = false) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.setCenter(center, animated);\n },\n /**\n * 设置地图的缩放级别\n * @param zoom 目标缩放级别\n * @param animated 是否使用动画过渡效果,默认为false\n * @throws 如果地图视图未初始化,抛出错误\n */\n setZoom: async (zoom: number, animated: boolean = false) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.setZoom(zoom, animated);\n },\n /**\n * 获取当前地图的相机位置(视角中心点、缩放级别、倾斜角度等)\n * @returns 返回一个Promise,解析为当前相机位置的对象\n * @throws 如果地图视图未初始化,则抛出错误\n */\n getCameraPosition: async () => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.getCameraPosition();\n },\n /**\n * 在地图上添加圆形覆盖物\n * @param id - 圆形覆盖物的唯一标识符\n * @param props - 圆形覆盖物的属性配置\n * @returns Promise<void> 添加操作的异步结果\n * @throws 如果地图视图未初始化,抛出错误'MapView not initialized'\n */\n addCircle: async (id: string, props: CircleProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addCircle(id, props);\n },\n /**\n * 从地图上移除指定的圆形覆盖物\n * @param id - 要移除的圆形覆盖物的唯一标识符\n * @throws 如果地图视图未初始化,抛出错误\n * @returns Promise<void> 异步操作完成\n */\n removeCircle: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removeCircle(id);\n },\n /**\n * 更新地图上的圆形覆盖物\n * @param id 要更新的圆形覆盖物的唯一标识符\n * @param props 要更新的圆形属性(部分属性)\n * @throws 如果地图视图未初始化,抛出错误\n * @returns Promise<void> 表示更新操作完成\n */\n updateCircle: async (id: string, props: Partial<CircleProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updateCircle(id, props);\n },\n /**\n * 添加一个标记点到地图上\n * @param id 标记点的唯一标识符\n * @param props 标记点的配置属性\n * @returns Promise<void> 添加操作完成后的Promise\n * @throws 如果地图视图未初始化则抛出错误\n */\n addMarker: async (id: string, props: MarkerProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addMarker(id, props);\n },\n /**\n * 从地图上移除指定ID的标记点\n * @param id 要移除的标记点ID\n * @throws 如果地图视图未初始化则抛出错误\n * @returns Promise<void> 异步操作完成\n */\n removeMarker: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removeMarker(id);\n },\n /**\n * 更新地图上指定ID的标记点属性\n * @param id - 要更新的标记点唯一标识符\n * @param props - 需要更新的标记点属性对象(部分属性)\n * @throws 如果地图视图未初始化则抛出错误\n * @returns Promise对象,表示异步更新操作\n */\n updateMarker: async (id: string, props: Partial<MarkerProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updateMarker(id, props);\n },\n /**\n * 添加折线覆盖物到地图\n * @param id - 折线的唯一标识符\n * @param props - 折线的配置属性\n * @returns Promise<void> 添加操作的异步结果\n * @throws 如果地图视图未初始化则抛出错误\n */\n addPolyline: async (id: string, props: PolylineProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addPolyline(id, props);\n },\n /**\n * 移除地图上的指定折线\n * @param id - 要移除的折线的唯一标识符\n * @throws 如果地图视图未初始化,抛出错误\n * @returns Promise<void>\n */\n removePolyline: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removePolyline(id);\n },\n /**\n * 更新地图上的折线覆盖物\n * \n * @param id 要更新的折线覆盖物的唯一标识符\n * @param props 要更新的折线属性,包含部分PolylineProps属性\n * @returns Promise<void> 异步操作结果\n * @throws 如果地图视图未初始化,抛出错误\n */\n updatePolyline: async (id: string, props: Partial<PolylineProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updatePolyline(id, props);\n },\n /**\n * 向地图添加多边形覆盖物\n * @param id - 多边形的唯一标识符\n * @param props - 多边形的配置属性\n * @returns Promise<void> 添加操作的异步结果\n * @throws 如果地图视图未初始化则抛出错误\n */\n addPolygon: async (id: string, props: PolygonProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addPolygon(id, props);\n },\n /**\n * 移除地图上的多边形覆盖物\n * @param id - 要移除的多边形覆盖物的唯一标识符\n * @throws 如果地图视图未初始化,抛出错误 'MapView not initialized'\n * @returns Promise<void> 异步操作完成\n */\n removePolygon: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removePolygon(id);\n },\n /**\n * 更新多边形覆盖物的属性\n * \n * @param id - 要更新的多边形覆盖物的唯一标识符\n * @param props - 要更新的多边形属性对象,包含需要更新的部分属性\n * @throws {Error} 当地图视图未初始化时抛出错误\n * @returns Promise<void> 异步操作完成后的Promise\n */\n updatePolygon: async (id: string, props: Partial<PolygonProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updatePolygon(id, props);\n },\n }), []);\n\n /**\n * 将传入的apiRef赋值给internalRef.current\n * 用于在组件内部保存对地图API实例的引用\n */\n React.useEffect(() => {\n internalRef.current = apiRef;\n }, [apiRef]);\n\n /**\n * 获取当前地图实例的API引用\n * @returns 返回地图API的引用对象,可用于调用地图相关方法\n */\n React.useImperativeHandle(ref, () => apiRef, [apiRef]);\n\n return (\n <MapContext.Provider value={internalRef}>\n <MarkerEventContext.Provider value={markerEventManager}>\n <CircleEventContext.Provider value={circleEventManager}>\n <PolygonEventContext.Provider value={polygonEventManager}>\n <PolylineEventContext.Provider value={polylineEventManager}>\n <NativeView\n ref={nativeRef}\n {...props}\n onMarkerPress={handleMarkerPress}\n onMarkerDragStart={handleMarkerDragStart}\n onMarkerDrag={handleMarkerDrag}\n onMarkerDragEnd={handleMarkerDragEnd}\n onCirclePress={handleCirclePress}\n onPolygonPress={handlePolygonPress}\n onPolylinePress={handlePolylinePress}\n >\n {props.children}\n </NativeView>\n </PolylineEventContext.Provider>\n </PolygonEventContext.Provider>\n </CircleEventContext.Provider>\n </MarkerEventContext.Provider>\n </MapContext.Provider>\n );\n});\n\nExpoGaodeMapView.displayName = 'ExpoGaodeMapView';\n\nexport default ExpoGaodeMapView;\n"]}
|
|
@@ -38,7 +38,7 @@ function MarkerDeclarative(props) {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
}, [eventManager, props.onPress, props.onDragStart, props.onDrag, props.onDragEnd]);
|
|
41
|
-
return (<NativeMarkerView position={props.position} title={props.title} snippet={props.snippet} draggable={props.draggable} icon={props.icon} iconWidth={props.iconWidth || 0} // 传递原始的 iconWidth(用于自定义图标)
|
|
41
|
+
return (<NativeMarkerView latitude={props.position.latitude} longitude={props.position.longitude} title={props.title} snippet={props.snippet} draggable={props.draggable} icon={props.icon} iconWidth={props.iconWidth || 0} // 传递原始的 iconWidth(用于自定义图标)
|
|
42
42
|
iconHeight={props.iconHeight || 0} // 传递原始的 iconHeight(用于自定义图标)
|
|
43
43
|
customViewWidth={containerWidth} // 新增:自定义视图宽度
|
|
44
44
|
customViewHeight={containerHeight} // 新增:自定义视图高度
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Marker.js","sourceRoot":"","sources":["../../../src/components/overlays/Marker.tsx"],"names":[],"mappings":"AA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OAAO,EAAE;gBACzC,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,SAAS,EAAE,KAAK,CAAC,SAAS;aAC3B,CAAC,CAAC;QACL,CAAC;IACH,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IAEpF,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,MAAM;QACN,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,eAAe;QACrB,KAAK,CAAC,gBAAgB;QACtB,KAAK,CAAC,QAAQ;KACf,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import * as React from 'react';\nimport { Image } from 'react-native';\nimport { requireNativeViewManager } from 'expo-modules-core';\nimport { MapContext, MarkerEventContext } from '../../ExpoGaodeMapView';\nimport type { MarkerProps } from '../../types';\n\nconst NativeMarkerView = requireNativeViewManager('MarkerView');\n\nexport default function Marker(props: MarkerProps) {\n // 如果有 children,使用声明式 API\n if (props.children) {\n return <MarkerDeclarative {...props} />;\n }\n // 否则使用命令式 API\n return <MarkerImperative {...props} />;\n}\n\nfunction MarkerDeclarative(props: MarkerProps) {\n const eventManager = React.useContext(MarkerEventContext);\n const markerIdRef = React.useRef(`marker_${Date.now()}_${Math.random()}`);\n \n // 根据是否有 children 来决定使用哪个尺寸属性\n // 有 children:使用 customViewWidth/customViewHeight(默认 80x30)\n // 无 children:使用 iconWidth/iconHeight(用于自定义图标)\n const containerWidth = props.children\n ? (props.customViewWidth && props.customViewWidth > 0 ? props.customViewWidth : 80)\n : (props.iconWidth || 0);\n const containerHeight = props.children\n ? (props.customViewHeight && props.customViewHeight > 0 ? props.customViewHeight : 30)\n : (props.iconHeight || 0);\n \n React.useEffect(() => {\n if (eventManager) {\n eventManager.register(markerIdRef.current, {\n onPress: props.onPress,\n onDragStart: props.onDragStart,\n onDrag: props.onDrag,\n onDragEnd: props.onDragEnd,\n });\n }\n return () => {\n if (eventManager) {\n eventManager.unregister(markerIdRef.current);\n }\n };\n }, [eventManager, props.onPress, props.onDragStart, props.onDrag, props.onDragEnd]);\n \n return (\n <NativeMarkerView\n position={props.position}\n title={props.title}\n snippet={props.snippet}\n draggable={props.draggable}\n icon={props.icon}\n iconWidth={props.iconWidth || 0} // 传递原始的 iconWidth(用于自定义图标)\n iconHeight={props.iconHeight || 0} // 传递原始的 iconHeight(用于自定义图标)\n customViewWidth={containerWidth} // 新增:自定义视图宽度\n customViewHeight={containerHeight} // 新增:自定义视图高度\n pinColor={props.pinColor}\n animatesDrop={props.animatesDrop}\n centerOffset={props.centerOffset}\n opacity={props.opacity}\n flat={props.flat}\n zIndex={props.zIndex}\n anchor={props.anchor}\n style={{ width: containerWidth, height: containerHeight }}\n >\n {props.children}\n </NativeMarkerView>\n );\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 && eventManager) {\n eventManager.register(markerIdRef.current, {\n onPress: props.onPress,\n onDragStart: props.onDragStart,\n onDrag: props.onDrag,\n onDragEnd: props.onDragEnd,\n });\n }\n }, [eventManager, props.onPress, props.onDragStart, props.onDrag, props.onDragEnd]);\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 mapRef,\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.customViewWidth,\n props.customViewHeight,\n props.pinColor\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,KAAK,CAAC,eAAe;QACrB,KAAK,CAAC,gBAAgB;QACtB,KAAK,CAAC,QAAQ;KACf,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import * as React from 'react';\nimport { Image } from 'react-native';\nimport { requireNativeViewManager } from 'expo-modules-core';\nimport { MapContext, MarkerEventContext } from '../../ExpoGaodeMapView';\nimport type { MarkerProps } from '../../types';\n\nconst NativeMarkerView = requireNativeViewManager('MarkerView');\n\nexport default function Marker(props: MarkerProps) {\n // 如果有 children,使用声明式 API\n if (props.children) {\n return <MarkerDeclarative {...props} />;\n }\n // 否则使用命令式 API\n return <MarkerImperative {...props} />;\n}\n\nfunction MarkerDeclarative(props: MarkerProps) {\n const eventManager = React.useContext(MarkerEventContext);\n const markerIdRef = React.useRef(`marker_${Date.now()}_${Math.random()}`);\n \n // 根据是否有 children 来决定使用哪个尺寸属性\n // 有 children:使用 customViewWidth/customViewHeight(默认 80x30)\n // 无 children:使用 iconWidth/iconHeight(用于自定义图标)\n const containerWidth = props.children\n ? (props.customViewWidth && props.customViewWidth > 0 ? props.customViewWidth : 80)\n : (props.iconWidth || 0);\n const containerHeight = props.children\n ? (props.customViewHeight && props.customViewHeight > 0 ? props.customViewHeight : 30)\n : (props.iconHeight || 0);\n \n React.useEffect(() => {\n if (eventManager) {\n eventManager.register(markerIdRef.current, {\n onPress: props.onPress,\n onDragStart: props.onDragStart,\n onDrag: props.onDrag,\n onDragEnd: props.onDragEnd,\n });\n }\n return () => {\n if (eventManager) {\n eventManager.unregister(markerIdRef.current);\n }\n };\n }, [eventManager, props.onPress, props.onDragStart, props.onDrag, props.onDragEnd]);\n \n return (\n <NativeMarkerView\n latitude={props.position.latitude}\n longitude={props.position.longitude}\n title={props.title}\n snippet={props.snippet}\n draggable={props.draggable}\n icon={props.icon}\n iconWidth={props.iconWidth || 0} // 传递原始的 iconWidth(用于自定义图标)\n iconHeight={props.iconHeight || 0} // 传递原始的 iconHeight(用于自定义图标)\n customViewWidth={containerWidth} // 新增:自定义视图宽度\n customViewHeight={containerHeight} // 新增:自定义视图高度\n pinColor={props.pinColor}\n animatesDrop={props.animatesDrop}\n centerOffset={props.centerOffset}\n opacity={props.opacity}\n flat={props.flat}\n zIndex={props.zIndex}\n anchor={props.anchor}\n style={{ width: containerWidth, height: containerHeight }}\n >\n {props.children}\n </NativeMarkerView>\n );\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 && eventManager) {\n eventManager.register(markerIdRef.current, {\n onPress: props.onPress,\n onDragStart: props.onDragStart,\n onDrag: props.onDrag,\n onDragEnd: props.onDragEnd,\n });\n }\n }, [eventManager, props.onPress, props.onDragStart, props.onDrag, props.onDragEnd]);\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 mapRef,\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.customViewWidth,\n props.customViewHeight,\n props.pinColor\n ]);\n \n return null;\n}\n\n"]}
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
* 高德地图视图相关类型定义
|
|
3
3
|
* 基于 Expo Modules API
|
|
4
4
|
*/
|
|
5
|
-
import type { StyleProp, ViewStyle } from 'react-native';
|
|
5
|
+
import type { StyleProp, ViewStyle, NativeSyntheticEvent } from 'react-native';
|
|
6
6
|
import type { CameraPosition, LatLng, LatLngBounds, MapPoi, MapType, Point } from './common.types';
|
|
7
|
-
import type { Coordinates, ReGeocode } from './location.types';
|
|
8
7
|
/**
|
|
9
8
|
* 地图相机事件
|
|
10
9
|
*/
|
|
@@ -142,73 +141,73 @@ export interface MapViewProps {
|
|
|
142
141
|
/**
|
|
143
142
|
* 点击地图事件
|
|
144
143
|
*/
|
|
145
|
-
onMapPress?: (event: LatLng) => void;
|
|
144
|
+
onMapPress?: (event: NativeSyntheticEvent<LatLng>) => void;
|
|
146
145
|
/**
|
|
147
146
|
* 点击标注点事件
|
|
148
147
|
*/
|
|
149
|
-
onPressPoi?: (event: MapPoi) => void;
|
|
148
|
+
onPressPoi?: (event: NativeSyntheticEvent<MapPoi>) => void;
|
|
150
149
|
/**
|
|
151
150
|
* 长按地图事件
|
|
152
151
|
*/
|
|
153
|
-
onMapLongPress?: (event: LatLng) => void;
|
|
152
|
+
onMapLongPress?: (event: NativeSyntheticEvent<LatLng>) => void;
|
|
154
153
|
/**
|
|
155
154
|
* 地图状态改变事件(实时触发)
|
|
156
155
|
*/
|
|
157
|
-
onCameraMove?: (event: CameraEvent) => void;
|
|
156
|
+
onCameraMove?: (event: NativeSyntheticEvent<CameraEvent>) => void;
|
|
158
157
|
/**
|
|
159
158
|
* 地图状态改变完成事件
|
|
160
159
|
*/
|
|
161
|
-
onCameraIdle?: (event: CameraEvent) => void;
|
|
160
|
+
onCameraIdle?: (event: NativeSyntheticEvent<CameraEvent>) => void;
|
|
162
161
|
/**
|
|
163
162
|
* 地图加载完成事件
|
|
164
163
|
*/
|
|
165
|
-
onLoad?: (event: {}) => void;
|
|
164
|
+
onLoad?: (event: NativeSyntheticEvent<{}>) => void;
|
|
166
165
|
/**
|
|
167
166
|
* 地图定位更新事件
|
|
168
167
|
*/
|
|
169
|
-
onLocation?: (event:
|
|
168
|
+
onLocation?: (event: NativeSyntheticEvent<GeolocationPosition>) => void;
|
|
170
169
|
/**
|
|
171
170
|
* Marker 点击事件
|
|
172
171
|
*/
|
|
173
|
-
onMarkerPress?: (event: {
|
|
172
|
+
onMarkerPress?: (event: NativeSyntheticEvent<{
|
|
174
173
|
markerId: string;
|
|
175
|
-
} & LatLng) => void;
|
|
174
|
+
} & LatLng>) => void;
|
|
176
175
|
/**
|
|
177
176
|
* Marker 拖拽开始事件
|
|
178
177
|
*/
|
|
179
|
-
onMarkerDragStart?: (event: {
|
|
178
|
+
onMarkerDragStart?: (event: NativeSyntheticEvent<{
|
|
180
179
|
markerId: string;
|
|
181
|
-
} & LatLng) => void;
|
|
180
|
+
} & LatLng>) => void;
|
|
182
181
|
/**
|
|
183
182
|
* Marker 拖拽中事件
|
|
184
183
|
*/
|
|
185
|
-
onMarkerDrag?: (event: {
|
|
184
|
+
onMarkerDrag?: (event: NativeSyntheticEvent<{
|
|
186
185
|
markerId: string;
|
|
187
|
-
} & LatLng) => void;
|
|
186
|
+
} & LatLng>) => void;
|
|
188
187
|
/**
|
|
189
188
|
* Marker 拖拽结束事件
|
|
190
189
|
*/
|
|
191
|
-
onMarkerDragEnd?: (event: {
|
|
190
|
+
onMarkerDragEnd?: (event: NativeSyntheticEvent<{
|
|
192
191
|
markerId: string;
|
|
193
|
-
} & LatLng) => void;
|
|
192
|
+
} & LatLng>) => void;
|
|
194
193
|
/**
|
|
195
194
|
* Circle 点击事件
|
|
196
195
|
*/
|
|
197
|
-
onCirclePress?: (event: {
|
|
196
|
+
onCirclePress?: (event: NativeSyntheticEvent<{
|
|
198
197
|
circleId: string;
|
|
199
|
-
} & LatLng) => void;
|
|
198
|
+
} & LatLng>) => void;
|
|
200
199
|
/**
|
|
201
200
|
* Polygon 点击事件
|
|
202
201
|
*/
|
|
203
|
-
onPolygonPress?: (event: {
|
|
202
|
+
onPolygonPress?: (event: NativeSyntheticEvent<{
|
|
204
203
|
polygonId: string;
|
|
205
|
-
} & LatLng) => void;
|
|
204
|
+
} & LatLng>) => void;
|
|
206
205
|
/**
|
|
207
206
|
* Polyline 点击事件
|
|
208
207
|
*/
|
|
209
|
-
onPolylinePress?: (event: {
|
|
208
|
+
onPolylinePress?: (event: NativeSyntheticEvent<{
|
|
210
209
|
polylineId: string;
|
|
211
|
-
} & LatLng) => void;
|
|
210
|
+
} & LatLng>) => void;
|
|
212
211
|
/**
|
|
213
212
|
* 子组件
|
|
214
213
|
*/
|