expo-gaode-map 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import { requireNativeViewManager } from 'expo-modules-core';
2
2
  import * as React from 'react';
3
+ import { NativeSyntheticEvent } from 'react-native';
3
4
  import { EventManager } from './utils/EventManager';
4
5
  import type {
5
6
  MapViewProps,
@@ -21,14 +22,14 @@ const NativeView: React.ComponentType<MapViewProps & { ref?: React.Ref<NativeMap
21
22
  export const MapContext = React.createContext<React.RefObject<MapViewRef | null> | null>(null);
22
23
 
23
24
  type MarkerEventCallbacks = {
24
- onPress?: () => void;
25
- onDragStart?: () => void;
26
- onDrag?: () => void;
27
- onDragEnd?: (event: { nativeEvent: LatLng }) => void;
25
+ onPress?: (event: NativeSyntheticEvent<{}>) => void;
26
+ onDragStart?: (event: NativeSyntheticEvent<LatLng>) => void;
27
+ onDrag?: (event: NativeSyntheticEvent<LatLng>) => void;
28
+ onDragEnd?: (event: NativeSyntheticEvent<LatLng>) => void;
28
29
  };
29
30
 
30
31
  type OverlayEventCallbacks = {
31
- onPress?: () => void;
32
+ onPress?: (event: NativeSyntheticEvent<{}>) => void;
32
33
  };
33
34
 
34
35
  export const MarkerEventContext = React.createContext<EventManager<MarkerEventCallbacks> | null>(null);
@@ -63,50 +64,45 @@ const ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref)
63
64
  const polylineEventManager = React.useMemo(() => new EventManager<OverlayEventCallbacks>(), []);
64
65
  const handleMarkerPress = (event: any) => {
65
66
  const markerId = event.nativeEvent?.markerId;
66
- if (markerId) markerEventManager.trigger(markerId, 'onPress');
67
+ if (markerId) markerEventManager.trigger(markerId, 'onPress', event);
67
68
  props.onMarkerPress?.(event);
68
69
  };
69
70
 
70
71
  const handleMarkerDragStart = (event: any) => {
71
72
  const markerId = event.nativeEvent?.markerId;
72
- if (markerId) markerEventManager.trigger(markerId, 'onDragStart');
73
+ if (markerId) markerEventManager.trigger(markerId, 'onDragStart', event);
73
74
  props.onMarkerDragStart?.(event);
74
75
  };
75
76
 
76
77
  const handleMarkerDrag = (event: any) => {
77
78
  const markerId = event.nativeEvent?.markerId;
78
- if (markerId) markerEventManager.trigger(markerId, 'onDrag');
79
+ if (markerId) markerEventManager.trigger(markerId, 'onDrag', event);
79
80
  props.onMarkerDrag?.(event);
80
81
  };
81
82
 
82
83
  const handleMarkerDragEnd = (event: any) => {
83
84
  const markerId = event.nativeEvent?.markerId;
84
85
  if (markerId) {
85
- markerEventManager.trigger(markerId, 'onDragEnd', {
86
- nativeEvent: {
87
- latitude: event.nativeEvent.latitude,
88
- longitude: event.nativeEvent.longitude
89
- }
90
- });
86
+ markerEventManager.trigger(markerId, 'onDragEnd', event);
91
87
  }
92
88
  props.onMarkerDragEnd?.(event);
93
89
  };
94
90
 
95
91
  const handleCirclePress = (event: any) => {
96
92
  const circleId = event.nativeEvent?.circleId;
97
- if (circleId) circleEventManager.trigger(circleId, 'onPress');
93
+ if (circleId) circleEventManager.trigger(circleId, 'onPress', event);
98
94
  props.onCirclePress?.(event);
99
95
  };
100
96
 
101
97
  const handlePolygonPress = (event: any) => {
102
98
  const polygonId = event.nativeEvent?.polygonId;
103
- if (polygonId) polygonEventManager.trigger(polygonId, 'onPress');
99
+ if (polygonId) polygonEventManager.trigger(polygonId, 'onPress', event);
104
100
  props.onPolygonPress?.(event);
105
101
  };
106
102
 
107
103
  const handlePolylinePress = (event: any) => {
108
104
  const polylineId = event.nativeEvent?.polylineId;
109
- if (polylineId) polylineEventManager.trigger(polylineId, 'onPress');
105
+ if (polylineId) polylineEventManager.trigger(polylineId, 'onPress', event);
110
106
  props.onPolylinePress?.(event);
111
107
  };
112
108
 
@@ -3,9 +3,9 @@
3
3
  * 基于 Expo Modules API
4
4
  */
5
5
 
6
- import type { StyleProp, ViewStyle } from 'react-native';
6
+ import type { StyleProp, ViewStyle,NativeSyntheticEvent } from 'react-native';
7
7
  import type { CameraPosition, LatLng, LatLngBounds, MapPoi, MapType, Point } from './common.types';
8
- import type { Coordinates, ReGeocode } from './location.types';
8
+
9
9
 
10
10
  /**
11
11
  * 地图相机事件
@@ -168,72 +168,72 @@ export interface MapViewProps {
168
168
  /**
169
169
  * 点击地图事件
170
170
  */
171
- onMapPress?: (event: LatLng) => void;
171
+ onMapPress?: (event: NativeSyntheticEvent<LatLng>) => void;
172
172
 
173
173
  /**
174
174
  * 点击标注点事件
175
175
  */
176
- onPressPoi?: (event: MapPoi) => void;
176
+ onPressPoi?: (event: NativeSyntheticEvent<MapPoi>) => void;
177
177
 
178
178
  /**
179
179
  * 长按地图事件
180
180
  */
181
- onMapLongPress?: (event: LatLng) => void;
181
+ onMapLongPress?: (event: NativeSyntheticEvent<LatLng>) => void;
182
182
 
183
183
  /**
184
184
  * 地图状态改变事件(实时触发)
185
185
  */
186
- onCameraMove?: (event: CameraEvent) => void;
186
+ onCameraMove?: (event: NativeSyntheticEvent<CameraEvent>) => void;
187
187
 
188
188
  /**
189
189
  * 地图状态改变完成事件
190
190
  */
191
- onCameraIdle?: (event: CameraEvent) => void;
191
+ onCameraIdle?: (event: NativeSyntheticEvent<CameraEvent>) => void;
192
192
 
193
193
  /**
194
194
  * 地图加载完成事件
195
195
  */
196
- onLoad?: (event: {}) => void;
196
+ onLoad?: (event: NativeSyntheticEvent<{}>) => void;
197
197
 
198
198
  /**
199
199
  * 地图定位更新事件
200
200
  */
201
- onLocation?: (event: Coordinates | ReGeocode) => void;
201
+ onLocation?: (event: NativeSyntheticEvent<GeolocationPosition>) => void;
202
202
 
203
203
  /**
204
204
  * Marker 点击事件
205
205
  */
206
- onMarkerPress?: (event: { markerId: string } & LatLng) => void;
206
+ onMarkerPress?: (event: NativeSyntheticEvent<{ markerId: string } & LatLng>) => void;
207
207
 
208
208
  /**
209
209
  * Marker 拖拽开始事件
210
210
  */
211
- onMarkerDragStart?: (event: { markerId: string } & LatLng) => void;
211
+ onMarkerDragStart?: (event: NativeSyntheticEvent<{ markerId: string } & LatLng>) => void;
212
212
 
213
213
  /**
214
214
  * Marker 拖拽中事件
215
215
  */
216
- onMarkerDrag?: (event: { markerId: string } & LatLng) => void;
216
+ onMarkerDrag?: (event: NativeSyntheticEvent<{ markerId: string } & LatLng>) => void;
217
217
 
218
218
  /**
219
219
  * Marker 拖拽结束事件
220
220
  */
221
- onMarkerDragEnd?: (event: { markerId: string } & LatLng) => void;
221
+ onMarkerDragEnd?: (event: NativeSyntheticEvent<{ markerId: string } & LatLng>) => void;
222
222
 
223
223
  /**
224
224
  * Circle 点击事件
225
225
  */
226
- onCirclePress?: (event: { circleId: string } & LatLng) => void;
226
+ onCirclePress?: (event: NativeSyntheticEvent<{ circleId: string } & LatLng>) => void;
227
227
 
228
228
  /**
229
229
  * Polygon 点击事件
230
230
  */
231
- onPolygonPress?: (event: { polygonId: string } & LatLng) => void;
231
+ onPolygonPress?: (event: NativeSyntheticEvent<{ polygonId: string } & LatLng>) => void;
232
232
 
233
233
  /**
234
234
  * Polyline 点击事件
235
235
  */
236
- onPolylinePress?: (event: { polylineId: string } & LatLng) => void;
236
+ onPolylinePress?: (event: NativeSyntheticEvent<{ polylineId: string } & LatLng>) => void;
237
237
 
238
238
  /**
239
239
  * 子组件
@@ -3,7 +3,7 @@
3
3
  * 基于 Expo Modules API
4
4
  */
5
5
 
6
- import type { ImageSourcePropType, ViewStyle } from 'react-native';
6
+ import type { ImageSourcePropType, ViewStyle, NativeSyntheticEvent } from 'react-native';
7
7
  import type { ColorValue, LatLng, Point } from './common.types';
8
8
 
9
9
  /**
@@ -116,22 +116,22 @@ export interface MarkerProps {
116
116
  /**
117
117
  * 点击事件
118
118
  */
119
- onPress?: () => void;
119
+ onPress?: (event: NativeSyntheticEvent<{}>) => void;
120
120
 
121
121
  /**
122
122
  * 拖拽开始事件
123
123
  */
124
- onDragStart?: () => void;
124
+ onDragStart?: (event: NativeSyntheticEvent<LatLng>) => void;
125
125
 
126
126
  /**
127
127
  * 拖拽中事件
128
128
  */
129
- onDrag?: () => void;
129
+ onDrag?: (event: NativeSyntheticEvent<LatLng>) => void;
130
130
 
131
131
  /**
132
132
  * 拖拽结束事件
133
133
  */
134
- onDragEnd?: (event: { nativeEvent: LatLng }) => void;
134
+ onDragEnd?: (event: NativeSyntheticEvent<LatLng>) => void;
135
135
  }
136
136
 
137
137
  /**
@@ -193,7 +193,7 @@ export interface PolylineProps {
193
193
  /**
194
194
  * 点击事件
195
195
  */
196
- onPress?: () => void;
196
+ onPress?: (event: NativeSyntheticEvent<{}>) => void;
197
197
  }
198
198
 
199
199
  /**
@@ -228,7 +228,7 @@ export interface PolygonProps {
228
228
  /**
229
229
  * 点击事件
230
230
  */
231
- onPress?: () => void;
231
+ onPress?: (event: NativeSyntheticEvent<{}>) => void;
232
232
  }
233
233
 
234
234
  /**
@@ -268,7 +268,7 @@ export interface CircleProps {
268
268
  /**
269
269
  * 点击事件
270
270
  */
271
- onPress?: () => void;
271
+ onPress?: (event: NativeSyntheticEvent<{}>) => void;
272
272
 
273
273
  /**
274
274
  * 自定义子元素
@@ -330,7 +330,7 @@ export interface MultiPointProps {
330
330
  /**
331
331
  * 点击事件
332
332
  */
333
- onPress?: (event: { nativeEvent: { index: number; item: MultiPointItem } }) => void;
333
+ onPress?: (event: NativeSyntheticEvent<{ index: number; item: MultiPointItem }>) => void;
334
334
  }
335
335
 
336
336
  /**
@@ -405,5 +405,5 @@ export interface ClusterProps {
405
405
  /**
406
406
  * 聚合点点击事件
407
407
  */
408
- onPress?: (params: ClusterParams) => void;
408
+ onPress?: (event: NativeSyntheticEvent<ClusterParams>) => void;
409
409
  }