expo-gaode-map 1.1.7 → 1.1.8
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 -1
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapView.kt +34 -3
- package/build/ExpoGaodeMapView.d.ts.map +1 -1
- package/build/ExpoGaodeMapView.js +12 -0
- package/build/ExpoGaodeMapView.js.map +1 -1
- package/build/components/overlays/Circle.d.ts +1 -2
- package/build/components/overlays/Circle.d.ts.map +1 -1
- package/build/components/overlays/Circle.js +2 -31
- package/build/components/overlays/Circle.js.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/index.js.map +1 -1
- package/build/types/map-view.types.d.ts +36 -22
- 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 +2 -7
- package/build/types/overlays.types.d.ts.map +1 -1
- package/build/types/overlays.types.js.map +1 -1
- package/package.json +1 -1
- package/src/ExpoGaodeMapView.tsx +14 -3
- package/src/components/overlays/Circle.tsx +3 -39
- package/src/types/index.ts +1 -1
- package/src/types/map-view.types.ts +39 -23
- package/src/types/overlays.types.ts +2 -7
- package/test/ClockMapView.tsx +0 -532
- package/test/useMap.ts +0 -1360
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlays.types.d.ts","sourceRoot":"","sources":["../../src/types/overlays.types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAA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AAE,YAAY,EAAE,CAAC;IAEvB;;OAEG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,KAAK,CAAC,SAAS,CAAC;IAEtD;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,KAAK,CAAC,SAAS,CAAC;IAE3D;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;CAChE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlays.types.js","sourceRoot":"","sources":["../../src/types/overlays.types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * 高德地图覆盖物相关类型定义\n * 基于 Expo Modules API\n */\n\nimport type { ImageSourcePropType, ViewStyle, NativeSyntheticEvent } from 'react-native';\nimport type { ColorValue, LatLng, Point } from './common.types';\n\n/**\n * 标记点属性\n */\nexport interface MarkerProps {\n /**\n * 坐标\n */\n position: LatLng;\n\n /**\n * 图标\n */\n icon?: string | ImageSourcePropType;\n\n /**\n * 图标宽度(像素)\n * 仅在使用 icon 属性时有效\n */\n iconWidth?: number;\n\n /**\n * 图标高度(像素)\n * 仅在使用 icon 属性时有效\n */\n iconHeight?: number;\n\n /**\n * 标题\n */\n title?: string;\n\n /**\n * 描述\n */\n snippet?: string;\n\n /**\n * 透明度 [0, 1]\n * @platform android\n * @note iOS 不支持\n */\n opacity?: number;\n\n /**\n * 是否可拖拽\n */\n draggable?: boolean;\n\n /**\n * 是否平贴地图\n * @platform android\n * @note iOS 不支持\n */\n flat?: boolean;\n\n /**\n * 层级\n * @platform android\n * @note iOS 不支持 (使用 displayPriority)\n */\n zIndex?: number;\n\n /**\n * 覆盖物锚点比例\n * @platform android\n * @note iOS 使用 centerOffset\n */\n anchor?: Point;\n\n /**\n * 覆盖物偏移位置\n * @platform ios\n */\n centerOffset?: Point;\n\n /**\n * 是否显示动画\n * @platform ios\n */\n animatesDrop?: boolean;\n\n /**\n * 大头针颜色\n *
|
|
1
|
+
{"version":3,"file":"overlays.types.js","sourceRoot":"","sources":["../../src/types/overlays.types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * 高德地图覆盖物相关类型定义\n * 基于 Expo Modules API\n */\n\nimport type { ImageSourcePropType, ViewStyle, NativeSyntheticEvent } from 'react-native';\nimport type { ColorValue, LatLng, Point } from './common.types';\n\n/**\n * 标记点属性\n */\nexport interface MarkerProps {\n /**\n * 坐标\n */\n position: LatLng;\n\n /**\n * 图标\n */\n icon?: string | ImageSourcePropType;\n\n /**\n * 图标宽度(像素)\n * 仅在使用 icon 属性时有效\n */\n iconWidth?: number;\n\n /**\n * 图标高度(像素)\n * 仅在使用 icon 属性时有效\n */\n iconHeight?: number;\n\n /**\n * 标题\n */\n title?: string;\n\n /**\n * 描述\n */\n snippet?: string;\n\n /**\n * 透明度 [0, 1]\n * @platform android\n * @note iOS 不支持\n */\n opacity?: number;\n\n /**\n * 是否可拖拽\n */\n draggable?: boolean;\n\n /**\n * 是否平贴地图\n * @platform android\n * @note iOS 不支持\n */\n flat?: boolean;\n\n /**\n * 层级\n * @platform android\n * @note iOS 不支持 (使用 displayPriority)\n */\n zIndex?: number;\n\n /**\n * 覆盖物锚点比例\n * @platform android\n * @note iOS 使用 centerOffset\n */\n anchor?: Point;\n\n /**\n * 覆盖物偏移位置\n * @platform ios\n */\n centerOffset?: Point;\n\n /**\n * 是否显示动画\n * @platform ios\n */\n animatesDrop?: boolean;\n\n /**\n * 大头针颜色\n * Android 支持更多颜色,iOS 只支持 red, green, purple\n */\n pinColor?: 'red' | 'orange' | 'yellow' | 'green' | 'cyan' | 'blue' | 'violet' | 'magenta' | 'rose' | 'purple';\n\n /**\n * 自定义视图\n * 当使用 children 时,会将 React Native 组件渲染为图片显示在地图上\n */\n children?: React.ReactNode;\n\n /**\n * 自定义视图宽度(像素)\n * 仅在使用 children 属性时有效 \n * @default 80\n */\n customViewWidth?: number;\n\n /**\n * 自定义视图高度(像素)\n * 仅在使用 children 属性时有效\n * @default 30\n */\n customViewHeight?: number;\n\n /**\n * 点击事件\n */\n onPress?: (event: NativeSyntheticEvent<{}>) => void;\n\n /**\n * 拖拽开始事件\n */\n onDragStart?: (event: NativeSyntheticEvent<LatLng>) => void;\n\n /**\n * 拖拽中事件\n */\n onDrag?: (event: NativeSyntheticEvent<LatLng>) => void;\n\n /**\n * 拖拽结束事件\n */\n onDragEnd?: (event: NativeSyntheticEvent<LatLng>) => void;\n}\n\n/**\n * 折线属性\n */\nexport interface PolylineProps {\n /**\n * 节点坐标数组\n */\n points: LatLng[];\n\n /**\n * 线宽\n */\n width?: number;\n\n /**\n * 线条颜色\n */\n color?: ColorValue;\n\n /**\n * 层级\n */\n zIndex?: number;\n\n /**\n * 分段颜色\n */\n colors?: ColorValue[];\n\n /**\n * 是否使用渐变色\n * @platform android\n * @note iOS 不支持\n */\n gradient?: boolean;\n\n /**\n * 是否绘制大地线\n * @platform android\n * @note iOS 不支持\n */\n geodesic?: boolean;\n\n /**\n * 是否绘制虚线\n * @platform android\n * @note iOS 不支持\n */\n dotted?: boolean;\n\n /**\n * 纹理图片\n * 支持网络图片(http/https)、本地文件(file://)或资源名称\n */\n texture?: string;\n\n /**\n * 点击事件\n */\n onPress?: (event: NativeSyntheticEvent<{}>) => void;\n}\n\n/**\n * 多边形属性\n */\nexport interface PolygonProps {\n /**\n * 节点坐标数组\n */\n points: LatLng[];\n\n /**\n * 边线宽度\n */\n strokeWidth?: number;\n\n /**\n * 边线颜色\n */\n strokeColor?: ColorValue;\n\n /**\n * 填充颜色\n */\n fillColor?: ColorValue;\n\n /**\n * 层级\n */\n zIndex?: number;\n\n /**\n * 点击事件\n */\n onPress?: (event: NativeSyntheticEvent<{}>) => void;\n}\n\n/**\n * 圆形属性\n */\nexport interface CircleProps {\n /**\n * 圆心坐标\n */\n center: LatLng;\n\n /**\n * 半径(米)\n */\n radius: number;\n\n /**\n * 边线宽度\n */\n strokeWidth?: number;\n\n /**\n * 边线颜色\n */\n strokeColor?: ColorValue;\n\n /**\n * 填充颜色\n */\n fillColor?: ColorValue;\n\n /**\n * 层级\n */\n zIndex?: number;\n\n /**\n * 点击事件\n */\n onPress?: (event: NativeSyntheticEvent<{}>) => void;\n\n\n}\n\n/**\n * 热力图属性\n */\nexport interface HeatMapProps {\n /**\n * 热力点数据\n */\n data: LatLng[];\n\n /**\n * 热力半径(米)\n */\n radius?: number;\n\n /**\n * 透明度 [0, 1]\n */\n opacity?: number;\n}\n\n/**\n * 海量点标记项\n */\nexport interface MultiPointItem extends LatLng {\n /**\n * 唯一标识\n */\n id?: string | number;\n\n /**\n * 自定义数据\n */\n data?: any;\n}\n\n/**\n * 海量点属性\n */\nexport interface MultiPointProps {\n /**\n * 点集合\n */\n items: MultiPointItem[];\n\n /**\n * 图标\n */\n icon?: ImageSourcePropType;\n\n /**\n * 点击事件\n */\n onPress?: (event: NativeSyntheticEvent<{ index: number; item: MultiPointItem }>) => void;\n}\n\n/**\n * 聚合点参数\n */\nexport interface ClusterParams {\n /**\n * 唯一标识\n */\n id: number;\n\n /**\n * 包含的标记点数量\n */\n count: number;\n\n /**\n * 聚合点坐标\n */\n position: LatLng;\n}\n\n/**\n * 聚合点项\n */\nexport interface ClusterPoint {\n /**\n * 坐标\n */\n position: LatLng;\n\n /**\n * 自定义数据\n */\n properties?: any;\n}\n\n/**\n * 聚合图层属性\n */\nexport interface ClusterProps {\n /**\n * 聚合半径\n */\n radius?: number;\n\n /**\n * 聚合点样式\n */\n clusterStyle?: ViewStyle;\n\n /**\n * 聚合点文本样式\n */\n clusterTextStyle?: ViewStyle;\n\n /**\n * 坐标点列表\n */\n points: ClusterPoint[];\n\n /**\n * 渲染标记点\n */\n renderMarker: (item: ClusterPoint) => React.ReactNode;\n\n /**\n * 渲染聚合点\n */\n renderCluster?: (params: ClusterParams) => React.ReactNode;\n\n /**\n * 聚合点点击事件\n */\n onPress?: (event: NativeSyntheticEvent<ClusterParams>) => void;\n}\n"]}
|
package/package.json
CHANGED
package/src/ExpoGaodeMapView.tsx
CHANGED
|
@@ -5,7 +5,6 @@ import { EventManager } from './utils/EventManager';
|
|
|
5
5
|
import type {
|
|
6
6
|
MapViewProps,
|
|
7
7
|
MapViewRef,
|
|
8
|
-
NativeMapViewRef,
|
|
9
8
|
CameraPosition,
|
|
10
9
|
LatLng,
|
|
11
10
|
Point,
|
|
@@ -17,7 +16,7 @@ import type {
|
|
|
17
16
|
|
|
18
17
|
export type { MapViewRef } from './types';
|
|
19
18
|
|
|
20
|
-
const NativeView: React.ComponentType<MapViewProps & { ref?: React.Ref<
|
|
19
|
+
const NativeView: React.ComponentType<MapViewProps & { ref?: React.Ref<MapViewRef> }> = requireNativeViewManager('ExpoGaodeMapView');
|
|
21
20
|
|
|
22
21
|
export const MapContext = React.createContext<React.RefObject<MapViewRef | null> | null>(null);
|
|
23
22
|
|
|
@@ -56,7 +55,7 @@ export const PolylineEventContext = React.createContext<EventManager<OverlayEven
|
|
|
56
55
|
* 所有API方法都会检查地图是否已初始化,未初始化时抛出错误
|
|
57
56
|
*/
|
|
58
57
|
const ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref) => {
|
|
59
|
-
const nativeRef = React.useRef<
|
|
58
|
+
const nativeRef = React.useRef<MapViewRef>(null);
|
|
60
59
|
const internalRef = React.useRef<MapViewRef | null>(null);
|
|
61
60
|
const markerEventManager = React.useMemo(() => new EventManager<MarkerEventCallbacks>(), []);
|
|
62
61
|
const circleEventManager = React.useMemo(() => new EventManager<OverlayEventCallbacks>(), []);
|
|
@@ -163,6 +162,7 @@ const ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref)
|
|
|
163
162
|
* @param props - 圆形覆盖物的属性配置
|
|
164
163
|
* @returns Promise<void> 添加操作的异步结果
|
|
165
164
|
* @throws 如果地图视图未初始化,抛出错误'MapView not initialized'
|
|
165
|
+
* @deprecated 该方法已被弃用,请使用声明式添加
|
|
166
166
|
*/
|
|
167
167
|
addCircle: async (id: string, props: CircleProps) => {
|
|
168
168
|
if (!nativeRef.current) throw new Error('MapView not initialized');
|
|
@@ -173,6 +173,7 @@ const ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref)
|
|
|
173
173
|
* @param id - 要移除的圆形覆盖物的唯一标识符
|
|
174
174
|
* @throws 如果地图视图未初始化,抛出错误
|
|
175
175
|
* @returns Promise<void> 异步操作完成
|
|
176
|
+
* @deprecated 该方法已被弃用,请使用声明式添加
|
|
176
177
|
*/
|
|
177
178
|
removeCircle: async (id: string) => {
|
|
178
179
|
if (!nativeRef.current) throw new Error('MapView not initialized');
|
|
@@ -184,6 +185,7 @@ const ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref)
|
|
|
184
185
|
* @param props 要更新的圆形属性(部分属性)
|
|
185
186
|
* @throws 如果地图视图未初始化,抛出错误
|
|
186
187
|
* @returns Promise<void> 表示更新操作完成
|
|
188
|
+
* @deprecated 该方法已被弃用,请使用声明式添加
|
|
187
189
|
*/
|
|
188
190
|
updateCircle: async (id: string, props: Partial<CircleProps>) => {
|
|
189
191
|
if (!nativeRef.current) throw new Error('MapView not initialized');
|
|
@@ -195,6 +197,7 @@ const ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref)
|
|
|
195
197
|
* @param props 标记点的配置属性
|
|
196
198
|
* @returns Promise<void> 添加操作完成后的Promise
|
|
197
199
|
* @throws 如果地图视图未初始化则抛出错误
|
|
200
|
+
* @deprecated 该方法已被弃用,请使用声明式添加
|
|
198
201
|
*/
|
|
199
202
|
addMarker: async (id: string, props: MarkerProps) => {
|
|
200
203
|
if (!nativeRef.current) throw new Error('MapView not initialized');
|
|
@@ -205,6 +208,7 @@ const ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref)
|
|
|
205
208
|
* @param id 要移除的标记点ID
|
|
206
209
|
* @throws 如果地图视图未初始化则抛出错误
|
|
207
210
|
* @returns Promise<void> 异步操作完成
|
|
211
|
+
* @deprecated 该方法已被弃用,请使用声明式添加
|
|
208
212
|
*/
|
|
209
213
|
removeMarker: async (id: string) => {
|
|
210
214
|
if (!nativeRef.current) throw new Error('MapView not initialized');
|
|
@@ -216,6 +220,7 @@ const ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref)
|
|
|
216
220
|
* @param props - 需要更新的标记点属性对象(部分属性)
|
|
217
221
|
* @throws 如果地图视图未初始化则抛出错误
|
|
218
222
|
* @returns Promise对象,表示异步更新操作
|
|
223
|
+
* @deprecated 该方法已被弃用,请使用声明式添加
|
|
219
224
|
*/
|
|
220
225
|
updateMarker: async (id: string, props: Partial<MarkerProps>) => {
|
|
221
226
|
if (!nativeRef.current) throw new Error('MapView not initialized');
|
|
@@ -227,6 +232,7 @@ const ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref)
|
|
|
227
232
|
* @param props - 折线的配置属性
|
|
228
233
|
* @returns Promise<void> 添加操作的异步结果
|
|
229
234
|
* @throws 如果地图视图未初始化则抛出错误
|
|
235
|
+
* @deprecated 该方法已被弃用,请使用声明式添加
|
|
230
236
|
*/
|
|
231
237
|
addPolyline: async (id: string, props: PolylineProps) => {
|
|
232
238
|
if (!nativeRef.current) throw new Error('MapView not initialized');
|
|
@@ -237,6 +243,7 @@ const ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref)
|
|
|
237
243
|
* @param id - 要移除的折线的唯一标识符
|
|
238
244
|
* @throws 如果地图视图未初始化,抛出错误
|
|
239
245
|
* @returns Promise<void>
|
|
246
|
+
* @deprecated 该方法已被弃用,请使用声明式添加
|
|
240
247
|
*/
|
|
241
248
|
removePolyline: async (id: string) => {
|
|
242
249
|
if (!nativeRef.current) throw new Error('MapView not initialized');
|
|
@@ -249,6 +256,7 @@ const ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref)
|
|
|
249
256
|
* @param props 要更新的折线属性,包含部分PolylineProps属性
|
|
250
257
|
* @returns Promise<void> 异步操作结果
|
|
251
258
|
* @throws 如果地图视图未初始化,抛出错误
|
|
259
|
+
* @deprecated 该方法已被弃用,请使用声明式添加
|
|
252
260
|
*/
|
|
253
261
|
updatePolyline: async (id: string, props: Partial<PolylineProps>) => {
|
|
254
262
|
if (!nativeRef.current) throw new Error('MapView not initialized');
|
|
@@ -260,6 +268,7 @@ const ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref)
|
|
|
260
268
|
* @param props - 多边形的配置属性
|
|
261
269
|
* @returns Promise<void> 添加操作的异步结果
|
|
262
270
|
* @throws 如果地图视图未初始化则抛出错误
|
|
271
|
+
* @deprecated 该方法已被弃用,请使用声明式添加
|
|
263
272
|
*/
|
|
264
273
|
addPolygon: async (id: string, props: PolygonProps) => {
|
|
265
274
|
if (!nativeRef.current) throw new Error('MapView not initialized');
|
|
@@ -270,6 +279,7 @@ const ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref)
|
|
|
270
279
|
* @param id - 要移除的多边形覆盖物的唯一标识符
|
|
271
280
|
* @throws 如果地图视图未初始化,抛出错误 'MapView not initialized'
|
|
272
281
|
* @returns Promise<void> 异步操作完成
|
|
282
|
+
* @deprecated 该方法已被弃用,请使用声明式添加
|
|
273
283
|
*/
|
|
274
284
|
removePolygon: async (id: string) => {
|
|
275
285
|
if (!nativeRef.current) throw new Error('MapView not initialized');
|
|
@@ -282,6 +292,7 @@ const ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref)
|
|
|
282
292
|
* @param props - 要更新的多边形属性对象,包含需要更新的部分属性
|
|
283
293
|
* @throws {Error} 当地图视图未初始化时抛出错误
|
|
284
294
|
* @returns Promise<void> 异步操作完成后的Promise
|
|
295
|
+
* @deprecated 该方法已被弃用,请使用声明式添加
|
|
285
296
|
*/
|
|
286
297
|
updatePolygon: async (id: string, props: Partial<PolygonProps>) => {
|
|
287
298
|
if (!nativeRef.current) throw new Error('MapView not initialized');
|
|
@@ -2,55 +2,19 @@
|
|
|
2
2
|
* @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
3
3
|
* @Date : 2025-11-13 15:02:04
|
|
4
4
|
* @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
5
|
-
* @LastEditTime : 2025-11-
|
|
5
|
+
* @LastEditTime : 2025-11-24 18:51:17
|
|
6
6
|
* @FilePath : /expo-gaode-map/src/components/overlays/Circle.tsx
|
|
7
7
|
* @Description :
|
|
8
8
|
*
|
|
9
9
|
* Copyright (c) 2025 by 尚博信_王强, All Rights Reserved.
|
|
10
10
|
*/
|
|
11
11
|
import * as React from 'react';
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
import type { CircleProps } from '../../types';
|
|
14
14
|
import { MapContext, CircleEventContext } from '../../ExpoGaodeMapView';
|
|
15
15
|
|
|
16
|
-
const NativeCircleView = requireNativeViewManager('CircleView');
|
|
17
|
-
|
|
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
16
|
|
|
53
|
-
function CircleImperative(props: CircleProps) {
|
|
17
|
+
export default function CircleImperative(props: CircleProps) {
|
|
54
18
|
const mapRef = React.useContext(MapContext);
|
|
55
19
|
const eventManager = React.useContext(CircleEventContext);
|
|
56
20
|
const circleIdRef = React.useRef<string | null>(null);
|
package/src/types/index.ts
CHANGED
|
@@ -289,39 +289,55 @@ export interface MapViewRef {
|
|
|
289
289
|
setCenter(center: LatLng, animated?: boolean): Promise<void>;
|
|
290
290
|
setZoom(zoom: number, animated?: boolean): Promise<void>;
|
|
291
291
|
getCameraPosition(): Promise<CameraPosition>;
|
|
292
|
+
/**
|
|
293
|
+
* @@deprecated 不推荐使用,请使用声明式添加
|
|
294
|
+
*/
|
|
292
295
|
addCircle(id: string, props: import('./overlays.types').CircleProps): Promise<void>;
|
|
296
|
+
/**
|
|
297
|
+
* @@deprecated 不推荐使用,请使用声明式添加
|
|
298
|
+
*/
|
|
293
299
|
removeCircle(id: string): Promise<void>;
|
|
300
|
+
/**
|
|
301
|
+
* @@deprecated 不推荐使用,请使用声明式添加
|
|
302
|
+
*/
|
|
294
303
|
updateCircle(id: string, props: Partial<import('./overlays.types').CircleProps>): Promise<void>;
|
|
304
|
+
/**
|
|
305
|
+
* @@deprecated 不推荐使用,请使用声明式添加
|
|
306
|
+
*/
|
|
295
307
|
addMarker(id: string, props: import('./overlays.types').MarkerProps): Promise<void>;
|
|
308
|
+
/**
|
|
309
|
+
* @@deprecated 不推荐使用,请使用声明式添加
|
|
310
|
+
*/
|
|
296
311
|
removeMarker(id: string): Promise<void>;
|
|
312
|
+
/**
|
|
313
|
+
* @@deprecated 不推荐使用,请使用声明式添加
|
|
314
|
+
*/
|
|
297
315
|
updateMarker(id: string, props: Partial<import('./overlays.types').MarkerProps>): Promise<void>;
|
|
316
|
+
/**
|
|
317
|
+
* @@deprecated 不推荐使用,请使用声明式添加
|
|
318
|
+
*/
|
|
298
319
|
addPolyline(id: string, props: import('./overlays.types').PolylineProps): Promise<void>;
|
|
320
|
+
/**
|
|
321
|
+
* @@deprecated 不推荐使用,请使用声明式添加
|
|
322
|
+
*/
|
|
299
323
|
removePolyline(id: string): Promise<void>;
|
|
300
|
-
|
|
324
|
+
/**
|
|
325
|
+
* @@deprecated 不推荐使用,请使用声明式添加
|
|
326
|
+
*/
|
|
327
|
+
updatePolyline(id: string, props: Partial<import('./overlays.types').PolylineProps>): Promise<void>;
|
|
328
|
+
/**
|
|
329
|
+
* @@deprecated 不推荐使用,请使用声明式添加
|
|
330
|
+
*/
|
|
301
331
|
addPolygon(id: string, props: import('./overlays.types').PolygonProps): Promise<void>;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* @@deprecated 不推荐使用,请使用声明式添加
|
|
335
|
+
*/
|
|
302
336
|
removePolygon(id: string): Promise<void>;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* @@deprecated 不推荐使用,请使用声明式添加
|
|
340
|
+
*/
|
|
303
341
|
updatePolygon(id: string, props: Partial<import('./overlays.types').PolygonProps>): Promise<void>;
|
|
304
342
|
}
|
|
305
343
|
|
|
306
|
-
/**
|
|
307
|
-
* 原生 MapView Ref 接口(所有参数必需)
|
|
308
|
-
*/
|
|
309
|
-
export interface NativeMapViewRef {
|
|
310
|
-
moveCamera(position: CameraPosition, duration: number): Promise<void>;
|
|
311
|
-
getLatLng(point: Point): Promise<LatLng>;
|
|
312
|
-
setCenter(center: LatLng, animated: boolean): Promise<void>;
|
|
313
|
-
setZoom(zoom: number, animated: boolean): Promise<void>;
|
|
314
|
-
getCameraPosition(): Promise<CameraPosition>;
|
|
315
|
-
addCircle(id: string, props: import('./overlays.types').CircleProps): Promise<void>;
|
|
316
|
-
removeCircle(id: string): Promise<void>;
|
|
317
|
-
updateCircle(id: string, props: Partial<import('./overlays.types').CircleProps>): Promise<void>;
|
|
318
|
-
addMarker(id: string, props: import('./overlays.types').MarkerProps): Promise<void>;
|
|
319
|
-
removeMarker(id: string): Promise<void>;
|
|
320
|
-
updateMarker(id: string, props: Partial<import('./overlays.types').MarkerProps>): Promise<void>;
|
|
321
|
-
addPolyline(id: string, props: import('./overlays.types').PolylineProps): Promise<void>;
|
|
322
|
-
removePolyline(id: string): Promise<void>;
|
|
323
|
-
updatePolyline(id: string, props: Partial<import('./overlays.types').PolylineProps>): Promise<void>;
|
|
324
|
-
addPolygon(id: string, props: import('./overlays.types').PolygonProps): Promise<void>;
|
|
325
|
-
removePolygon(id: string): Promise<void>;
|
|
326
|
-
updatePolygon(id: string, props: Partial<import('./overlays.types').PolygonProps>): Promise<void>;
|
|
327
|
-
}
|
|
@@ -89,9 +89,9 @@ export interface MarkerProps {
|
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* 大头针颜色
|
|
92
|
-
*
|
|
92
|
+
* Android 支持更多颜色,iOS 只支持 red, green, purple
|
|
93
93
|
*/
|
|
94
|
-
pinColor?: 'red' | 'green' | 'purple';
|
|
94
|
+
pinColor?: 'red' | 'orange' | 'yellow' | 'green' | 'cyan' | 'blue' | 'violet' | 'magenta' | 'rose' | 'purple';
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
97
|
* 自定义视图
|
|
@@ -270,11 +270,6 @@ export interface CircleProps {
|
|
|
270
270
|
*/
|
|
271
271
|
onPress?: (event: NativeSyntheticEvent<{}>) => void;
|
|
272
272
|
|
|
273
|
-
/**
|
|
274
|
-
* 自定义子元素
|
|
275
|
-
* 暂不支持
|
|
276
|
-
*/
|
|
277
|
-
children?: React.ReactNode;
|
|
278
273
|
|
|
279
274
|
}
|
|
280
275
|
|