expo-gaode-map-navigation 2.0.3 → 2.0.4
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/build.gradle +3 -0
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapModule.kt +45 -49
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapView.kt +5 -15
- package/android/src/main/java/expo/modules/gaodemap/map/modules/SDKInitializer.kt +143 -14
- package/build/ExpoGaodeMapNaviView.d.ts.map +1 -1
- package/build/ExpoGaodeMapNaviView.js +3 -2
- package/build/ExpoGaodeMapNaviView.js.map +1 -1
- package/build/ExpoGaodeMapNavigationModule.d.ts +2 -7
- package/build/ExpoGaodeMapNavigationModule.d.ts.map +1 -1
- package/build/ExpoGaodeMapNavigationModule.js +19 -2
- package/build/ExpoGaodeMapNavigationModule.js.map +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +8 -2
- package/build/index.js.map +1 -1
- package/build/map/ExpoGaodeMapModule.d.ts +245 -4
- package/build/map/ExpoGaodeMapModule.d.ts.map +1 -1
- package/build/map/ExpoGaodeMapModule.js +197 -15
- package/build/map/ExpoGaodeMapModule.js.map +1 -1
- package/build/map/ExpoGaodeMapOfflineModule.d.ts.map +1 -1
- package/build/map/ExpoGaodeMapOfflineModule.js +19 -2
- package/build/map/ExpoGaodeMapOfflineModule.js.map +1 -1
- package/build/map/ExpoGaodeMapView.d.ts.map +1 -1
- package/build/map/ExpoGaodeMapView.js +8 -2
- package/build/map/ExpoGaodeMapView.js.map +1 -1
- package/build/map/components/overlays/Circle.d.ts.map +1 -1
- package/build/map/components/overlays/Circle.js +3 -2
- package/build/map/components/overlays/Circle.js.map +1 -1
- package/build/map/components/overlays/Cluster.d.ts.map +1 -1
- package/build/map/components/overlays/Cluster.js +3 -2
- package/build/map/components/overlays/Cluster.js.map +1 -1
- package/build/map/components/overlays/HeatMap.d.ts.map +1 -1
- package/build/map/components/overlays/HeatMap.js +3 -2
- package/build/map/components/overlays/HeatMap.js.map +1 -1
- package/build/map/components/overlays/Marker.d.ts.map +1 -1
- package/build/map/components/overlays/Marker.js +3 -2
- package/build/map/components/overlays/Marker.js.map +1 -1
- package/build/map/components/overlays/MultiPoint.d.ts.map +1 -1
- package/build/map/components/overlays/MultiPoint.js +3 -2
- package/build/map/components/overlays/MultiPoint.js.map +1 -1
- package/build/map/components/overlays/Polygon.d.ts.map +1 -1
- package/build/map/components/overlays/Polygon.js +3 -2
- package/build/map/components/overlays/Polygon.js.map +1 -1
- package/build/map/components/overlays/Polyline.d.ts.map +1 -1
- package/build/map/components/overlays/Polyline.js +3 -2
- package/build/map/components/overlays/Polyline.js.map +1 -1
- package/build/map/types/common.types.d.ts +26 -0
- package/build/map/types/common.types.d.ts.map +1 -1
- package/build/map/types/common.types.js.map +1 -1
- package/build/map/types/native-module.types.d.ts +28 -1
- package/build/map/types/native-module.types.d.ts.map +1 -1
- package/build/map/types/native-module.types.js.map +1 -1
- package/build/map/utils/ErrorHandler.d.ts +6 -0
- package/build/map/utils/ErrorHandler.d.ts.map +1 -1
- package/build/map/utils/ErrorHandler.js +42 -0
- package/build/map/utils/ErrorHandler.js.map +1 -1
- package/build/map/utils/GeoUtils.d.ts.map +1 -1
- package/build/map/utils/GeoUtils.js +6 -2
- package/build/map/utils/GeoUtils.js.map +1 -1
- package/build/map/utils/lazyNativeViewManager.d.ts +3 -0
- package/build/map/utils/lazyNativeViewManager.d.ts.map +1 -0
- package/build/map/utils/lazyNativeViewManager.js +11 -0
- package/build/map/utils/lazyNativeViewManager.js.map +1 -0
- package/ios/ExpoGaodeMapNavigation.podspec +5 -0
- package/ios/map/ExpoGaodeMapModule.swift +27 -40
- package/ios/map/ExpoGaodeMapView.swift +160 -77
- package/ios/map/GaodeMapPrivacyManager.swift +155 -0
- package/ios/map/modules/LocationManager.swift +43 -24
- package/package.json +1 -1
- package/android/src/main/java/expo/modules/gaodemap/map/MapPreloadManager.kt +0 -494
- package/ios/map/MapPreloadManager.swift +0 -348
|
@@ -1,13 +1,254 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { LatLng, Coordinates, ReGeocode, LocationListener, LatLngPoint, CoordinateType } from './types';
|
|
2
|
+
import type { ExpoGaodeMapModule as NativeExpoGaodeMapModule } from './types/native-module.types';
|
|
3
|
+
import { PrivacyConfig, PrivacyStatus, SDKConfig, PermissionStatus } from './types/common.types';
|
|
4
|
+
declare const helperMethods: {
|
|
5
|
+
/**
|
|
6
|
+
* 初始化 SDK,并缓存配置(包含 webKey)
|
|
7
|
+
* 注意:允许不提供任何 API Key,因为原生端可能已通过 Config Plugin 配置
|
|
8
|
+
*/
|
|
9
|
+
initSDK(config: SDKConfig): void;
|
|
10
|
+
isSDKInitialized(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* 设置是否显示隐私政策弹窗
|
|
13
|
+
* @deprecated 请优先使用 `setPrivacyConfig`
|
|
14
|
+
*/
|
|
15
|
+
setPrivacyShow(hasShow: boolean, hasContainsPrivacy: boolean): void;
|
|
16
|
+
/**
|
|
17
|
+
* 设置用户是否同意隐私政策
|
|
18
|
+
* @deprecated 请优先使用 `setPrivacyConfig`
|
|
19
|
+
*/
|
|
20
|
+
setPrivacyAgree(hasAgree: boolean): void;
|
|
21
|
+
/**
|
|
22
|
+
* 设置当前隐私协议版本
|
|
23
|
+
* 当版本号变化时,之前的同意状态会失效
|
|
24
|
+
*/
|
|
25
|
+
setPrivacyVersion(version: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* 清空已持久化的隐私同意状态
|
|
28
|
+
*/
|
|
29
|
+
resetPrivacyConsent(): void;
|
|
30
|
+
/**
|
|
31
|
+
* 一次性同步完整的隐私状态
|
|
32
|
+
* 推荐业务层只调用这个方法
|
|
33
|
+
*/
|
|
34
|
+
setPrivacyConfig(config: PrivacyConfig): void;
|
|
35
|
+
getPrivacyStatus(): PrivacyStatus;
|
|
36
|
+
calculateDistanceBetweenPoints(p1: LatLngPoint, p2: LatLngPoint): number;
|
|
37
|
+
calculateDistance(lat1: number, lon1: number, lat2: number, lon2: number): number;
|
|
38
|
+
setLoadWorldVectorMap(enabled: boolean): void;
|
|
39
|
+
getVersion(): string;
|
|
40
|
+
start(): void;
|
|
41
|
+
stop(): void;
|
|
42
|
+
isStarted(): Promise<boolean>;
|
|
43
|
+
getCurrentLocation(): Promise<Coordinates | ReGeocode>;
|
|
44
|
+
coordinateConvert(coordinate: LatLngPoint, type: CoordinateType): Promise<LatLng>;
|
|
45
|
+
setLocatingWithReGeocode(isReGeocode: boolean): void;
|
|
46
|
+
readonly isBackgroundLocationEnabled: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 检查位置权限状态
|
|
49
|
+
*/
|
|
50
|
+
checkLocationPermission(): Promise<PermissionStatus>;
|
|
51
|
+
/**
|
|
52
|
+
* 请求前台位置权限(增强版)
|
|
53
|
+
*/
|
|
54
|
+
requestLocationPermission(): Promise<PermissionStatus>;
|
|
55
|
+
/**
|
|
56
|
+
* 请求后台位置权限
|
|
57
|
+
* 注意:必须在前台权限已授予后才能请求
|
|
58
|
+
*/
|
|
59
|
+
requestBackgroundLocationPermission(): Promise<PermissionStatus>;
|
|
60
|
+
/**
|
|
61
|
+
* 打开应用设置页面
|
|
62
|
+
* 引导用户手动授予权限
|
|
63
|
+
*/
|
|
64
|
+
openAppSettings(): void;
|
|
65
|
+
setAllowsBackgroundLocationUpdates(allows: boolean): void;
|
|
66
|
+
/**
|
|
67
|
+
* 添加定位监听器(便捷方法)
|
|
68
|
+
* 自动订阅 onLocationUpdate 事件,提供容错处理
|
|
69
|
+
* @param listener 定位回调函数
|
|
70
|
+
* @returns 订阅对象,调用 remove() 取消监听
|
|
71
|
+
* 注意:如果使用 Config Plugin 配置了 API Key,无需调用 initSDK()
|
|
72
|
+
*/
|
|
73
|
+
addLocationListener(listener: LocationListener): {
|
|
74
|
+
remove: () => void;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* 计算两个坐标点之间的距离
|
|
78
|
+
* @param coordinate1 第一个坐标点
|
|
79
|
+
* @param coordinate2 第二个坐标点
|
|
80
|
+
* @returns 两点之间的距离(单位:米)
|
|
81
|
+
*/
|
|
82
|
+
distanceBetweenCoordinates(coordinate1: LatLngPoint, coordinate2: LatLngPoint): number;
|
|
83
|
+
/**
|
|
84
|
+
* 判断点是否在圆内
|
|
85
|
+
* @param point 要判断的点
|
|
86
|
+
* @param center 圆心坐标
|
|
87
|
+
* @param radius 圆半径(单位:米)
|
|
88
|
+
* @returns 是否在圆内
|
|
89
|
+
*/
|
|
90
|
+
isPointInCircle(point: LatLngPoint, center: LatLngPoint, radius: number): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* 判断点是否在多边形内
|
|
93
|
+
* @param point 要判断的点
|
|
94
|
+
* @param polygon 多边形的顶点坐标数组
|
|
95
|
+
* @returns 是否在多边形内
|
|
96
|
+
*/
|
|
97
|
+
isPointInPolygon(point: LatLngPoint, polygon: LatLngPoint[]): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* 计算多边形面积
|
|
100
|
+
* @param polygon 多边形的顶点坐标数组
|
|
101
|
+
* @returns 面积(单位:平方米)
|
|
102
|
+
*/
|
|
103
|
+
calculatePolygonArea(polygon: LatLngPoint[]): number;
|
|
104
|
+
/**
|
|
105
|
+
* 计算矩形面积
|
|
106
|
+
* @param southWest 西南角坐标
|
|
107
|
+
* @param northEast 东北角坐标
|
|
108
|
+
* @returns 面积(单位:平方米)
|
|
109
|
+
*/
|
|
110
|
+
calculateRectangleArea(southWest: LatLngPoint, northEast: LatLngPoint): number;
|
|
111
|
+
/**
|
|
112
|
+
* 获取路径上距离目标点最近的点
|
|
113
|
+
* @param path 路径点集合
|
|
114
|
+
* @param target 目标点
|
|
115
|
+
* @returns 最近点信息,包含坐标、索引和距离
|
|
116
|
+
*/
|
|
117
|
+
getNearestPointOnPath(path: LatLngPoint[], target: LatLngPoint): {
|
|
118
|
+
latitude: number;
|
|
119
|
+
longitude: number;
|
|
120
|
+
index: number;
|
|
121
|
+
distanceMeters: number;
|
|
122
|
+
} | null;
|
|
123
|
+
/**
|
|
124
|
+
* 计算多边形质心
|
|
125
|
+
* @param polygon 多边形顶点坐标数组
|
|
126
|
+
* @returns 质心坐标
|
|
127
|
+
*/
|
|
128
|
+
calculateCentroid(polygon: LatLngPoint[]): LatLng | null;
|
|
129
|
+
/**
|
|
130
|
+
* 计算路径边界和中心点
|
|
131
|
+
* @param points 路径点集合
|
|
132
|
+
* @returns 边界信息,包含 north, south, east, west 和 center
|
|
133
|
+
*/
|
|
134
|
+
calculatePathBounds(points: LatLngPoint[]): {
|
|
135
|
+
north: number;
|
|
136
|
+
south: number;
|
|
137
|
+
east: number;
|
|
138
|
+
west: number;
|
|
139
|
+
center: LatLngPoint;
|
|
140
|
+
} | null;
|
|
141
|
+
/**
|
|
142
|
+
* GeoHash 编码
|
|
143
|
+
* @param coordinate 坐标点
|
|
144
|
+
* @param precision 精度 (1-12)
|
|
145
|
+
* @returns GeoHash 字符串
|
|
146
|
+
*/
|
|
147
|
+
encodeGeoHash(coordinate: LatLngPoint, precision: number): string;
|
|
148
|
+
/**
|
|
149
|
+
* 轨迹抽稀 (RDP 算法)
|
|
150
|
+
* @param points 原始轨迹点
|
|
151
|
+
* @param tolerance 允许误差(米)
|
|
152
|
+
* @returns 简化后的轨迹点
|
|
153
|
+
*/
|
|
154
|
+
simplifyPolyline(points: LatLngPoint[], tolerance: number): LatLng[];
|
|
155
|
+
/**
|
|
156
|
+
* 计算路径总长度
|
|
157
|
+
* @param points 路径点
|
|
158
|
+
* @returns 长度(米)
|
|
159
|
+
*/
|
|
160
|
+
calculatePathLength(points: LatLngPoint[]): number;
|
|
161
|
+
/**
|
|
162
|
+
* 解析高德地图 API 返回的 Polyline 字符串
|
|
163
|
+
* 格式: "lng,lat;lng,lat;..."
|
|
164
|
+
* @param polylineStr 高德原始 polyline 字符串,或包含 polyline 属性的对象
|
|
165
|
+
* @returns 解析后的点集
|
|
166
|
+
*/
|
|
167
|
+
parsePolyline(polylineStr: string | {
|
|
168
|
+
polyline: string;
|
|
169
|
+
}): LatLng[];
|
|
170
|
+
/**
|
|
171
|
+
* 获取路径上指定距离的点
|
|
172
|
+
* @param points 路径点
|
|
173
|
+
* @param distance 距离起点的米数
|
|
174
|
+
* @returns 点信息(坐标+角度)
|
|
175
|
+
*/
|
|
176
|
+
getPointAtDistance(points: LatLngPoint[], distance: number): {
|
|
177
|
+
latitude: number;
|
|
178
|
+
longitude: number;
|
|
179
|
+
angle: number;
|
|
180
|
+
} | null;
|
|
181
|
+
/**
|
|
182
|
+
* 经纬度转换为地图瓦片坐标
|
|
183
|
+
* @param coordinate 经纬度点
|
|
184
|
+
* @param zoom 缩放级别
|
|
185
|
+
* @returns 瓦片坐标(x, y, z)
|
|
186
|
+
*/
|
|
187
|
+
latLngToTile(coordinate: LatLngPoint, zoom: number): {
|
|
188
|
+
x: number;
|
|
189
|
+
y: number;
|
|
190
|
+
z: number;
|
|
191
|
+
} | null;
|
|
192
|
+
/**
|
|
193
|
+
* 地图瓦片坐标转换为经纬度
|
|
194
|
+
* @param tile 瓦片坐标(x, y, z)
|
|
195
|
+
* @returns 经纬度点
|
|
196
|
+
*/
|
|
197
|
+
tileToLatLng(tile: {
|
|
198
|
+
x: number;
|
|
199
|
+
y: number;
|
|
200
|
+
z: number;
|
|
201
|
+
}): LatLng | null;
|
|
202
|
+
/**
|
|
203
|
+
* 经纬度转换为地图像素坐标
|
|
204
|
+
* @param coordinate 经纬度点
|
|
205
|
+
* @param zoom 缩放级别
|
|
206
|
+
* @returns 像素坐标(x, y)
|
|
207
|
+
*/
|
|
208
|
+
latLngToPixel(coordinate: LatLngPoint, zoom: number): {
|
|
209
|
+
x: number;
|
|
210
|
+
y: number;
|
|
211
|
+
} | null;
|
|
212
|
+
/**
|
|
213
|
+
* 地图像素坐标转换为经纬度
|
|
214
|
+
* @param pixel 像素坐标(x, y)
|
|
215
|
+
* @param zoom 缩放级别
|
|
216
|
+
* @returns 经纬度点
|
|
217
|
+
*/
|
|
218
|
+
pixelToLatLng(pixel: {
|
|
219
|
+
x: number;
|
|
220
|
+
y: number;
|
|
221
|
+
}, zoom: number): LatLng | null;
|
|
222
|
+
/**
|
|
223
|
+
* 批量地理围栏检测
|
|
224
|
+
* @param point 待检查的点
|
|
225
|
+
* @param polygons 多边形数组,格式为 LatLngPoint[][] 或 LatLngPoint[][][]
|
|
226
|
+
* @returns 包含点索引的数组(-1 表示不在任何多边形内)
|
|
227
|
+
*/
|
|
228
|
+
findPointInPolygons(point: LatLngPoint, polygons: LatLngPoint[][] | LatLngPoint[][][]): number;
|
|
229
|
+
/**
|
|
230
|
+
* 生成网格聚合数据 (常用于展示网格聚合图或大规模点数据处理)
|
|
231
|
+
* @param points 包含经纬度和权重的点数组
|
|
232
|
+
* @param gridSizeMeters 网格大小(米)
|
|
233
|
+
* @returns 包含经纬度和强度的网格点数组
|
|
234
|
+
*/
|
|
235
|
+
generateHeatmapGrid(points: Array<LatLngPoint & {
|
|
236
|
+
weight?: number;
|
|
237
|
+
}>, gridSizeMeters: number): Array<{
|
|
238
|
+
latitude: number;
|
|
239
|
+
longitude: number;
|
|
240
|
+
intensity: number;
|
|
241
|
+
}>;
|
|
242
|
+
};
|
|
3
243
|
/**
|
|
4
244
|
* 获取最近一次 initSDK 的配置
|
|
5
245
|
*/
|
|
6
246
|
export declare function getSDKConfig(): SDKConfig | null;
|
|
247
|
+
export type ExpoGaodeMapModule = typeof helperMethods & NativeExpoGaodeMapModule;
|
|
248
|
+
declare const ExpoGaodeMapModuleWithHelpers: ExpoGaodeMapModule;
|
|
7
249
|
/**
|
|
8
250
|
* 获取用于 Web API 的 webKey(若未初始化或未提供则返回 undefined)
|
|
9
251
|
*/
|
|
10
252
|
export declare function getWebKey(): string | undefined;
|
|
11
|
-
|
|
12
|
-
export default _default;
|
|
253
|
+
export default ExpoGaodeMapModuleWithHelpers;
|
|
13
254
|
//# sourceMappingURL=ExpoGaodeMapModule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoGaodeMapModule.d.ts","sourceRoot":"","sources":["../../src/map/ExpoGaodeMapModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExpoGaodeMapModule.d.ts","sourceRoot":"","sources":["../../src/map/ExpoGaodeMapModule.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,MAAM,EACN,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,cAAc,EACf,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,kBAAkB,IAAI,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAElG,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AA0FjG,QAAA,MAAM,aAAa;IAEjB;;;OAGG;oBACa,SAAS,GAAG,IAAI;wBAgCZ,OAAO;IAI3B;;;OAGG;4BACqB,OAAO,sBAAsB,OAAO,GAAG,IAAI;IAMnE;;;OAGG;8BACuB,OAAO,GAAG,IAAI;IAMxC;;;OAGG;+BACwB,MAAM,GAAG,IAAI;IAMxC;;OAEG;2BACoB,IAAI;IAM3B;;;OAGG;6BACsB,aAAa,GAAG,IAAI;wBAUzB,aAAa;uCAgBE,WAAW,MAAM,WAAW,GAAG,MAAM;4BAWhD,MAAM,QAAQ,MAAM,QAAQ,MAAM,QAAQ,MAAM,GAAG,MAAM;mCAWlD,OAAO,GAAG,IAAI;kBAU/B,MAAM;aAWX,IAAI;YAWL,IAAI;iBAWC,OAAO,CAAC,OAAO,CAAC;0BAYD,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;kCAaxB,WAAW,QAAQ,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;0CAajD,OAAO,GAAG,IAAI;0CAWjB,OAAO;IAM1C;;OAEG;+BAC8B,OAAO,CAAC,gBAAgB,CAAC;IAa1D;;OAEG;iCACgC,OAAO,CA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CAAC;AAEzB;;EAEE;AACF,wBAAgB,SAAS,IAAI,MAAM,GAAG,SAAS,CAE9C;AAED,eAAe,6BAA6B,CAAC"}
|
|
@@ -2,30 +2,91 @@ import { requireNativeModule } from 'expo';
|
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
3
|
import { ErrorHandler, ErrorLogger } from './utils/ErrorHandler';
|
|
4
4
|
import { normalizeLatLng, normalizeLatLngList } from './utils/GeoUtils';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
let nativeModuleCache = null;
|
|
6
|
+
function getNativeModule(optional = false) {
|
|
7
|
+
if (nativeModuleCache) {
|
|
8
|
+
return nativeModuleCache;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
nativeModuleCache = requireNativeModule('ExpoGaodeMap');
|
|
12
|
+
return nativeModuleCache;
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (optional) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const moduleError = ErrorHandler.nativeModuleUnavailable();
|
|
19
|
+
ErrorLogger.log(moduleError);
|
|
20
|
+
throw moduleError;
|
|
21
|
+
}
|
|
9
22
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
23
|
+
function getBoundNativeValue(module, prop) {
|
|
24
|
+
const value = Reflect.get(module, prop, module);
|
|
25
|
+
if (typeof value === 'function') {
|
|
26
|
+
return (...args) => value.apply(module, args);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
14
29
|
}
|
|
30
|
+
const nativeModule = new Proxy({}, {
|
|
31
|
+
get(_target, prop) {
|
|
32
|
+
const module = getNativeModule(true);
|
|
33
|
+
return module ? getBoundNativeValue(module, prop) : undefined;
|
|
34
|
+
},
|
|
35
|
+
});
|
|
15
36
|
// 记录最近一次 initSDK 的配置(含 webKey)
|
|
16
37
|
let _sdkConfig = null;
|
|
17
38
|
let _isSDKInitialized = false;
|
|
39
|
+
const privacySensitiveMethodNames = new Set([
|
|
40
|
+
'start',
|
|
41
|
+
'stop',
|
|
42
|
+
'isStarted',
|
|
43
|
+
'getCurrentLocation',
|
|
44
|
+
'coordinateConvert',
|
|
45
|
+
'setLocatingWithReGeocode',
|
|
46
|
+
'setLocationMode',
|
|
47
|
+
'setInterval',
|
|
48
|
+
'setOnceLocation',
|
|
49
|
+
'setSensorEnable',
|
|
50
|
+
'setWifiScan',
|
|
51
|
+
'setGpsFirst',
|
|
52
|
+
'setOnceLocationLatest',
|
|
53
|
+
'setGeoLanguage',
|
|
54
|
+
'setLocationCacheEnable',
|
|
55
|
+
'setHttpTimeOut',
|
|
56
|
+
'setDesiredAccuracy',
|
|
57
|
+
'setLocationTimeout',
|
|
58
|
+
'setReGeocodeTimeout',
|
|
59
|
+
'setDistanceFilter',
|
|
60
|
+
'setPausesLocationUpdatesAutomatically',
|
|
61
|
+
'setAllowsBackgroundLocationUpdates',
|
|
62
|
+
'setLocationProtocol',
|
|
63
|
+
'startUpdatingHeading',
|
|
64
|
+
'stopUpdatingHeading',
|
|
65
|
+
'checkLocationPermission',
|
|
66
|
+
'requestLocationPermission',
|
|
67
|
+
'requestBackgroundLocationPermission',
|
|
68
|
+
'addLocationListener',
|
|
69
|
+
]);
|
|
70
|
+
function assertPrivacyReady(scene = 'sdk') {
|
|
71
|
+
const nativeModule = getNativeModule();
|
|
72
|
+
if (!nativeModule) {
|
|
73
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
74
|
+
}
|
|
75
|
+
const status = nativeModule.getPrivacyStatus();
|
|
76
|
+
if (!status.isReady) {
|
|
77
|
+
throw ErrorHandler.privacyNotAgreed(scene);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
18
80
|
// 扩展原生模块,添加便捷方法
|
|
19
|
-
const
|
|
20
|
-
...(nativeModule || {}),
|
|
81
|
+
const helperMethods = {
|
|
21
82
|
/**
|
|
22
83
|
* 初始化 SDK,并缓存配置(包含 webKey)
|
|
23
84
|
* 注意:允许不提供任何 API Key,因为原生端可能已通过 Config Plugin 配置
|
|
24
85
|
*/
|
|
25
86
|
initSDK(config) {
|
|
26
|
-
|
|
87
|
+
const nativeModule = getNativeModule();
|
|
88
|
+
if (!nativeModule)
|
|
27
89
|
throw ErrorHandler.nativeModuleUnavailable();
|
|
28
|
-
}
|
|
29
90
|
try {
|
|
30
91
|
// 检查是否有任何 key 被提供
|
|
31
92
|
const hasJSKeys = !!(config.androidKey || config.iosKey);
|
|
@@ -54,19 +115,90 @@ const ExpoGaodeMapModuleWithHelpers = {
|
|
|
54
115
|
isSDKInitialized() {
|
|
55
116
|
return _isSDKInitialized;
|
|
56
117
|
},
|
|
118
|
+
/**
|
|
119
|
+
* 设置是否显示隐私政策弹窗
|
|
120
|
+
* @deprecated 请优先使用 `setPrivacyConfig`
|
|
121
|
+
*/
|
|
122
|
+
setPrivacyShow(hasShow, hasContainsPrivacy) {
|
|
123
|
+
const nativeModule = getNativeModule();
|
|
124
|
+
if (!nativeModule)
|
|
125
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
126
|
+
nativeModule.setPrivacyShow(hasShow, hasContainsPrivacy);
|
|
127
|
+
},
|
|
128
|
+
/**
|
|
129
|
+
* 设置用户是否同意隐私政策
|
|
130
|
+
* @deprecated 请优先使用 `setPrivacyConfig`
|
|
131
|
+
*/
|
|
132
|
+
setPrivacyAgree(hasAgree) {
|
|
133
|
+
const nativeModule = getNativeModule();
|
|
134
|
+
if (!nativeModule)
|
|
135
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
136
|
+
nativeModule.setPrivacyAgree(hasAgree);
|
|
137
|
+
},
|
|
138
|
+
/**
|
|
139
|
+
* 设置当前隐私协议版本
|
|
140
|
+
* 当版本号变化时,之前的同意状态会失效
|
|
141
|
+
*/
|
|
142
|
+
setPrivacyVersion(version) {
|
|
143
|
+
const nativeModule = getNativeModule();
|
|
144
|
+
if (!nativeModule)
|
|
145
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
146
|
+
nativeModule.setPrivacyVersion(version);
|
|
147
|
+
},
|
|
148
|
+
/**
|
|
149
|
+
* 清空已持久化的隐私同意状态
|
|
150
|
+
*/
|
|
151
|
+
resetPrivacyConsent() {
|
|
152
|
+
const nativeModule = getNativeModule();
|
|
153
|
+
if (!nativeModule)
|
|
154
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
155
|
+
nativeModule.resetPrivacyConsent();
|
|
156
|
+
},
|
|
157
|
+
/**
|
|
158
|
+
* 一次性同步完整的隐私状态
|
|
159
|
+
* 推荐业务层只调用这个方法
|
|
160
|
+
*/
|
|
161
|
+
setPrivacyConfig(config) {
|
|
162
|
+
const nativeModule = getNativeModule();
|
|
163
|
+
if (!nativeModule)
|
|
164
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
165
|
+
if (typeof config.privacyVersion === 'string') {
|
|
166
|
+
nativeModule.setPrivacyVersion(config.privacyVersion);
|
|
167
|
+
}
|
|
168
|
+
nativeModule.setPrivacyShow(config.hasShow, config.hasContainsPrivacy);
|
|
169
|
+
nativeModule.setPrivacyAgree(config.hasAgree);
|
|
170
|
+
},
|
|
171
|
+
getPrivacyStatus() {
|
|
172
|
+
const nativeModule = getNativeModule();
|
|
173
|
+
if (!nativeModule) {
|
|
174
|
+
return {
|
|
175
|
+
hasShow: false,
|
|
176
|
+
hasContainsPrivacy: false,
|
|
177
|
+
hasAgree: false,
|
|
178
|
+
isReady: false,
|
|
179
|
+
privacyVersion: null,
|
|
180
|
+
agreedPrivacyVersion: null,
|
|
181
|
+
restoredFromStorage: false,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
return nativeModule.getPrivacyStatus();
|
|
185
|
+
},
|
|
57
186
|
calculateDistanceBetweenPoints(p1, p2) {
|
|
187
|
+
const nativeModule = getNativeModule();
|
|
58
188
|
if (!nativeModule) {
|
|
59
189
|
throw ErrorHandler.nativeModuleUnavailable();
|
|
60
190
|
}
|
|
61
191
|
return nativeModule.distanceBetweenCoordinates(normalizeLatLng(p1), normalizeLatLng(p2));
|
|
62
192
|
},
|
|
63
193
|
calculateDistance(lat1, lon1, lat2, lon2) {
|
|
194
|
+
const nativeModule = getNativeModule();
|
|
64
195
|
if (!nativeModule) {
|
|
65
196
|
throw ErrorHandler.nativeModuleUnavailable();
|
|
66
197
|
}
|
|
67
198
|
return nativeModule.distanceBetweenCoordinates({ latitude: lat1, longitude: lon1 }, { latitude: lat2, longitude: lon2 });
|
|
68
199
|
},
|
|
69
200
|
setLoadWorldVectorMap(enabled) {
|
|
201
|
+
const nativeModule = getNativeModule(true);
|
|
70
202
|
if (!nativeModule)
|
|
71
203
|
return;
|
|
72
204
|
try {
|
|
@@ -77,6 +209,7 @@ const ExpoGaodeMapModuleWithHelpers = {
|
|
|
77
209
|
}
|
|
78
210
|
},
|
|
79
211
|
getVersion() {
|
|
212
|
+
const nativeModule = getNativeModule(true);
|
|
80
213
|
if (!nativeModule)
|
|
81
214
|
return '0.0.0';
|
|
82
215
|
try {
|
|
@@ -88,6 +221,8 @@ const ExpoGaodeMapModuleWithHelpers = {
|
|
|
88
221
|
}
|
|
89
222
|
},
|
|
90
223
|
start() {
|
|
224
|
+
assertPrivacyReady('sdk');
|
|
225
|
+
const nativeModule = getNativeModule(true);
|
|
91
226
|
if (!nativeModule)
|
|
92
227
|
return;
|
|
93
228
|
try {
|
|
@@ -98,6 +233,8 @@ const ExpoGaodeMapModuleWithHelpers = {
|
|
|
98
233
|
}
|
|
99
234
|
},
|
|
100
235
|
stop() {
|
|
236
|
+
assertPrivacyReady('sdk');
|
|
237
|
+
const nativeModule = getNativeModule(true);
|
|
101
238
|
if (!nativeModule)
|
|
102
239
|
return;
|
|
103
240
|
try {
|
|
@@ -108,6 +245,8 @@ const ExpoGaodeMapModuleWithHelpers = {
|
|
|
108
245
|
}
|
|
109
246
|
},
|
|
110
247
|
isStarted() {
|
|
248
|
+
assertPrivacyReady('sdk');
|
|
249
|
+
const nativeModule = getNativeModule(true);
|
|
111
250
|
if (!nativeModule)
|
|
112
251
|
return Promise.resolve(false);
|
|
113
252
|
try {
|
|
@@ -119,6 +258,8 @@ const ExpoGaodeMapModuleWithHelpers = {
|
|
|
119
258
|
}
|
|
120
259
|
},
|
|
121
260
|
async getCurrentLocation() {
|
|
261
|
+
assertPrivacyReady('sdk');
|
|
262
|
+
const nativeModule = getNativeModule();
|
|
122
263
|
if (!nativeModule) {
|
|
123
264
|
throw ErrorHandler.nativeModuleUnavailable();
|
|
124
265
|
}
|
|
@@ -130,6 +271,8 @@ const ExpoGaodeMapModuleWithHelpers = {
|
|
|
130
271
|
}
|
|
131
272
|
},
|
|
132
273
|
async coordinateConvert(coordinate, type) {
|
|
274
|
+
assertPrivacyReady('sdk');
|
|
275
|
+
const nativeModule = getNativeModule();
|
|
133
276
|
if (!nativeModule) {
|
|
134
277
|
throw ErrorHandler.nativeModuleUnavailable();
|
|
135
278
|
}
|
|
@@ -141,6 +284,8 @@ const ExpoGaodeMapModuleWithHelpers = {
|
|
|
141
284
|
}
|
|
142
285
|
},
|
|
143
286
|
setLocatingWithReGeocode(isReGeocode) {
|
|
287
|
+
assertPrivacyReady('sdk');
|
|
288
|
+
const nativeModule = getNativeModule(true);
|
|
144
289
|
if (!nativeModule)
|
|
145
290
|
return;
|
|
146
291
|
try {
|
|
@@ -151,6 +296,7 @@ const ExpoGaodeMapModuleWithHelpers = {
|
|
|
151
296
|
}
|
|
152
297
|
},
|
|
153
298
|
get isBackgroundLocationEnabled() {
|
|
299
|
+
const nativeModule = getNativeModule(true);
|
|
154
300
|
if (!nativeModule)
|
|
155
301
|
return false;
|
|
156
302
|
return nativeModule.isBackgroundLocationEnabled === true;
|
|
@@ -159,6 +305,8 @@ const ExpoGaodeMapModuleWithHelpers = {
|
|
|
159
305
|
* 检查位置权限状态
|
|
160
306
|
*/
|
|
161
307
|
async checkLocationPermission() {
|
|
308
|
+
assertPrivacyReady('sdk');
|
|
309
|
+
const nativeModule = getNativeModule();
|
|
162
310
|
if (!nativeModule) {
|
|
163
311
|
throw ErrorHandler.nativeModuleUnavailable();
|
|
164
312
|
}
|
|
@@ -173,6 +321,8 @@ const ExpoGaodeMapModuleWithHelpers = {
|
|
|
173
321
|
* 请求前台位置权限(增强版)
|
|
174
322
|
*/
|
|
175
323
|
async requestLocationPermission() {
|
|
324
|
+
assertPrivacyReady('sdk');
|
|
325
|
+
const nativeModule = getNativeModule();
|
|
176
326
|
if (!nativeModule) {
|
|
177
327
|
throw ErrorHandler.nativeModuleUnavailable();
|
|
178
328
|
}
|
|
@@ -192,6 +342,8 @@ const ExpoGaodeMapModuleWithHelpers = {
|
|
|
192
342
|
* 注意:必须在前台权限已授予后才能请求
|
|
193
343
|
*/
|
|
194
344
|
async requestBackgroundLocationPermission() {
|
|
345
|
+
assertPrivacyReady('sdk');
|
|
346
|
+
const nativeModule = getNativeModule();
|
|
195
347
|
if (!nativeModule) {
|
|
196
348
|
throw ErrorHandler.nativeModuleUnavailable();
|
|
197
349
|
}
|
|
@@ -211,6 +363,7 @@ const ExpoGaodeMapModuleWithHelpers = {
|
|
|
211
363
|
* 引导用户手动授予权限
|
|
212
364
|
*/
|
|
213
365
|
openAppSettings() {
|
|
366
|
+
const nativeModule = getNativeModule();
|
|
214
367
|
if (!nativeModule) {
|
|
215
368
|
throw ErrorHandler.nativeModuleUnavailable();
|
|
216
369
|
}
|
|
@@ -222,6 +375,8 @@ const ExpoGaodeMapModuleWithHelpers = {
|
|
|
222
375
|
}
|
|
223
376
|
},
|
|
224
377
|
setAllowsBackgroundLocationUpdates(allows) {
|
|
378
|
+
assertPrivacyReady('sdk');
|
|
379
|
+
const nativeModule = getNativeModule();
|
|
225
380
|
if (!nativeModule) {
|
|
226
381
|
throw ErrorHandler.nativeModuleUnavailable();
|
|
227
382
|
}
|
|
@@ -256,13 +411,18 @@ const ExpoGaodeMapModuleWithHelpers = {
|
|
|
256
411
|
* 注意:如果使用 Config Plugin 配置了 API Key,无需调用 initSDK()
|
|
257
412
|
*/
|
|
258
413
|
addLocationListener(listener) {
|
|
259
|
-
|
|
414
|
+
assertPrivacyReady('sdk');
|
|
415
|
+
const module = getNativeModule();
|
|
416
|
+
if (!module) {
|
|
260
417
|
throw ErrorHandler.nativeModuleUnavailable();
|
|
261
418
|
}
|
|
262
|
-
if (!
|
|
419
|
+
if (!module.addListener) {
|
|
263
420
|
ErrorLogger.warn('Native module does not support events');
|
|
421
|
+
return {
|
|
422
|
+
remove: () => { },
|
|
423
|
+
};
|
|
264
424
|
}
|
|
265
|
-
return
|
|
425
|
+
return module.addListener('onLocationUpdate', listener) || {
|
|
266
426
|
remove: () => { },
|
|
267
427
|
};
|
|
268
428
|
},
|
|
@@ -617,6 +777,28 @@ const ExpoGaodeMapModuleWithHelpers = {
|
|
|
617
777
|
export function getSDKConfig() {
|
|
618
778
|
return _sdkConfig;
|
|
619
779
|
}
|
|
780
|
+
;
|
|
781
|
+
const ExpoGaodeMapModuleWithHelpers = new Proxy(helperMethods, {
|
|
782
|
+
get(target, prop, receiver) {
|
|
783
|
+
if (Reflect.has(target, prop)) {
|
|
784
|
+
return Reflect.get(target, prop, receiver);
|
|
785
|
+
}
|
|
786
|
+
const nativeModule = getNativeModule(true);
|
|
787
|
+
if (!nativeModule) {
|
|
788
|
+
return undefined;
|
|
789
|
+
}
|
|
790
|
+
const value = Reflect.get(nativeModule, prop, nativeModule);
|
|
791
|
+
if (typeof prop === 'string' &&
|
|
792
|
+
privacySensitiveMethodNames.has(prop) &&
|
|
793
|
+
typeof value === 'function') {
|
|
794
|
+
return (...args) => {
|
|
795
|
+
assertPrivacyReady('sdk');
|
|
796
|
+
return value.apply(nativeModule, args);
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
return getBoundNativeValue(nativeModule, prop);
|
|
800
|
+
},
|
|
801
|
+
});
|
|
620
802
|
/**
|
|
621
803
|
* 获取用于 Web API 的 webKey(若未初始化或未提供则返回 undefined)
|
|
622
804
|
*/
|