expo-gaode-map 0.1.0
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/.eslintrc.js +5 -0
- package/PUBLISHING.md +244 -0
- package/README.md +990 -0
- package/android/build.gradle +48 -0
- package/android/src/main/AndroidManifest.xml +40 -0
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapModule.kt +455 -0
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapView.kt +337 -0
- package/android/src/main/java/expo/modules/gaodemap/managers/CameraManager.kt +128 -0
- package/android/src/main/java/expo/modules/gaodemap/managers/OverlayManager.kt +324 -0
- package/android/src/main/java/expo/modules/gaodemap/managers/UIManager.kt +122 -0
- package/android/src/main/java/expo/modules/gaodemap/modules/LocationManager.kt +247 -0
- package/android/src/main/java/expo/modules/gaodemap/modules/SDKInitializer.kt +45 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/CircleView.kt +151 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/ClusterView.kt +127 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/HeatMapView.kt +97 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerView.kt +204 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/MultiPointView.kt +103 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/PolygonView.kt +114 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/PolylineView.kt +138 -0
- package/build/ExpoGaodeMap.types.d.ts +24 -0
- package/build/ExpoGaodeMap.types.d.ts.map +1 -0
- package/build/ExpoGaodeMap.types.js +14 -0
- package/build/ExpoGaodeMap.types.js.map +1 -0
- package/build/ExpoGaodeMapModule.d.ts +7 -0
- package/build/ExpoGaodeMapModule.d.ts.map +1 -0
- package/build/ExpoGaodeMapModule.js +14 -0
- package/build/ExpoGaodeMapModule.js.map +1 -0
- package/build/ExpoGaodeMapView.d.ts +31 -0
- package/build/ExpoGaodeMapView.d.ts.map +1 -0
- package/build/ExpoGaodeMapView.js +141 -0
- package/build/ExpoGaodeMapView.js.map +1 -0
- package/build/components/overlays/Circle.d.ts +18 -0
- package/build/components/overlays/Circle.d.ts.map +1 -0
- package/build/components/overlays/Circle.js +63 -0
- package/build/components/overlays/Circle.js.map +1 -0
- package/build/components/overlays/Cluster.d.ts +22 -0
- package/build/components/overlays/Cluster.d.ts.map +1 -0
- package/build/components/overlays/Cluster.js +35 -0
- package/build/components/overlays/Cluster.js.map +1 -0
- package/build/components/overlays/HeatMap.d.ts +21 -0
- package/build/components/overlays/HeatMap.d.ts.map +1 -0
- package/build/components/overlays/HeatMap.js +34 -0
- package/build/components/overlays/HeatMap.js.map +1 -0
- package/build/components/overlays/Marker.d.ts +17 -0
- package/build/components/overlays/Marker.d.ts.map +1 -0
- package/build/components/overlays/Marker.js +57 -0
- package/build/components/overlays/Marker.js.map +1 -0
- package/build/components/overlays/MultiPoint.d.ts +21 -0
- package/build/components/overlays/MultiPoint.d.ts.map +1 -0
- package/build/components/overlays/MultiPoint.js +34 -0
- package/build/components/overlays/MultiPoint.js.map +1 -0
- package/build/components/overlays/Polygon.d.ts +22 -0
- package/build/components/overlays/Polygon.d.ts.map +1 -0
- package/build/components/overlays/Polygon.js +100 -0
- package/build/components/overlays/Polygon.js.map +1 -0
- package/build/components/overlays/Polyline.d.ts +20 -0
- package/build/components/overlays/Polyline.d.ts.map +1 -0
- package/build/components/overlays/Polyline.js +60 -0
- package/build/components/overlays/Polyline.js.map +1 -0
- package/build/components/overlays/index.d.ts +8 -0
- package/build/components/overlays/index.d.ts.map +1 -0
- package/build/components/overlays/index.js +18 -0
- package/build/components/overlays/index.js.map +1 -0
- package/build/index.d.ts +10 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +28 -0
- package/build/index.js.map +1 -0
- package/build/modules/AMapLocation.d.ts +58 -0
- package/build/modules/AMapLocation.d.ts.map +1 -0
- package/build/modules/AMapLocation.js +141 -0
- package/build/modules/AMapLocation.js.map +1 -0
- package/build/modules/AMapSDK.d.ts +27 -0
- package/build/modules/AMapSDK.d.ts.map +1 -0
- package/build/modules/AMapSDK.js +43 -0
- package/build/modules/AMapSDK.js.map +1 -0
- package/build/modules/AMapView.d.ts +39 -0
- package/build/modules/AMapView.d.ts.map +1 -0
- package/build/modules/AMapView.js +61 -0
- package/build/modules/AMapView.js.map +1 -0
- package/build/types/common.types.d.ts +133 -0
- package/build/types/common.types.d.ts.map +1 -0
- package/build/types/common.types.js +31 -0
- package/build/types/common.types.js.map +1 -0
- package/build/types/index.d.ts +12 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/index.js +17 -0
- package/build/types/index.js.map +1 -0
- package/build/types/location.types.d.ts +306 -0
- package/build/types/location.types.d.ts.map +1 -0
- package/build/types/location.types.js +93 -0
- package/build/types/location.types.js.map +1 -0
- package/build/types/map-view.types.d.ts +213 -0
- package/build/types/map-view.types.d.ts.map +1 -0
- package/build/types/map-view.types.js +6 -0
- package/build/types/map-view.types.js.map +1 -0
- package/build/types/overlays.types.d.ts +296 -0
- package/build/types/overlays.types.d.ts.map +1 -0
- package/build/types/overlays.types.js +6 -0
- package/build/types/overlays.types.js.map +1 -0
- package/build/types/sdk.types.d.ts +113 -0
- package/build/types/sdk.types.d.ts.map +1 -0
- package/build/types/sdk.types.js +6 -0
- package/build/types/sdk.types.js.map +1 -0
- package/docs/followUserLocation.md +186 -0
- package/expo-module.config.json +9 -0
- package/ios/ExpoGaodeMap.podspec +29 -0
- package/ios/ExpoGaodeMapModule.swift +48 -0
- package/ios/ExpoGaodeMapView.swift +38 -0
- package/package.json +45 -0
- package/src/ExpoGaodeMap.types.ts +68 -0
- package/src/ExpoGaodeMapModule.ts +21 -0
- package/src/ExpoGaodeMapView.tsx +151 -0
- package/src/components/overlays/Circle.tsx +73 -0
- package/src/components/overlays/Cluster.tsx +38 -0
- package/src/components/overlays/HeatMap.tsx +37 -0
- package/src/components/overlays/Marker.tsx +66 -0
- package/src/components/overlays/MultiPoint.tsx +37 -0
- package/src/components/overlays/Polygon.tsx +107 -0
- package/src/components/overlays/Polyline.tsx +69 -0
- package/src/components/overlays/index.ts +18 -0
- package/src/index.ts +55 -0
- package/src/modules/AMapLocation.ts +164 -0
- package/src/modules/AMapSDK.ts +48 -0
- package/src/modules/AMapView.ts +68 -0
- package/src/types/README.md +186 -0
- package/src/types/common.types.ts +155 -0
- package/src/types/index.ts +74 -0
- package/src/types/location.types.ts +364 -0
- package/src/types/map-view.types.ts +249 -0
- package/src/types/overlays.types.ts +346 -0
- package/src/types/sdk.types.ts +128 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
3
|
+
* @Date : 2025-11-13 15:01:45
|
|
4
|
+
* @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
5
|
+
* @LastEditTime : 2025-11-13 19:24:22
|
|
6
|
+
* @FilePath : /expo-gaode-map/src/components/overlays/Polygon.tsx
|
|
7
|
+
* @Description : 地图多边形组件 - 命令式 API
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2025 by 尚博信_王强, All Rights Reserved.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
import { useContext, useEffect, useRef } from 'react';
|
|
14
|
+
import type { PolygonProps } from '../../types';
|
|
15
|
+
import { MapContext } from '../../ExpoGaodeMapView';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 地图多边形组件 - 命令式 API
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <MapView>
|
|
23
|
+
* <Polygon
|
|
24
|
+
* points={[
|
|
25
|
+
* { latitude: 39.9, longitude: 116.4 },
|
|
26
|
+
* { latitude: 39.91, longitude: 116.41 },
|
|
27
|
+
* { latitude: 39.92, longitude: 116.40 },
|
|
28
|
+
* ]}
|
|
29
|
+
* fillColor={0x44FF0000}
|
|
30
|
+
* strokeColor={-65536}
|
|
31
|
+
* strokeWidth={5}
|
|
32
|
+
* />
|
|
33
|
+
* </MapView>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export default function Polygon(props: PolygonProps) {
|
|
37
|
+
const { points, fillColor, strokeColor, strokeWidth, zIndex } = props;
|
|
38
|
+
const nativeRef = useContext(MapContext);
|
|
39
|
+
const polygonIdRef = useRef<string>(`polygon_${Date.now()}_${Math.random()}`);
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const polygonId = polygonIdRef.current;
|
|
43
|
+
|
|
44
|
+
// 添加多边形
|
|
45
|
+
if (nativeRef?.current && points && points.length >= 3) {
|
|
46
|
+
try {
|
|
47
|
+
console.log('🟦 Polygon 组件调用 addPolygon:', polygonId, {
|
|
48
|
+
points,
|
|
49
|
+
fillColor: fillColor ?? 0x440000FF,
|
|
50
|
+
strokeColor: strokeColor ?? -16776961,
|
|
51
|
+
strokeWidth: strokeWidth ?? 10,
|
|
52
|
+
zIndex: zIndex ?? 0,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
nativeRef.current.addPolygon(polygonId, {
|
|
56
|
+
points,
|
|
57
|
+
fillColor: fillColor ?? 0x440000FF,
|
|
58
|
+
strokeColor: strokeColor ?? -16776961,
|
|
59
|
+
strokeWidth: strokeWidth ?? 10,
|
|
60
|
+
zIndex: zIndex ?? 0,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
console.log('✅ Polygon addPolygon 调用完成');
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error('❌ 添加多边形失败:', error);
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
console.warn('⚠️ Polygon 组件条件不满足:', {
|
|
69
|
+
hasNativeRef: !!nativeRef?.current,
|
|
70
|
+
hasPoints: !!points,
|
|
71
|
+
pointsLength: points?.length,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 清理函数
|
|
76
|
+
return () => {
|
|
77
|
+
if (nativeRef?.current) {
|
|
78
|
+
try {
|
|
79
|
+
nativeRef.current.removePolygon(polygonId);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.error('移除多边形失败:', error);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}, []);
|
|
86
|
+
|
|
87
|
+
// 更新多边形属性
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
const polygonId = polygonIdRef.current;
|
|
90
|
+
|
|
91
|
+
if (nativeRef?.current) {
|
|
92
|
+
try {
|
|
93
|
+
nativeRef.current.updatePolygon(polygonId, {
|
|
94
|
+
points,
|
|
95
|
+
fillColor,
|
|
96
|
+
strokeColor,
|
|
97
|
+
strokeWidth,
|
|
98
|
+
zIndex,
|
|
99
|
+
});
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error('更新多边形失败:', error);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}, [points, fillColor, strokeColor, strokeWidth, zIndex]);
|
|
105
|
+
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
3
|
+
* @Date : 2025-11-13 15:01:30
|
|
4
|
+
* @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
5
|
+
* @LastEditTime : 2025-11-13 19:06:00
|
|
6
|
+
* @FilePath : /expo-gaode-map/src/components/overlays/Polyline.tsx
|
|
7
|
+
* @Description : 地图折线组件 - 使用命令式 API
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2025 by 尚博信_王强, All Rights Reserved.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import * as React from 'react';
|
|
13
|
+
import { MapContext } from '../../ExpoGaodeMapView';
|
|
14
|
+
import type { PolylineProps } from '../../types';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 地图折线组件
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <MapView>
|
|
22
|
+
* <Polyline
|
|
23
|
+
* points={[
|
|
24
|
+
* { latitude: 39.9, longitude: 116.4 },
|
|
25
|
+
* { latitude: 39.91, longitude: 116.41 },
|
|
26
|
+
* ]}
|
|
27
|
+
* color="#FF0000"
|
|
28
|
+
* width={5}
|
|
29
|
+
* />
|
|
30
|
+
* </MapView>
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export default function Polyline(props: PolylineProps) {
|
|
34
|
+
const mapRef = React.useContext(MapContext);
|
|
35
|
+
const polylineIdRef = React.useRef<string>(`polyline_${Date.now()}_${Math.random()}`);
|
|
36
|
+
|
|
37
|
+
console.log('Polyline 组件渲染,props:', props);
|
|
38
|
+
|
|
39
|
+
// 添加折线
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
const polylineId = polylineIdRef.current;
|
|
42
|
+
|
|
43
|
+
console.log('Polyline useEffect - 添加折线到地图');
|
|
44
|
+
mapRef?.current?.addPolyline?.(polylineId, props).then(() => {
|
|
45
|
+
console.log('✅ 折线已添加:', polylineId);
|
|
46
|
+
}).catch((error: any) => {
|
|
47
|
+
console.error('❌ 添加折线失败:', error);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return () => {
|
|
51
|
+
console.log('Polyline useEffect cleanup - 移除折线');
|
|
52
|
+
mapRef?.current?.removePolyline?.(polylineId).catch((error: any) => {
|
|
53
|
+
console.error('❌ 移除折线失败:', error);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
// 监听 Props 变化,更新折线
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
const polylineId = polylineIdRef.current;
|
|
61
|
+
|
|
62
|
+
console.log('Polyline props 变化,更新折线:', props);
|
|
63
|
+
mapRef?.current?.updatePolyline?.(polylineId, props).catch((error: any) => {
|
|
64
|
+
console.error('❌ 更新折线失败:', error);
|
|
65
|
+
});
|
|
66
|
+
}, [props.points, props.width, props.color]);
|
|
67
|
+
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
3
|
+
* @Date : 2025-11-13 15:03:10
|
|
4
|
+
* @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
5
|
+
* @LastEditTime : 2025-11-13 15:03:22
|
|
6
|
+
* @FilePath : /expo-gaode-map/src/components/overlays/index.ts
|
|
7
|
+
* @Description : 覆盖物组件统一导出
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2025 by 尚博信_王强, All Rights Reserved.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export { default as Marker } from './Marker';
|
|
13
|
+
export { default as Polyline } from './Polyline';
|
|
14
|
+
export { default as Polygon } from './Polygon';
|
|
15
|
+
export { default as Circle } from './Circle';
|
|
16
|
+
export { default as HeatMap } from './HeatMap';
|
|
17
|
+
export { default as MultiPoint } from './MultiPoint';
|
|
18
|
+
export { default as Cluster } from './Cluster';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
3
|
+
* @Date : 2025-11-13 14:45:15
|
|
4
|
+
* @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
5
|
+
* @LastEditTime : 2025-11-13 18:26:20
|
|
6
|
+
* @FilePath : /expo-gaode-map/src/index.ts
|
|
7
|
+
* @Description : 高德地图 Expo Module 主导出文件
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2025 by 尚博信_王强, All Rights Reserved.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// 导出类型定义
|
|
13
|
+
export * from './ExpoGaodeMap.types';
|
|
14
|
+
export * from './types';
|
|
15
|
+
|
|
16
|
+
// 导出原生模块
|
|
17
|
+
export { default as ExpoGaodeMapModule } from './ExpoGaodeMapModule';
|
|
18
|
+
|
|
19
|
+
// 导出 SDK 模块
|
|
20
|
+
export { default as AMapSDK, initSDK, setApiKey, getVersion } from './modules/AMapSDK';
|
|
21
|
+
|
|
22
|
+
// 导出定位模块
|
|
23
|
+
export {
|
|
24
|
+
default as AMapLocation,
|
|
25
|
+
configure,
|
|
26
|
+
start,
|
|
27
|
+
stop,
|
|
28
|
+
isStarted,
|
|
29
|
+
getCurrentLocation,
|
|
30
|
+
addLocationListener,
|
|
31
|
+
coordinateConvert,
|
|
32
|
+
startUpdatingHeading,
|
|
33
|
+
stopUpdatingHeading,
|
|
34
|
+
} from './modules/AMapLocation';
|
|
35
|
+
|
|
36
|
+
// 地图视图控制已移至 MapView 的 ref 调用
|
|
37
|
+
// 使用方式: const mapRef = useRef<MapViewRef>(null); mapRef.current.moveCamera() 等
|
|
38
|
+
|
|
39
|
+
// 导出地图视图组件
|
|
40
|
+
export { default as MapView } from './ExpoGaodeMapView';
|
|
41
|
+
export type { MapViewRef } from './ExpoGaodeMapView';
|
|
42
|
+
|
|
43
|
+
// 导出覆盖物组件
|
|
44
|
+
export {
|
|
45
|
+
Marker,
|
|
46
|
+
Polyline,
|
|
47
|
+
Polygon,
|
|
48
|
+
Circle,
|
|
49
|
+
HeatMap,
|
|
50
|
+
MultiPoint,
|
|
51
|
+
Cluster,
|
|
52
|
+
} from './components/overlays';
|
|
53
|
+
|
|
54
|
+
// 默认导出:直接重新导出所有模块
|
|
55
|
+
export { default } from './ExpoGaodeMapModule';
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
3
|
+
* @Date : 2025-11-13 14:42:10
|
|
4
|
+
* @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
5
|
+
* @LastEditTime : 2025-11-13 14:42:15
|
|
6
|
+
* @FilePath : /expo-gaode-map/src/modules/AMapLocation.ts
|
|
7
|
+
* @Description : 高德地图定位模块
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2025 by 尚博信_王强, All Rights Reserved.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { EventSubscription } from 'expo-modules-core';
|
|
13
|
+
import ExpoGaodeMapModule from '../ExpoGaodeMapModule';
|
|
14
|
+
import type {
|
|
15
|
+
Coordinates,
|
|
16
|
+
ReGeocode,
|
|
17
|
+
LocationOptions,
|
|
18
|
+
LocationListener,
|
|
19
|
+
LatLng,
|
|
20
|
+
CoordinateType,
|
|
21
|
+
} from '../types';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 配置定位选项
|
|
25
|
+
*/
|
|
26
|
+
export function configure(options: LocationOptions): void {
|
|
27
|
+
if (options.withReGeocode !== undefined) {
|
|
28
|
+
ExpoGaodeMapModule.setLocatingWithReGeocode?.(options.withReGeocode);
|
|
29
|
+
}
|
|
30
|
+
if (options.accuracy !== undefined) {
|
|
31
|
+
ExpoGaodeMapModule.setDesiredAccuracy?.(options.accuracy);
|
|
32
|
+
}
|
|
33
|
+
if (options.mode !== undefined) {
|
|
34
|
+
ExpoGaodeMapModule.setLocationMode?.(options.mode);
|
|
35
|
+
}
|
|
36
|
+
if (options.onceLocation !== undefined) {
|
|
37
|
+
ExpoGaodeMapModule.setOnceLocation?.(options.onceLocation);
|
|
38
|
+
}
|
|
39
|
+
if (options.interval !== undefined) {
|
|
40
|
+
ExpoGaodeMapModule.setInterval?.(options.interval);
|
|
41
|
+
}
|
|
42
|
+
if (options.timeout !== undefined) {
|
|
43
|
+
ExpoGaodeMapModule.setLocationTimeout?.(options.timeout);
|
|
44
|
+
}
|
|
45
|
+
if (options.reGeocodeTimeout !== undefined) {
|
|
46
|
+
ExpoGaodeMapModule.setReGeocodeTimeout?.(options.reGeocodeTimeout);
|
|
47
|
+
}
|
|
48
|
+
if (options.distanceFilter !== undefined) {
|
|
49
|
+
ExpoGaodeMapModule.setDistanceFilter?.(options.distanceFilter);
|
|
50
|
+
}
|
|
51
|
+
if (options.sensorEnable !== undefined) {
|
|
52
|
+
ExpoGaodeMapModule.setSensorEnable?.(options.sensorEnable);
|
|
53
|
+
}
|
|
54
|
+
if (options.wifiScan !== undefined) {
|
|
55
|
+
ExpoGaodeMapModule.setWifiScan?.(options.wifiScan);
|
|
56
|
+
}
|
|
57
|
+
if (options.gpsFirst !== undefined) {
|
|
58
|
+
ExpoGaodeMapModule.setGpsFirst?.(options.gpsFirst);
|
|
59
|
+
}
|
|
60
|
+
if (options.onceLocationLatest !== undefined) {
|
|
61
|
+
ExpoGaodeMapModule.setOnceLocationLatest?.(options.onceLocationLatest);
|
|
62
|
+
}
|
|
63
|
+
if (options.geoLanguage !== undefined) {
|
|
64
|
+
ExpoGaodeMapModule.setGeoLanguage?.(options.geoLanguage);
|
|
65
|
+
}
|
|
66
|
+
if (options.allowsBackgroundLocationUpdates !== undefined) {
|
|
67
|
+
ExpoGaodeMapModule.setAllowsBackgroundLocationUpdates?.(options.allowsBackgroundLocationUpdates);
|
|
68
|
+
}
|
|
69
|
+
if (options.pausesLocationUpdatesAutomatically !== undefined) {
|
|
70
|
+
ExpoGaodeMapModule.setPausesLocationUpdatesAutomatically?.(options.pausesLocationUpdatesAutomatically);
|
|
71
|
+
}
|
|
72
|
+
if (options.locationCacheEnable !== undefined) {
|
|
73
|
+
ExpoGaodeMapModule.setLocationCacheEnable?.(options.locationCacheEnable);
|
|
74
|
+
}
|
|
75
|
+
if (options.httpTimeout !== undefined) {
|
|
76
|
+
ExpoGaodeMapModule.setHttpTimeOut?.(options.httpTimeout);
|
|
77
|
+
}
|
|
78
|
+
if (options.protocol !== undefined) {
|
|
79
|
+
ExpoGaodeMapModule.setLocationProtocol?.(options.protocol);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 开始连续定位
|
|
85
|
+
*/
|
|
86
|
+
export function start(): void {
|
|
87
|
+
ExpoGaodeMapModule.start?.();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 停止定位
|
|
92
|
+
*/
|
|
93
|
+
export function stop(): void {
|
|
94
|
+
ExpoGaodeMapModule.stop?.();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 是否正在定位
|
|
99
|
+
*/
|
|
100
|
+
export async function isStarted(): Promise<boolean> {
|
|
101
|
+
return ExpoGaodeMapModule.isStarted?.() || Promise.resolve(false);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 获取当前位置(单次定位)
|
|
106
|
+
*/
|
|
107
|
+
export async function getCurrentLocation(): Promise<Coordinates | ReGeocode> {
|
|
108
|
+
return ExpoGaodeMapModule.getCurrentLocation?.();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 添加定位监听器
|
|
113
|
+
*/
|
|
114
|
+
export function addLocationListener(listener: LocationListener): EventSubscription {
|
|
115
|
+
return ExpoGaodeMapModule.addListener?.('onLocationUpdate', listener) || {
|
|
116
|
+
remove: () => {},
|
|
117
|
+
} as EventSubscription;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 坐标转换
|
|
122
|
+
*/
|
|
123
|
+
export async function coordinateConvert(
|
|
124
|
+
coordinate: LatLng,
|
|
125
|
+
type: CoordinateType
|
|
126
|
+
): Promise<LatLng> {
|
|
127
|
+
return ExpoGaodeMapModule.coordinateConvert?.(coordinate, type) || Promise.resolve(coordinate);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 开始获取设备朝向
|
|
132
|
+
* @platform ios
|
|
133
|
+
*/
|
|
134
|
+
export function startUpdatingHeading(): void {
|
|
135
|
+
ExpoGaodeMapModule.startUpdatingHeading?.();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* 停止获取设备朝向
|
|
140
|
+
* @platform ios
|
|
141
|
+
*/
|
|
142
|
+
export function stopUpdatingHeading(): void {
|
|
143
|
+
ExpoGaodeMapModule.stopUpdatingHeading?.();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 设置 API Key
|
|
148
|
+
*/
|
|
149
|
+
export function setApiKey(key: string): void {
|
|
150
|
+
ExpoGaodeMapModule.setApiKey?.(key);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export default {
|
|
154
|
+
configure,
|
|
155
|
+
start,
|
|
156
|
+
stop,
|
|
157
|
+
isStarted,
|
|
158
|
+
getCurrentLocation,
|
|
159
|
+
addLocationListener,
|
|
160
|
+
coordinateConvert,
|
|
161
|
+
startUpdatingHeading,
|
|
162
|
+
stopUpdatingHeading,
|
|
163
|
+
setApiKey,
|
|
164
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
3
|
+
* @Date : 2025-11-13 14:41:55
|
|
4
|
+
* @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
5
|
+
* @LastEditTime : 2025-11-13 14:42:00
|
|
6
|
+
* @FilePath : /expo-gaode-map/src/modules/AMapSDK.ts
|
|
7
|
+
* @Description :
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2025 by 尚博信_王强, All Rights Reserved.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* 高德地图 SDK 模块
|
|
13
|
+
* 基于 Expo Modules 实现
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import ExpoGaodeMapModule from '../ExpoGaodeMapModule';
|
|
17
|
+
import type { SDKConfig } from '../types';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 初始化高德地图 SDK
|
|
21
|
+
* @param config SDK 配置
|
|
22
|
+
*/
|
|
23
|
+
export function initSDK(config: SDKConfig): void {
|
|
24
|
+
const apiKey = config.iosKey || config.androidKey || '';
|
|
25
|
+
ExpoGaodeMapModule.setApiKey?.(apiKey);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 设置 API Key
|
|
30
|
+
* @param key API 密钥
|
|
31
|
+
*/
|
|
32
|
+
export function setApiKey(key: string): void {
|
|
33
|
+
ExpoGaodeMapModule.setApiKey?.(key);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 获取 SDK 版本号
|
|
38
|
+
* @returns SDK 版本
|
|
39
|
+
*/
|
|
40
|
+
export async function getVersion(): Promise<string> {
|
|
41
|
+
return ExpoGaodeMapModule.getVersion?.() || Promise.resolve('unknown');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default {
|
|
45
|
+
initSDK,
|
|
46
|
+
setApiKey,
|
|
47
|
+
getVersion,
|
|
48
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
3
|
+
* @Date : 2025-11-13 14:57:30
|
|
4
|
+
* @LastEditors : 尚博信_王强 wangqiang03@sunboxsoft.com
|
|
5
|
+
* @LastEditTime : 2025-11-13 14:57:35
|
|
6
|
+
* @FilePath : /expo-gaode-map/src/modules/AMapView.ts
|
|
7
|
+
* @Description : 高德地图视图控制模块
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2025 by 尚博信_王强, All Rights Reserved.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import ExpoGaodeMapModule from '../ExpoGaodeMapModule';
|
|
13
|
+
import type { CameraPosition, Point, LatLng } from '../types';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 移动地图相机到指定位置
|
|
17
|
+
* @param cameraPosition 相机位置参数
|
|
18
|
+
* @param duration 动画时长(毫秒),默认为0(无动画)
|
|
19
|
+
*/
|
|
20
|
+
export function moveCamera(cameraPosition: CameraPosition, duration = 0): void {
|
|
21
|
+
ExpoGaodeMapModule.moveCamera?.(cameraPosition, duration);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 将屏幕坐标转换为地理坐标
|
|
26
|
+
* @param point 屏幕坐标点
|
|
27
|
+
* @returns 地理坐标
|
|
28
|
+
*/
|
|
29
|
+
export async function getLatLng(point: Point): Promise<LatLng> {
|
|
30
|
+
return ExpoGaodeMapModule.getLatLng?.(point) || Promise.resolve({ latitude: 0, longitude: 0 });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 设置地图中心点
|
|
35
|
+
* @param center 中心点坐标
|
|
36
|
+
* @param animated 是否使用动画
|
|
37
|
+
*/
|
|
38
|
+
export function setCenter(center: LatLng, animated = true): void {
|
|
39
|
+
ExpoGaodeMapModule.setCenter?.(center, animated);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 设置地图缩放级别
|
|
44
|
+
* @param zoom 缩放级别(3-20)
|
|
45
|
+
* @param animated 是否使用动画
|
|
46
|
+
*/
|
|
47
|
+
export function setZoom(zoom: number, animated = true): void {
|
|
48
|
+
ExpoGaodeMapModule.setZoom?.(zoom, animated);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 获取当前地图状态
|
|
53
|
+
* @returns 当前相机位置
|
|
54
|
+
*/
|
|
55
|
+
export async function getCameraPosition(): Promise<CameraPosition> {
|
|
56
|
+
return ExpoGaodeMapModule.getCameraPosition?.() || Promise.resolve({
|
|
57
|
+
target: { latitude: 0, longitude: 0 },
|
|
58
|
+
zoom: 10,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default {
|
|
63
|
+
moveCamera,
|
|
64
|
+
getLatLng,
|
|
65
|
+
setCenter,
|
|
66
|
+
setZoom,
|
|
67
|
+
getCameraPosition,
|
|
68
|
+
};
|