expo-gaode-map-navigation 2.0.18 → 2.0.19
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 +4 -25
- package/build/ExpoGaodeMapNaviView.js +2 -1
- package/build/ExpoGaodeMapNaviView.js.map +1 -1
- package/build/ExpoGaodeMapNavigationModule.d.ts +1 -1
- package/build/ExpoGaodeMapNavigationModule.d.ts.map +1 -1
- package/build/ExpoGaodeMapNavigationModule.js.map +1 -1
- package/build/map/ExpoGaodeMapModule.d.ts +3 -2
- package/build/map/ExpoGaodeMapModule.d.ts.map +1 -1
- package/build/map/ExpoGaodeMapModule.js +3 -1
- package/build/map/ExpoGaodeMapModule.js.map +1 -1
- package/build/map/ExpoGaodeMapOfflineModule.js +1 -1
- package/build/map/ExpoGaodeMapOfflineModule.js.map +1 -1
- package/build/map/ExpoGaodeMapView.js +2 -8
- package/build/map/ExpoGaodeMapView.js.map +1 -1
- package/build/map/components/FoldableMapView.d.ts +3 -2
- package/build/map/components/FoldableMapView.d.ts.map +1 -1
- package/build/map/components/FoldableMapView.js +2 -1
- package/build/map/components/FoldableMapView.js.map +1 -1
- package/build/map/components/MapUI.js +2 -1
- package/build/map/components/MapUI.js.map +1 -1
- package/build/map/components/overlays/Circle.d.ts +1 -1
- package/build/map/components/overlays/Circle.d.ts.map +1 -1
- package/build/map/components/overlays/Circle.js +2 -1
- package/build/map/components/overlays/Circle.js.map +1 -1
- package/build/map/components/overlays/Cluster.d.ts +1 -1
- package/build/map/components/overlays/Cluster.d.ts.map +1 -1
- package/build/map/components/overlays/Cluster.js +2 -1
- package/build/map/components/overlays/Cluster.js.map +1 -1
- package/build/map/components/overlays/HeatMap.d.ts +1 -1
- package/build/map/components/overlays/HeatMap.d.ts.map +1 -1
- package/build/map/components/overlays/HeatMap.js +2 -1
- package/build/map/components/overlays/HeatMap.js.map +1 -1
- package/build/map/components/overlays/Marker.d.ts +1 -1
- package/build/map/components/overlays/Marker.d.ts.map +1 -1
- package/build/map/components/overlays/Marker.js +2 -5
- package/build/map/components/overlays/Marker.js.map +1 -1
- package/build/map/components/overlays/MultiPoint.d.ts +1 -2
- package/build/map/components/overlays/MultiPoint.d.ts.map +1 -1
- package/build/map/components/overlays/MultiPoint.js +2 -1
- package/build/map/components/overlays/MultiPoint.js.map +1 -1
- package/build/map/components/overlays/Polygon.d.ts +1 -1
- package/build/map/components/overlays/Polygon.d.ts.map +1 -1
- package/build/map/components/overlays/Polygon.js +2 -1
- package/build/map/components/overlays/Polygon.js.map +1 -1
- package/build/map/components/overlays/Polyline.d.ts +1 -1
- package/build/map/components/overlays/Polyline.d.ts.map +1 -1
- package/build/map/components/overlays/Polyline.js +2 -1
- package/build/map/components/overlays/Polyline.js.map +1 -1
- package/build/map/search/ExpoGaodeMapSearchModule.d.ts +1 -1
- package/build/map/search/ExpoGaodeMapSearchModule.d.ts.map +1 -1
- package/build/map/search/ExpoGaodeMapSearchModule.js.map +1 -1
- package/build/map/types/common.types.d.ts +1 -1
- 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/map-view.types.d.ts +2 -2
- package/build/map/types/map-view.types.d.ts.map +1 -1
- package/build/map/types/map-view.types.js.map +1 -1
- package/build/map/utils/GeoUtils.d.ts +1 -1
- package/build/map/utils/GeoUtils.d.ts.map +1 -1
- package/build/map/utils/GeoUtils.js +2 -2
- package/build/map/utils/GeoUtils.js.map +1 -1
- package/build/route-geometry.d.ts.map +1 -1
- package/build/route-geometry.js +24 -8
- package/build/route-geometry.js.map +1 -1
- package/build/src/ExpoGaodeMapNaviView.d.ts +67 -0
- package/build/src/ExpoGaodeMapNaviView.d.ts.map +1 -0
- package/build/src/ExpoGaodeMapNaviView.js +138 -0
- package/build/src/ExpoGaodeMapNaviView.js.map +1 -0
- package/build/src/ExpoGaodeMapNavigation.types.d.ts +2 -0
- package/build/src/ExpoGaodeMapNavigation.types.d.ts.map +1 -0
- package/build/src/ExpoGaodeMapNavigation.types.js +3 -0
- package/build/src/ExpoGaodeMapNavigation.types.js.map +1 -0
- package/build/src/ExpoGaodeMapNavigationModule.d.ts +4 -0
- package/build/src/ExpoGaodeMapNavigationModule.d.ts.map +1 -0
- package/build/src/ExpoGaodeMapNavigationModule.js +27 -0
- package/build/src/ExpoGaodeMapNavigationModule.js.map +1 -0
- package/build/src/index.d.ts +47 -0
- package/build/src/index.d.ts.map +1 -0
- package/build/src/index.js +48 -0
- package/build/src/index.js.map +1 -0
- package/build/src/map/ExpoGaodeMapModule.d.ts +256 -0
- package/build/src/map/ExpoGaodeMapModule.d.ts.map +1 -0
- package/build/src/map/ExpoGaodeMapModule.js +813 -0
- package/build/src/map/ExpoGaodeMapModule.js.map +1 -0
- package/build/src/map/ExpoGaodeMapOfflineModule.d.ts +145 -0
- package/build/src/map/ExpoGaodeMapOfflineModule.d.ts.map +1 -0
- package/build/src/map/ExpoGaodeMapOfflineModule.js +24 -0
- package/build/src/map/ExpoGaodeMapOfflineModule.js.map +1 -0
- package/build/src/map/ExpoGaodeMapView.d.ts +23 -0
- package/build/src/map/ExpoGaodeMapView.d.ts.map +1 -0
- package/build/src/map/ExpoGaodeMapView.js +173 -0
- package/build/src/map/ExpoGaodeMapView.js.map +1 -0
- package/build/src/map/components/FoldableMapView.d.ts +39 -0
- package/build/src/map/components/FoldableMapView.d.ts.map +1 -0
- package/build/src/map/components/FoldableMapView.js +171 -0
- package/build/src/map/components/FoldableMapView.js.map +1 -0
- package/build/src/map/components/MapContext.d.ts +13 -0
- package/build/src/map/components/MapContext.d.ts.map +1 -0
- package/build/src/map/components/MapContext.js +18 -0
- package/build/src/map/components/MapContext.js.map +1 -0
- package/build/src/map/components/MapUI.d.ts +19 -0
- package/build/src/map/components/MapUI.d.ts.map +1 -0
- package/build/src/map/components/MapUI.js +24 -0
- package/build/src/map/components/MapUI.js.map +1 -0
- package/build/src/map/components/overlays/Circle.d.ts +13 -0
- package/build/src/map/components/overlays/Circle.d.ts.map +1 -0
- package/build/src/map/components/overlays/Circle.js +20 -0
- package/build/src/map/components/overlays/Circle.js.map +1 -0
- package/build/src/map/components/overlays/Cluster.d.ts +12 -0
- package/build/src/map/components/overlays/Cluster.d.ts.map +1 -0
- package/build/src/map/components/overlays/Cluster.js +16 -0
- package/build/src/map/components/overlays/Cluster.js.map +1 -0
- package/build/src/map/components/overlays/HeatMap.d.ts +12 -0
- package/build/src/map/components/overlays/HeatMap.d.ts.map +1 -0
- package/build/src/map/components/overlays/HeatMap.js +46 -0
- package/build/src/map/components/overlays/HeatMap.js.map +1 -0
- package/build/src/map/components/overlays/Marker.d.ts +16 -0
- package/build/src/map/components/overlays/Marker.d.ts.map +1 -0
- package/build/src/map/components/overlays/Marker.js +125 -0
- package/build/src/map/components/overlays/Marker.js.map +1 -0
- package/build/src/map/components/overlays/MultiPoint.d.ts +9 -0
- package/build/src/map/components/overlays/MultiPoint.d.ts.map +1 -0
- package/build/src/map/components/overlays/MultiPoint.js +15 -0
- package/build/src/map/components/overlays/MultiPoint.js.map +1 -0
- package/build/src/map/components/overlays/Polygon.d.ts +12 -0
- package/build/src/map/components/overlays/Polygon.d.ts.map +1 -0
- package/build/src/map/components/overlays/Polygon.js +20 -0
- package/build/src/map/components/overlays/Polygon.js.map +1 -0
- package/build/src/map/components/overlays/Polyline.d.ts +12 -0
- package/build/src/map/components/overlays/Polyline.d.ts.map +1 -0
- package/build/src/map/components/overlays/Polyline.js +20 -0
- package/build/src/map/components/overlays/Polyline.js.map +1 -0
- package/build/src/map/components/overlays/index.d.ts +8 -0
- package/build/src/map/components/overlays/index.d.ts.map +1 -0
- package/build/src/map/components/overlays/index.js +8 -0
- package/build/src/map/components/overlays/index.js.map +1 -0
- package/build/src/map/index.d.ts +35 -0
- package/build/src/map/index.d.ts.map +1 -0
- package/build/src/map/index.js +48 -0
- package/build/src/map/index.js.map +1 -0
- package/build/src/map/search/ExpoGaodeMapSearch.types.d.ts +340 -0
- package/build/src/map/search/ExpoGaodeMapSearch.types.d.ts.map +1 -0
- package/build/src/map/search/ExpoGaodeMapSearch.types.js +19 -0
- package/build/src/map/search/ExpoGaodeMapSearch.types.js.map +1 -0
- package/build/src/map/search/ExpoGaodeMapSearchModule.d.ts +74 -0
- package/build/src/map/search/ExpoGaodeMapSearchModule.d.ts.map +1 -0
- package/build/src/map/search/ExpoGaodeMapSearchModule.js +48 -0
- package/build/src/map/search/ExpoGaodeMapSearchModule.js.map +1 -0
- package/build/src/map/search/index.d.ts +156 -0
- package/build/src/map/search/index.d.ts.map +1 -0
- package/build/src/map/search/index.js +171 -0
- package/build/src/map/search/index.js.map +1 -0
- package/build/src/map/types/common.types.d.ts +199 -0
- package/build/src/map/types/common.types.d.ts.map +1 -0
- package/build/src/map/types/common.types.js +33 -0
- package/build/src/map/types/common.types.js.map +1 -0
- package/build/src/map/types/index.d.ts +13 -0
- package/build/src/map/types/index.d.ts.map +1 -0
- package/build/src/map/types/index.js +7 -0
- package/build/src/map/types/index.js.map +1 -0
- package/build/src/map/types/location.types.d.ts +358 -0
- package/build/src/map/types/location.types.d.ts.map +1 -0
- package/build/src/map/types/location.types.js +93 -0
- package/build/src/map/types/location.types.js.map +1 -0
- package/build/src/map/types/map-view.types.d.ts +340 -0
- package/build/src/map/types/map-view.types.d.ts.map +1 -0
- package/build/src/map/types/map-view.types.js +6 -0
- package/build/src/map/types/map-view.types.js.map +1 -0
- package/build/src/map/types/native-module.types.d.ts +395 -0
- package/build/src/map/types/native-module.types.d.ts.map +1 -0
- package/build/src/map/types/native-module.types.js +5 -0
- package/build/src/map/types/native-module.types.js.map +1 -0
- package/build/src/map/types/offline.types.d.ts +133 -0
- package/build/src/map/types/offline.types.d.ts.map +1 -0
- package/build/src/map/types/offline.types.js +5 -0
- package/build/src/map/types/offline.types.js.map +1 -0
- package/build/src/map/types/overlays.types.d.ts +456 -0
- package/build/src/map/types/overlays.types.d.ts.map +1 -0
- package/build/src/map/types/overlays.types.js +6 -0
- package/build/src/map/types/overlays.types.js.map +1 -0
- package/build/src/map/types/route-playback.types.d.ts +28 -0
- package/build/src/map/types/route-playback.types.d.ts.map +1 -0
- package/build/src/map/types/route-playback.types.js +2 -0
- package/build/src/map/types/route-playback.types.js.map +1 -0
- package/build/src/map/utils/ErrorHandler.d.ts +121 -0
- package/build/src/map/utils/ErrorHandler.d.ts.map +1 -0
- package/build/src/map/utils/ErrorHandler.js +470 -0
- package/build/src/map/utils/ErrorHandler.js.map +1 -0
- package/build/src/map/utils/GeoUtils.d.ts +21 -0
- package/build/src/map/utils/GeoUtils.d.ts.map +1 -0
- package/build/src/map/utils/GeoUtils.js +78 -0
- package/build/src/map/utils/GeoUtils.js.map +1 -0
- package/build/src/map/utils/OfflineMapManager.d.ts +153 -0
- package/build/src/map/utils/OfflineMapManager.d.ts.map +1 -0
- package/build/src/map/utils/OfflineMapManager.js +217 -0
- package/build/src/map/utils/OfflineMapManager.js.map +1 -0
- package/build/src/map/utils/PermissionUtils.d.ts +92 -0
- package/build/src/map/utils/PermissionUtils.d.ts.map +1 -0
- package/build/src/map/utils/PermissionUtils.js +252 -0
- package/build/src/map/utils/PermissionUtils.js.map +1 -0
- package/build/src/map/utils/PlatformDetector.d.ts +103 -0
- package/build/src/map/utils/PlatformDetector.d.ts.map +1 -0
- package/build/src/map/utils/PlatformDetector.js +178 -0
- package/build/src/map/utils/PlatformDetector.js.map +1 -0
- package/build/src/map/utils/lazyNativeViewManager.d.ts +3 -0
- package/build/src/map/utils/lazyNativeViewManager.d.ts.map +1 -0
- package/build/src/map/utils/lazyNativeViewManager.js +11 -0
- package/build/src/map/utils/lazyNativeViewManager.js.map +1 -0
- package/build/src/route-geometry.d.ts +13 -0
- package/build/src/route-geometry.d.ts.map +1 -0
- package/build/src/route-geometry.js +154 -0
- package/build/src/route-geometry.js.map +1 -0
- package/build/src/route-planning.d.ts +21 -0
- package/build/src/route-planning.d.ts.map +1 -0
- package/build/src/route-planning.js +67 -0
- package/build/src/route-planning.js.map +1 -0
- package/build/src/types/coordinates.types.d.ts +25 -0
- package/build/src/types/coordinates.types.d.ts.map +1 -0
- package/build/src/types/coordinates.types.js +6 -0
- package/build/src/types/coordinates.types.js.map +1 -0
- package/build/src/types/independent.types.d.ts +385 -0
- package/build/src/types/independent.types.d.ts.map +1 -0
- package/build/src/types/independent.types.js +2 -0
- package/build/src/types/independent.types.js.map +1 -0
- package/build/src/types/index.d.ts +6 -0
- package/build/src/types/index.d.ts.map +1 -0
- package/build/src/types/index.js +7 -0
- package/build/src/types/index.js.map +1 -0
- package/build/src/types/native-module.types.d.ts +74 -0
- package/build/src/types/native-module.types.d.ts.map +1 -0
- package/build/src/types/native-module.types.js +3 -0
- package/build/src/types/native-module.types.js.map +1 -0
- package/build/src/types/naviview.types.d.ts +562 -0
- package/build/src/types/naviview.types.d.ts.map +1 -0
- package/build/src/types/naviview.types.js +2 -0
- package/build/src/types/naviview.types.js.map +1 -0
- package/build/src/types/route.types.d.ts +414 -0
- package/build/src/types/route.types.d.ts.map +1 -0
- package/build/src/types/route.types.js +137 -0
- package/build/src/types/route.types.js.map +1 -0
- package/build/src/web-api-fallback.d.ts +5 -0
- package/build/src/web-api-fallback.d.ts.map +1 -0
- package/build/src/web-api-fallback.js +160 -0
- package/build/src/web-api-fallback.js.map +1 -0
- package/build/src/web-route-following.d.ts +3 -0
- package/build/src/web-route-following.d.ts.map +1 -0
- package/build/src/web-route-following.js +178 -0
- package/build/src/web-route-following.js.map +1 -0
- package/build/types/native-module.types.d.ts +2 -2
- package/build/types/native-module.types.d.ts.map +1 -1
- package/build/types/native-module.types.js.map +1 -1
- package/build/types/naviview.types.d.ts +1 -1
- package/build/types/naviview.types.d.ts.map +1 -1
- package/build/types/naviview.types.js.map +1 -1
- package/build/web-api-fallback.d.ts.map +1 -1
- package/build/web-api-fallback.js +0 -1
- package/build/web-api-fallback.js.map +1 -1
- package/ios/map/ExpoGaodeMapView.swift +145 -3
- package/ios/map/managers/UIManager.swift +3 -0
- package/package.json +10 -7
- package/plugin/build/withGaodeMap.js +19 -14
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { PlatformDetector } from './PlatformDetector';
|
|
3
|
+
/**
|
|
4
|
+
* 位置权限类型
|
|
5
|
+
*/
|
|
6
|
+
export var LocationPermissionType;
|
|
7
|
+
(function (LocationPermissionType) {
|
|
8
|
+
/** 仅前台(使用时) */
|
|
9
|
+
LocationPermissionType["FOREGROUND"] = "foreground";
|
|
10
|
+
/** 后台位置 */
|
|
11
|
+
LocationPermissionType["BACKGROUND"] = "background";
|
|
12
|
+
/** 前台+后台 */
|
|
13
|
+
LocationPermissionType["FOREGROUND_AND_BACKGROUND"] = "foreground_and_background";
|
|
14
|
+
})(LocationPermissionType || (LocationPermissionType = {}));
|
|
15
|
+
/**
|
|
16
|
+
* 权限工具类
|
|
17
|
+
*
|
|
18
|
+
* 🔔 **重要说明**:
|
|
19
|
+
*
|
|
20
|
+
* 本工具类**不执行实际的权限请求**,仅提供:
|
|
21
|
+
* - 平台检测(Android 14+、iOS 17+)
|
|
22
|
+
* - 权限说明文案(适配新系统特性)
|
|
23
|
+
* - 最佳实践建议
|
|
24
|
+
* - 诊断信息
|
|
25
|
+
*
|
|
26
|
+
* **实际权限请求请使用**:
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import ExpoGaodeMapModule from 'expo-gaode-map';
|
|
29
|
+
*
|
|
30
|
+
* // 检查权限
|
|
31
|
+
* const status = await ExpoGaodeMapModule.checkLocationPermission();
|
|
32
|
+
*
|
|
33
|
+
* // 请求权限
|
|
34
|
+
* const result = await ExpoGaodeMapModule.requestLocationPermission();
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* 本工具类主要用于在请求权限**之前**向用户展示说明文案。
|
|
38
|
+
*/
|
|
39
|
+
export class PermissionUtils {
|
|
40
|
+
/**
|
|
41
|
+
* 检查当前平台的系统版本
|
|
42
|
+
*/
|
|
43
|
+
static getSystemInfo() {
|
|
44
|
+
const platform = Platform.OS;
|
|
45
|
+
const systemVersion = PlatformDetector.getSystemVersion();
|
|
46
|
+
return {
|
|
47
|
+
platform,
|
|
48
|
+
version: systemVersion.version,
|
|
49
|
+
isAndroid14Plus: PlatformDetector.needsAndroid14Permissions(),
|
|
50
|
+
isiOS17Plus: PlatformDetector.supportsiOS17Features(),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 获取权限说明文案
|
|
55
|
+
*/
|
|
56
|
+
static getPermissionRationale(type) {
|
|
57
|
+
const { platform, isAndroid14Plus, isiOS17Plus } = this.getSystemInfo();
|
|
58
|
+
if (platform === 'android') {
|
|
59
|
+
return this.getAndroidRationale(type, isAndroid14Plus);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return this.getiOSRationale(type, isiOS17Plus);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Android 权限说明文案
|
|
67
|
+
*/
|
|
68
|
+
static getAndroidRationale(type, isAndroid14) {
|
|
69
|
+
switch (type) {
|
|
70
|
+
case LocationPermissionType.FOREGROUND:
|
|
71
|
+
if (isAndroid14) {
|
|
72
|
+
return `为了在地图上显示您的位置,应用需要访问您的位置信息。
|
|
73
|
+
|
|
74
|
+
您可以选择:
|
|
75
|
+
• 仅在使用应用时允许
|
|
76
|
+
• 每次询问
|
|
77
|
+
|
|
78
|
+
我们不会在后台收集您的位置数据。`;
|
|
79
|
+
}
|
|
80
|
+
return '为了在地图上显示您的位置,应用需要访问您的位置信息。';
|
|
81
|
+
case LocationPermissionType.BACKGROUND:
|
|
82
|
+
if (isAndroid14) {
|
|
83
|
+
return `为了在后台更新您的位置(如导航、轨迹记录),应用需要始终访问位置权限。
|
|
84
|
+
|
|
85
|
+
您可以随时在设置中更改此权限。`;
|
|
86
|
+
}
|
|
87
|
+
return '为了在后台更新您的位置,应用需要始终访问位置权限。';
|
|
88
|
+
case LocationPermissionType.FOREGROUND_AND_BACKGROUND:
|
|
89
|
+
if (isAndroid14) {
|
|
90
|
+
return `应用需要位置权限来提供以下功能:
|
|
91
|
+
• 在地图上显示您的位置(前台)
|
|
92
|
+
• 后台导航和轨迹记录(后台)
|
|
93
|
+
|
|
94
|
+
我们会先请求前台权限,然后再请求后台权限。`;
|
|
95
|
+
}
|
|
96
|
+
return '应用需要位置权限来显示地图位置和后台导航功能。';
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* iOS 权限说明文案
|
|
101
|
+
*/
|
|
102
|
+
static getiOSRationale(type, isiOS17) {
|
|
103
|
+
switch (type) {
|
|
104
|
+
case LocationPermissionType.FOREGROUND:
|
|
105
|
+
if (isiOS17) {
|
|
106
|
+
return `为了在地图上显示您的位置,应用需要访问您的位置信息。
|
|
107
|
+
|
|
108
|
+
您可以选择:
|
|
109
|
+
• 使用 App 期间:仅在使用应用时访问位置
|
|
110
|
+
• 一次:仅本次使用时访问位置
|
|
111
|
+
|
|
112
|
+
我们不会在后台收集您的位置数据。`;
|
|
113
|
+
}
|
|
114
|
+
return '为了在地图上显示您的位置,应用需要访问您的位置信息。';
|
|
115
|
+
case LocationPermissionType.BACKGROUND:
|
|
116
|
+
case LocationPermissionType.FOREGROUND_AND_BACKGROUND:
|
|
117
|
+
if (isiOS17) {
|
|
118
|
+
return `为了提供以下功能,应用需要始终访问位置权限:
|
|
119
|
+
• 后台导航和路径规划
|
|
120
|
+
• 轨迹记录
|
|
121
|
+
• 位置提醒
|
|
122
|
+
|
|
123
|
+
您可以随时在设置中更改此权限。`;
|
|
124
|
+
}
|
|
125
|
+
return '为了在后台更新您的位置,应用需要始终访问位置权限。';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* 获取精确位置权限说明(iOS 14+)
|
|
130
|
+
*/
|
|
131
|
+
static getAccuracyRationale() {
|
|
132
|
+
const { isiOS17Plus } = this.getSystemInfo();
|
|
133
|
+
if (isiOS17Plus) {
|
|
134
|
+
return `为了提供准确的导航和定位服务,应用需要访问精确位置。
|
|
135
|
+
|
|
136
|
+
选择"模糊位置"可能会导致:
|
|
137
|
+
• 地图定位不准确
|
|
138
|
+
• 导航路线偏差
|
|
139
|
+
• 搜索结果不精确`;
|
|
140
|
+
}
|
|
141
|
+
return '为了提供准确的导航和定位服务,应用需要访问精确位置。';
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 获取权限请求的最佳实践建议
|
|
145
|
+
*/
|
|
146
|
+
static getBestPractices() {
|
|
147
|
+
return {
|
|
148
|
+
android14: [
|
|
149
|
+
'先解释为什么需要权限,再发起请求',
|
|
150
|
+
'前台和后台权限分两步请求',
|
|
151
|
+
'永久拒绝后引导用户到设置页面',
|
|
152
|
+
'提供"仅本次"选项的说明',
|
|
153
|
+
],
|
|
154
|
+
ios17: [
|
|
155
|
+
'在 Info.plist 中提供清晰的权限说明',
|
|
156
|
+
'使用 Privacy Manifest 声明位置访问原因',
|
|
157
|
+
'先请求"使用期间",再请求"始终允许"',
|
|
158
|
+
'支持"仅一次"权限模式',
|
|
159
|
+
],
|
|
160
|
+
general: [
|
|
161
|
+
'在用户需要使用功能时再请求权限',
|
|
162
|
+
'清晰解释权限用途和好处',
|
|
163
|
+
'提供拒绝后的替代方案',
|
|
164
|
+
'尊重用户的权限选择',
|
|
165
|
+
],
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* 验证 Info.plist 配置(仅 iOS)
|
|
170
|
+
*/
|
|
171
|
+
static validateiOSConfiguration() {
|
|
172
|
+
if (Platform.OS !== 'ios') {
|
|
173
|
+
return {
|
|
174
|
+
valid: true,
|
|
175
|
+
missingKeys: [],
|
|
176
|
+
recommendations: [],
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const recommendations = [];
|
|
180
|
+
const { isiOS17Plus } = this.getSystemInfo();
|
|
181
|
+
if (isiOS17Plus) {
|
|
182
|
+
recommendations.push('建议在 Privacy Manifest (PrivacyInfo.xcprivacy) 中声明位置访问原因', '确保 NSLocationWhenInUseUsageDescription 文案清晰、具体', '如需后台位置,配置 NSLocationAlwaysAndWhenInUseUsageDescription');
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
valid: true,
|
|
186
|
+
missingKeys: [],
|
|
187
|
+
recommendations,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* 检查是否支持后台位置权限
|
|
192
|
+
*/
|
|
193
|
+
static supportsBackgroundLocation() {
|
|
194
|
+
const { platform, version } = this.getSystemInfo();
|
|
195
|
+
if (platform === 'android') {
|
|
196
|
+
// Android 10 (API 29) 引入后台位置权限
|
|
197
|
+
return version >= 29;
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
// iOS 8+ 支持
|
|
201
|
+
return version >= 8;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* 打印权限诊断信息
|
|
206
|
+
*/
|
|
207
|
+
static printDiagnostics() {
|
|
208
|
+
const info = this.getSystemInfo();
|
|
209
|
+
console.log('=== 权限管理诊断信息 ===');
|
|
210
|
+
console.log(`平台: ${info.platform}`);
|
|
211
|
+
console.log(`系统版本: ${info.version}`);
|
|
212
|
+
console.log(`Android 14+: ${info.isAndroid14Plus ? '是' : '否'}`);
|
|
213
|
+
console.log(`iOS 17+: ${info.isiOS17Plus ? '是' : '否'}`);
|
|
214
|
+
console.log(`支持后台位置: ${this.supportsBackgroundLocation() ? '是' : '否'}`);
|
|
215
|
+
const practices = this.getBestPractices();
|
|
216
|
+
console.log('\n💡 最佳实践建议:');
|
|
217
|
+
if (info.isAndroid14Plus) {
|
|
218
|
+
console.log('\nAndroid 14+ 特别注意:');
|
|
219
|
+
practices.android14.forEach((tip, index) => {
|
|
220
|
+
console.log(` ${index + 1}. ${tip}`);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
if (info.isiOS17Plus) {
|
|
224
|
+
console.log('\niOS 17+ 特别注意:');
|
|
225
|
+
practices.ios17.forEach((tip, index) => {
|
|
226
|
+
console.log(` ${index + 1}. ${tip}`);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
console.log('\n通用建议:');
|
|
230
|
+
practices.general.forEach((tip, index) => {
|
|
231
|
+
console.log(` ${index + 1}. ${tip}`);
|
|
232
|
+
});
|
|
233
|
+
if (info.platform === 'ios') {
|
|
234
|
+
const validation = this.validateiOSConfiguration();
|
|
235
|
+
if (validation.recommendations.length > 0) {
|
|
236
|
+
console.log('\niOS 配置建议:');
|
|
237
|
+
validation.recommendations.forEach((rec, index) => {
|
|
238
|
+
console.log(` ${index + 1}. ${rec}`);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
console.log('\n📌 实际权限请求:');
|
|
243
|
+
console.log(' 使用 ExpoGaodeMapModule.checkLocationPermission()');
|
|
244
|
+
console.log(' 使用 ExpoGaodeMapModule.requestLocationPermission()');
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* 向后兼容的别名
|
|
249
|
+
* @deprecated 请使用 PermissionUtils
|
|
250
|
+
*/
|
|
251
|
+
export const PermissionManager = PermissionUtils;
|
|
252
|
+
//# sourceMappingURL=PermissionUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PermissionUtils.js","sourceRoot":"","sources":["../../../../src/map/utils/PermissionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;GAEG;AACH,MAAM,CAAN,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,eAAe;IACf,mDAAyB,CAAA;IACzB,WAAW;IACX,mDAAyB,CAAA;IACzB,YAAY;IACZ,iFAAuD,CAAA;AACzD,CAAC,EAPW,sBAAsB,KAAtB,sBAAsB,QAOjC;AAED;;;;;;;;;;;;;;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ChD,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;gBACxC,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;QACjE,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;IACrE,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC","sourcesContent":["import { Platform } from 'react-native';\nimport { PlatformDetector } from './PlatformDetector';\n\n/**\n * 位置权限类型\n */\nexport enum LocationPermissionType {\n /** 仅前台(使用时) */\n FOREGROUND = 'foreground',\n /** 后台位置 */\n BACKGROUND = 'background',\n /** 前台+后台 */\n FOREGROUND_AND_BACKGROUND = 'foreground_and_background',\n}\n\n/**\n * 权限工具类\n *\n * 🔔 **重要说明**:\n *\n * 本工具类**不执行实际的权限请求**,仅提供:\n * - 平台检测(Android 14+、iOS 17+)\n * - 权限说明文案(适配新系统特性)\n * - 最佳实践建议\n * - 诊断信息\n *\n * **实际权限请求请使用**:\n * ```typescript\n * import ExpoGaodeMapModule from 'expo-gaode-map';\n *\n * // 检查权限\n * const status = await ExpoGaodeMapModule.checkLocationPermission();\n *\n * // 请求权限\n * const result = await ExpoGaodeMapModule.requestLocationPermission();\n * ```\n *\n * 本工具类主要用于在请求权限**之前**向用户展示说明文案。\n */\nexport class PermissionUtils {\n /**\n * 检查当前平台的系统版本\n */\n static getSystemInfo(): {\n platform: 'android' | 'ios';\n version: number;\n isAndroid14Plus: boolean;\n isiOS17Plus: boolean;\n } {\n const platform = Platform.OS as 'android' | 'ios';\n const systemVersion = PlatformDetector.getSystemVersion();\n \n return {\n platform,\n version: systemVersion.version,\n isAndroid14Plus: PlatformDetector.needsAndroid14Permissions(),\n isiOS17Plus: PlatformDetector.supportsiOS17Features(),\n };\n }\n\n /**\n * 获取权限说明文案\n */\n static getPermissionRationale(type: LocationPermissionType): string {\n const { platform, isAndroid14Plus, isiOS17Plus } = this.getSystemInfo();\n \n if (platform === 'android') {\n return this.getAndroidRationale(type, isAndroid14Plus);\n } else {\n return this.getiOSRationale(type, isiOS17Plus);\n }\n }\n\n /**\n * Android 权限说明文案\n */\n private static getAndroidRationale(\n type: LocationPermissionType,\n isAndroid14: boolean\n ): string {\n switch (type) {\n case LocationPermissionType.FOREGROUND:\n if (isAndroid14) {\n return `为了在地图上显示您的位置,应用需要访问您的位置信息。\n\n您可以选择:\n• 仅在使用应用时允许\n• 每次询问\n\n我们不会在后台收集您的位置数据。`;\n }\n return '为了在地图上显示您的位置,应用需要访问您的位置信息。';\n\n case LocationPermissionType.BACKGROUND:\n if (isAndroid14) {\n return `为了在后台更新您的位置(如导航、轨迹记录),应用需要始终访问位置权限。\n\n您可以随时在设置中更改此权限。`;\n }\n return '为了在后台更新您的位置,应用需要始终访问位置权限。';\n\n case LocationPermissionType.FOREGROUND_AND_BACKGROUND:\n if (isAndroid14) {\n return `应用需要位置权限来提供以下功能:\n• 在地图上显示您的位置(前台)\n• 后台导航和轨迹记录(后台)\n\n我们会先请求前台权限,然后再请求后台权限。`;\n }\n return '应用需要位置权限来显示地图位置和后台导航功能。';\n }\n }\n\n /**\n * iOS 权限说明文案\n */\n private static getiOSRationale(\n type: LocationPermissionType,\n isiOS17: boolean\n ): string {\n switch (type) {\n case LocationPermissionType.FOREGROUND:\n if (isiOS17) {\n return `为了在地图上显示您的位置,应用需要访问您的位置信息。\n\n您可以选择:\n• 使用 App 期间:仅在使用应用时访问位置\n• 一次:仅本次使用时访问位置\n\n我们不会在后台收集您的位置数据。`;\n }\n return '为了在地图上显示您的位置,应用需要访问您的位置信息。';\n\n case LocationPermissionType.BACKGROUND:\n case LocationPermissionType.FOREGROUND_AND_BACKGROUND:\n if (isiOS17) {\n return `为了提供以下功能,应用需要始终访问位置权限:\n• 后台导航和路径规划\n• 轨迹记录\n• 位置提醒\n\n您可以随时在设置中更改此权限。`;\n }\n return '为了在后台更新您的位置,应用需要始终访问位置权限。';\n }\n }\n\n /**\n * 获取精确位置权限说明(iOS 14+)\n */\n static getAccuracyRationale(): string {\n const { isiOS17Plus } = this.getSystemInfo();\n \n if (isiOS17Plus) {\n return `为了提供准确的导航和定位服务,应用需要访问精确位置。\n\n选择\"模糊位置\"可能会导致:\n• 地图定位不准确\n• 导航路线偏差\n• 搜索结果不精确`;\n }\n \n return '为了提供准确的导航和定位服务,应用需要访问精确位置。';\n }\n\n /**\n * 获取权限请求的最佳实践建议\n */\n static getBestPractices(): {\n android14: string[];\n ios17: string[];\n general: string[];\n } {\n return {\n android14: [\n '先解释为什么需要权限,再发起请求',\n '前台和后台权限分两步请求',\n '永久拒绝后引导用户到设置页面',\n '提供\"仅本次\"选项的说明',\n ],\n ios17: [\n '在 Info.plist 中提供清晰的权限说明',\n '使用 Privacy Manifest 声明位置访问原因',\n '先请求\"使用期间\",再请求\"始终允许\"',\n '支持\"仅一次\"权限模式',\n ],\n general: [\n '在用户需要使用功能时再请求权限',\n '清晰解释权限用途和好处',\n '提供拒绝后的替代方案',\n '尊重用户的权限选择',\n ],\n };\n }\n\n /**\n * 验证 Info.plist 配置(仅 iOS)\n */\n static validateiOSConfiguration(): {\n valid: boolean;\n missingKeys: string[];\n recommendations: string[];\n } {\n if (Platform.OS !== 'ios') {\n return {\n valid: true,\n missingKeys: [],\n recommendations: [],\n };\n }\n\n const recommendations: string[] = [];\n const { isiOS17Plus } = this.getSystemInfo();\n\n if (isiOS17Plus) {\n recommendations.push(\n '建议在 Privacy Manifest (PrivacyInfo.xcprivacy) 中声明位置访问原因',\n '确保 NSLocationWhenInUseUsageDescription 文案清晰、具体',\n '如需后台位置,配置 NSLocationAlwaysAndWhenInUseUsageDescription'\n );\n }\n\n return {\n valid: true,\n missingKeys: [],\n recommendations,\n };\n }\n\n /**\n * 检查是否支持后台位置权限\n */\n static supportsBackgroundLocation(): boolean {\n const { platform, version } = this.getSystemInfo();\n \n if (platform === 'android') {\n // Android 10 (API 29) 引入后台位置权限\n return version >= 29;\n } else {\n // iOS 8+ 支持\n return version >= 8;\n }\n }\n\n /**\n * 打印权限诊断信息\n */\n static printDiagnostics(): void {\n const info = this.getSystemInfo();\n console.log('=== 权限管理诊断信息 ===');\n console.log(`平台: ${info.platform}`);\n console.log(`系统版本: ${info.version}`);\n console.log(`Android 14+: ${info.isAndroid14Plus ? '是' : '否'}`);\n console.log(`iOS 17+: ${info.isiOS17Plus ? '是' : '否'}`);\n console.log(`支持后台位置: ${this.supportsBackgroundLocation() ? '是' : '否'}`);\n \n const practices = this.getBestPractices();\n console.log('\\n💡 最佳实践建议:');\n \n if (info.isAndroid14Plus) {\n console.log('\\nAndroid 14+ 特别注意:');\n practices.android14.forEach((tip, index) => {\n console.log(` ${index + 1}. ${tip}`);\n });\n }\n \n if (info.isiOS17Plus) {\n console.log('\\niOS 17+ 特别注意:');\n practices.ios17.forEach((tip, index) => {\n console.log(` ${index + 1}. ${tip}`);\n });\n }\n \n console.log('\\n通用建议:');\n practices.general.forEach((tip, index) => {\n console.log(` ${index + 1}. ${tip}`);\n });\n \n if (info.platform === 'ios') {\n const validation = this.validateiOSConfiguration();\n if (validation.recommendations.length > 0) {\n console.log('\\niOS 配置建议:');\n validation.recommendations.forEach((rec, index) => {\n console.log(` ${index + 1}. ${rec}`);\n });\n }\n }\n \n console.log('\\n📌 实际权限请求:');\n console.log(' 使用 ExpoGaodeMapModule.checkLocationPermission()');\n console.log(' 使用 ExpoGaodeMapModule.requestLocationPermission()');\n }\n}\n\n/**\n * 向后兼容的别名\n * @deprecated 请使用 PermissionUtils\n */\nexport const PermissionManager = PermissionUtils;"]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 平台检测工具
|
|
3
|
+
* 用于检测设备特性、系统版本等
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 设备类型
|
|
7
|
+
*/
|
|
8
|
+
export declare enum DeviceType {
|
|
9
|
+
PHONE = "phone",
|
|
10
|
+
TABLET = "tablet",
|
|
11
|
+
FOLDABLE = "foldable",
|
|
12
|
+
UNKNOWN = "unknown"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 折叠状态
|
|
16
|
+
*/
|
|
17
|
+
export declare enum FoldState {
|
|
18
|
+
FOLDED = "folded",
|
|
19
|
+
UNFOLDED = "unfolded",
|
|
20
|
+
HALF_FOLDED = "half_folded",
|
|
21
|
+
UNKNOWN = "unknown"
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 设备信息
|
|
25
|
+
*/
|
|
26
|
+
export interface DeviceInfo {
|
|
27
|
+
type: DeviceType;
|
|
28
|
+
isTablet: boolean;
|
|
29
|
+
isFoldable: boolean;
|
|
30
|
+
screenSize: {
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
scale: number;
|
|
34
|
+
fontScale: number;
|
|
35
|
+
};
|
|
36
|
+
aspectRatio: number;
|
|
37
|
+
isLandscape: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 系统版本信息
|
|
41
|
+
*/
|
|
42
|
+
export interface SystemVersion {
|
|
43
|
+
platform: 'ios' | 'android';
|
|
44
|
+
version: number;
|
|
45
|
+
isAndroid14Plus: boolean;
|
|
46
|
+
isIOS17Plus: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 平台检测器类
|
|
50
|
+
*/
|
|
51
|
+
export declare class PlatformDetector {
|
|
52
|
+
private static deviceInfo;
|
|
53
|
+
private static systemVersion;
|
|
54
|
+
/**
|
|
55
|
+
* 获取系统版本信息
|
|
56
|
+
*/
|
|
57
|
+
static getSystemVersion(): SystemVersion;
|
|
58
|
+
/**
|
|
59
|
+
* 获取设备信息
|
|
60
|
+
*/
|
|
61
|
+
static getDeviceInfo(): DeviceInfo;
|
|
62
|
+
/**
|
|
63
|
+
* 检测折叠屏设备
|
|
64
|
+
*/
|
|
65
|
+
private static detectFoldable;
|
|
66
|
+
/**
|
|
67
|
+
* 检测当前折叠状态(需要原生支持)
|
|
68
|
+
*/
|
|
69
|
+
static getFoldState(): FoldState;
|
|
70
|
+
/**
|
|
71
|
+
* 是否为 iPad
|
|
72
|
+
*/
|
|
73
|
+
static isIPad(): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* 是否支持多任务
|
|
76
|
+
*/
|
|
77
|
+
static supportsMultitasking(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* 是否需要 Android 14+ 新权限流程
|
|
80
|
+
*/
|
|
81
|
+
static needsAndroid14Permissions(): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* 是否支持 iOS 17+ 新特性
|
|
84
|
+
*/
|
|
85
|
+
static supportsiOS17Features(): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* 监听屏幕尺寸变化(折叠屏展开/折叠)
|
|
88
|
+
*/
|
|
89
|
+
static addDimensionChangeListener(callback: (info: DeviceInfo) => void): () => void;
|
|
90
|
+
/**
|
|
91
|
+
* 重置缓存(用于测试或强制刷新)
|
|
92
|
+
*/
|
|
93
|
+
static resetCache(): void;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 便捷的导出函数
|
|
97
|
+
*/
|
|
98
|
+
export declare const isAndroid14Plus: () => boolean;
|
|
99
|
+
export declare const isiOS17Plus: () => boolean;
|
|
100
|
+
export declare const isTablet: () => boolean;
|
|
101
|
+
export declare const isFoldable: () => boolean;
|
|
102
|
+
export declare const isIPad: () => boolean;
|
|
103
|
+
//# sourceMappingURL=PlatformDetector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformDetector.d.ts","sourceRoot":"","sources":["../../../../src/map/utils/PlatformDetector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,oBAAY,UAAU;IACpB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,QAAQ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QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,GAAG,MAAM,IAAI;IAWnF;;OAEG;IACH,MAAM,CAAC,UAAU,IAAI,IAAI;CAI1B;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,eAAqD,CAAC;AAClF,eAAO,MAAM,WAAW,eAAiD,CAAC;AAC1E,eAAO,MAAM,QAAQ,eAAkD,CAAC;AACxE,eAAO,MAAM,UAAU,eAAoD,CAAC;AAC5E,eAAO,MAAM,MAAM,eAAkC,CAAC"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 平台检测工具
|
|
3
|
+
* 用于检测设备特性、系统版本等
|
|
4
|
+
*/
|
|
5
|
+
import { Platform, Dimensions } from 'react-native';
|
|
6
|
+
/**
|
|
7
|
+
* 设备类型
|
|
8
|
+
*/
|
|
9
|
+
export var DeviceType;
|
|
10
|
+
(function (DeviceType) {
|
|
11
|
+
DeviceType["PHONE"] = "phone";
|
|
12
|
+
DeviceType["TABLET"] = "tablet";
|
|
13
|
+
DeviceType["FOLDABLE"] = "foldable";
|
|
14
|
+
DeviceType["UNKNOWN"] = "unknown";
|
|
15
|
+
})(DeviceType || (DeviceType = {}));
|
|
16
|
+
/**
|
|
17
|
+
* 折叠状态
|
|
18
|
+
*/
|
|
19
|
+
export var FoldState;
|
|
20
|
+
(function (FoldState) {
|
|
21
|
+
FoldState["FOLDED"] = "folded";
|
|
22
|
+
FoldState["UNFOLDED"] = "unfolded";
|
|
23
|
+
FoldState["HALF_FOLDED"] = "half_folded";
|
|
24
|
+
FoldState["UNKNOWN"] = "unknown";
|
|
25
|
+
})(FoldState || (FoldState = {}));
|
|
26
|
+
/**
|
|
27
|
+
* 平台检测器类
|
|
28
|
+
*/
|
|
29
|
+
export class PlatformDetector {
|
|
30
|
+
static deviceInfo = null;
|
|
31
|
+
static systemVersion = null;
|
|
32
|
+
/**
|
|
33
|
+
* 获取系统版本信息
|
|
34
|
+
*/
|
|
35
|
+
static getSystemVersion() {
|
|
36
|
+
if (this.systemVersion) {
|
|
37
|
+
return this.systemVersion;
|
|
38
|
+
}
|
|
39
|
+
const version = parseInt(Platform.Version.toString(), 10);
|
|
40
|
+
this.systemVersion = {
|
|
41
|
+
platform: Platform.OS,
|
|
42
|
+
version,
|
|
43
|
+
isAndroid14Plus: Platform.OS === 'android' && version >= 34, // Android 14 = API 34
|
|
44
|
+
isIOS17Plus: Platform.OS === 'ios' && version >= 17,
|
|
45
|
+
};
|
|
46
|
+
return this.systemVersion;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 获取设备信息
|
|
50
|
+
*/
|
|
51
|
+
static getDeviceInfo() {
|
|
52
|
+
if (this.deviceInfo) {
|
|
53
|
+
return this.deviceInfo;
|
|
54
|
+
}
|
|
55
|
+
const { width, height, scale, fontScale } = Dimensions.get('window');
|
|
56
|
+
const aspectRatio = Math.max(width, height) / Math.min(width, height);
|
|
57
|
+
const isLandscape = width > height;
|
|
58
|
+
// 判断是否为平板(基于屏幕尺寸和宽高比)
|
|
59
|
+
const smallerDimension = Math.min(width, height);
|
|
60
|
+
const isTablet = smallerDimension >= 600 || aspectRatio < 1.6;
|
|
61
|
+
// 检测折叠屏(基于极端宽高比)
|
|
62
|
+
const isFoldable = this.detectFoldable(width, height, aspectRatio);
|
|
63
|
+
let type = DeviceType.PHONE;
|
|
64
|
+
if (isFoldable) {
|
|
65
|
+
type = DeviceType.FOLDABLE;
|
|
66
|
+
}
|
|
67
|
+
else if (isTablet) {
|
|
68
|
+
type = DeviceType.TABLET;
|
|
69
|
+
}
|
|
70
|
+
this.deviceInfo = {
|
|
71
|
+
type,
|
|
72
|
+
isTablet,
|
|
73
|
+
isFoldable,
|
|
74
|
+
screenSize: { width, height, scale, fontScale },
|
|
75
|
+
aspectRatio,
|
|
76
|
+
isLandscape,
|
|
77
|
+
};
|
|
78
|
+
return this.deviceInfo;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 检测折叠屏设备
|
|
82
|
+
*/
|
|
83
|
+
static detectFoldable(width, height, aspectRatio) {
|
|
84
|
+
// 常见折叠屏特征:
|
|
85
|
+
// 1. 展开时宽高比接近正方形或较小(1.2-1.6)
|
|
86
|
+
// 2. 折叠时宽高比很大(>2.1)
|
|
87
|
+
if (Platform.OS === 'android') {
|
|
88
|
+
// 检查是否为极端宽高比
|
|
89
|
+
if (aspectRatio > 2.1 || aspectRatio < 1.3) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
// 检查是否为特定分辨率(已知折叠屏设备)
|
|
93
|
+
const knownFoldableResolutions = [
|
|
94
|
+
{ w: 2208, h: 1768 }, // Galaxy Z Fold 展开
|
|
95
|
+
{ w: 2176, h: 1812 }, // Galaxy Z Fold 3/4 展开
|
|
96
|
+
{ w: 884, h: 2208 }, // Galaxy Z Fold 折叠
|
|
97
|
+
{ w: 1768, h: 2208 }, // Huawei Mate X
|
|
98
|
+
];
|
|
99
|
+
return knownFoldableResolutions.some((res) => (Math.abs(width - res.w) < 50 && Math.abs(height - res.h) < 50) ||
|
|
100
|
+
(Math.abs(width - res.h) < 50 && Math.abs(height - res.w) < 50));
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 检测当前折叠状态(需要原生支持)
|
|
106
|
+
*/
|
|
107
|
+
static getFoldState() {
|
|
108
|
+
const info = this.getDeviceInfo();
|
|
109
|
+
if (!info.isFoldable) {
|
|
110
|
+
return FoldState.UNKNOWN;
|
|
111
|
+
}
|
|
112
|
+
// 基于宽高比判断折叠状态
|
|
113
|
+
if (info.aspectRatio > 2.0) {
|
|
114
|
+
return FoldState.FOLDED;
|
|
115
|
+
}
|
|
116
|
+
else if (info.aspectRatio < 1.5) {
|
|
117
|
+
return FoldState.UNFOLDED;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return FoldState.HALF_FOLDED;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* 是否为 iPad
|
|
125
|
+
*/
|
|
126
|
+
static isIPad() {
|
|
127
|
+
if (Platform.OS !== 'ios') {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return this.getDeviceInfo().isTablet;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 是否支持多任务
|
|
134
|
+
*/
|
|
135
|
+
static supportsMultitasking() {
|
|
136
|
+
return Platform.OS === 'ios' && this.isIPad();
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* 是否需要 Android 14+ 新权限流程
|
|
140
|
+
*/
|
|
141
|
+
static needsAndroid14Permissions() {
|
|
142
|
+
return this.getSystemVersion().isAndroid14Plus;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 是否支持 iOS 17+ 新特性
|
|
146
|
+
*/
|
|
147
|
+
static supportsiOS17Features() {
|
|
148
|
+
return this.getSystemVersion().isIOS17Plus;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* 监听屏幕尺寸变化(折叠屏展开/折叠)
|
|
152
|
+
*/
|
|
153
|
+
static addDimensionChangeListener(callback) {
|
|
154
|
+
const subscription = Dimensions.addEventListener('change', () => {
|
|
155
|
+
// 清除缓存,重新计算
|
|
156
|
+
this.deviceInfo = null;
|
|
157
|
+
const newInfo = this.getDeviceInfo();
|
|
158
|
+
callback(newInfo);
|
|
159
|
+
});
|
|
160
|
+
return () => subscription.remove();
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 重置缓存(用于测试或强制刷新)
|
|
164
|
+
*/
|
|
165
|
+
static resetCache() {
|
|
166
|
+
this.deviceInfo = null;
|
|
167
|
+
this.systemVersion = null;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* 便捷的导出函数
|
|
172
|
+
*/
|
|
173
|
+
export const isAndroid14Plus = () => PlatformDetector.needsAndroid14Permissions();
|
|
174
|
+
export const isiOS17Plus = () => PlatformDetector.supportsiOS17Features();
|
|
175
|
+
export const isTablet = () => PlatformDetector.getDeviceInfo().isTablet;
|
|
176
|
+
export const isFoldable = () => PlatformDetector.getDeviceInfo().isFoldable;
|
|
177
|
+
export const isIPad = () => PlatformDetector.isIPad();
|
|
178
|
+
//# sourceMappingURL=PlatformDetector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformDetector.js","sourceRoot":"","sources":["../../../../src/map/utils/PlatformDetector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAN,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,+BAAiB,CAAA;IACjB,mCAAqB,CAAA;IACrB,iCAAmB,CAAA;AACrB,CAAC,EALW,UAAU,KAAV,UAAU,QAKrB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,8BAAiB,CAAA;IACjB,kCAAqB,CAAA;IACrB,wCAA2B,CAAA;IAC3B,gCAAmB,CAAA;AACrB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;AA6BD;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAC,UAAU,GAAsB,IAAI,CAAC;IAC5C,MAAM,CAAC,aAAa,GAAyB,IAAI,CAAC;IAE1D;;OAEG;IACH,MAAM,CAAC,gBAAgB;QACrB,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC,aAAa,CAAC;QAC5B,CAAC;QAED,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;QAE1D,IAAI,CAAC,aAAa,GAAG;YACnB,QAAQ,EAAE,QAAQ,CAAC,EAAuB;YAC1C,OAAO;YACP,eAAe,EAAE,QAAQ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AQ,CAAC,OAAO,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,UAAU;QACf,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC5B,CAAC;;AAGH;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,gBAAgB,CAAC,yBAAyB,EAAE,CAAC;AAClF,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,CAAC;AAC1E,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC;AACxE,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC;AAC5E,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC","sourcesContent":["/**\n * 平台检测工具\n * 用于检测设备特性、系统版本等\n */\n\nimport { Platform, Dimensions } from 'react-native';\n\n/**\n * 设备类型\n */\nexport enum DeviceType {\n PHONE = 'phone',\n TABLET = 'tablet',\n FOLDABLE = 'foldable',\n UNKNOWN = 'unknown',\n}\n\n/**\n * 折叠状态\n */\nexport enum FoldState {\n FOLDED = 'folded',\n UNFOLDED = 'unfolded',\n HALF_FOLDED = 'half_folded',\n UNKNOWN = 'unknown',\n}\n\n/**\n * 设备信息\n */\nexport interface DeviceInfo {\n type: DeviceType;\n isTablet: boolean;\n isFoldable: boolean;\n screenSize: {\n width: number;\n height: number;\n scale: number;\n fontScale: number;\n };\n aspectRatio: number;\n isLandscape: boolean;\n}\n\n/**\n * 系统版本信息\n */\nexport interface SystemVersion {\n platform: 'ios' | 'android';\n version: number;\n isAndroid14Plus: boolean;\n isIOS17Plus: boolean;\n}\n\n/**\n * 平台检测器类\n */\nexport class PlatformDetector {\n private static deviceInfo: DeviceInfo | null = null;\n private static systemVersion: SystemVersion | null = null;\n\n /**\n * 获取系统版本信息\n */\n static getSystemVersion(): SystemVersion {\n if (this.systemVersion) {\n return this.systemVersion;\n }\n\n const version = parseInt(Platform.Version.toString(), 10);\n \n this.systemVersion = {\n platform: Platform.OS as 'ios' | 'android',\n version,\n isAndroid14Plus: Platform.OS === 'android' && version >= 34, // Android 14 = API 34\n isIOS17Plus: Platform.OS === 'ios' && version >= 17,\n };\n\n return this.systemVersion;\n }\n\n /**\n * 获取设备信息\n */\n static getDeviceInfo(): DeviceInfo {\n if (this.deviceInfo) {\n return this.deviceInfo;\n }\n\n const { width, height, scale, fontScale } = Dimensions.get('window');\n const aspectRatio = Math.max(width, height) / Math.min(width, height);\n const isLandscape = width > height;\n\n // 判断是否为平板(基于屏幕尺寸和宽高比)\n const smallerDimension = Math.min(width, height);\n const isTablet = smallerDimension >= 600 || aspectRatio < 1.6;\n\n // 检测折叠屏(基于极端宽高比)\n const isFoldable = this.detectFoldable(width, height, aspectRatio);\n\n let type: DeviceType = DeviceType.PHONE;\n if (isFoldable) {\n type = DeviceType.FOLDABLE;\n } else if (isTablet) {\n type = DeviceType.TABLET;\n }\n\n this.deviceInfo = {\n type,\n isTablet,\n isFoldable,\n screenSize: { width, height, scale, fontScale },\n aspectRatio,\n isLandscape,\n };\n\n return this.deviceInfo;\n }\n\n /**\n * 检测折叠屏设备\n */\n private static detectFoldable(width: number, height: number, aspectRatio: number): boolean {\n // 常见折叠屏特征:\n // 1. 展开时宽高比接近正方形或较小(1.2-1.6)\n // 2. 折叠时宽高比很大(>2.1)\n \n if (Platform.OS === 'android') {\n // 检查是否为极端宽高比\n if (aspectRatio > 2.1 || aspectRatio < 1.3) {\n return true;\n }\n \n // 检查是否为特定分辨率(已知折叠屏设备)\n const knownFoldableResolutions = [\n { w: 2208, h: 1768 }, // Galaxy Z Fold 展开\n { w: 2176, h: 1812 }, // Galaxy Z Fold 3/4 展开\n { w: 884, h: 2208 }, // Galaxy Z Fold 折叠\n { w: 1768, h: 2208 }, // Huawei Mate X\n ];\n\n return knownFoldableResolutions.some(\n (res) =>\n (Math.abs(width - res.w) < 50 && Math.abs(height - res.h) < 50) ||\n (Math.abs(width - res.h) < 50 && Math.abs(height - res.w) < 50)\n );\n }\n\n return false;\n }\n\n /**\n * 检测当前折叠状态(需要原生支持)\n */\n static getFoldState(): FoldState {\n const info = this.getDeviceInfo();\n if (!info.isFoldable) {\n return FoldState.UNKNOWN;\n }\n\n // 基于宽高比判断折叠状态\n if (info.aspectRatio > 2.0) {\n return FoldState.FOLDED;\n } else if (info.aspectRatio < 1.5) {\n return FoldState.UNFOLDED;\n } else {\n return FoldState.HALF_FOLDED;\n }\n }\n\n /**\n * 是否为 iPad\n */\n static isIPad(): boolean {\n if (Platform.OS !== 'ios') {\n return false;\n }\n return this.getDeviceInfo().isTablet;\n }\n\n /**\n * 是否支持多任务\n */\n static supportsMultitasking(): boolean {\n return Platform.OS === 'ios' && this.isIPad();\n }\n\n /**\n * 是否需要 Android 14+ 新权限流程\n */\n static needsAndroid14Permissions(): boolean {\n return this.getSystemVersion().isAndroid14Plus;\n }\n\n /**\n * 是否支持 iOS 17+ 新特性\n */\n static supportsiOS17Features(): boolean {\n return this.getSystemVersion().isIOS17Plus;\n }\n\n /**\n * 监听屏幕尺寸变化(折叠屏展开/折叠)\n */\n static addDimensionChangeListener(callback: (info: DeviceInfo) => void): () => void {\n const subscription = Dimensions.addEventListener('change', () => {\n // 清除缓存,重新计算\n this.deviceInfo = null;\n const newInfo = this.getDeviceInfo();\n callback(newInfo);\n });\n\n return () => subscription.remove();\n }\n\n /**\n * 重置缓存(用于测试或强制刷新)\n */\n static resetCache(): void {\n this.deviceInfo = null;\n this.systemVersion = null;\n }\n}\n\n/**\n * 便捷的导出函数\n */\nexport const isAndroid14Plus = () => PlatformDetector.needsAndroid14Permissions();\nexport const isiOS17Plus = () => PlatformDetector.supportsiOS17Features();\nexport const isTablet = () => PlatformDetector.getDeviceInfo().isTablet;\nexport const isFoldable = () => PlatformDetector.getDeviceInfo().isFoldable;\nexport const isIPad = () => PlatformDetector.isIPad();"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazyNativeViewManager.d.ts","sourceRoot":"","sources":["../../../../src/map/utils/lazyNativeViewManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG3C,wBAAgB,2BAA2B,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxF,IAAI,EAAE,MAAM,GACX,MAAM,aAAa,CAAC,KAAK,CAAC,CAS5B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { requireNativeViewManager } from 'expo-modules-core';
|
|
2
|
+
export function createLazyNativeViewManager(name) {
|
|
3
|
+
let cached = null;
|
|
4
|
+
return () => {
|
|
5
|
+
if (!cached) {
|
|
6
|
+
cached = requireNativeViewManager(name);
|
|
7
|
+
}
|
|
8
|
+
return cached;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=lazyNativeViewManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazyNativeViewManager.js","sourceRoot":"","sources":["../../../../src/map/utils/lazyNativeViewManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,MAAM,UAAU,2BAA2B,CACzC,IAAY;IAEZ,IAAI,MAAM,GAAgC,IAAI,CAAC;IAE/C,OAAO,GAAG,EAAE;QACV,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,wBAAwB,CAAQ,IAAI,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,MAAO,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { ComponentType } from 'react';\nimport { requireNativeViewManager } from 'expo-modules-core';\n\nexport function createLazyNativeViewManager<Props extends object = Record<string, unknown>>(\n name: string\n): () => ComponentType<Props> {\n let cached: ComponentType<Props> | null = null;\n\n return () => {\n if (!cached) {\n cached = requireNativeViewManager<Props>(name);\n }\n return cached!;\n };\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BuildAnchorWaypointsOptions, NaviPoint, WebPlannedRoute } from './types';
|
|
2
|
+
export declare function parsePolyline(polyline?: string): NaviPoint[];
|
|
3
|
+
export declare function dedupeAdjacentPoints(points: NaviPoint[]): NaviPoint[];
|
|
4
|
+
export declare function haversineDistance(pointA: NaviPoint, pointB: NaviPoint): number;
|
|
5
|
+
export declare function distanceBetweenCoordinatesSafe(pointA: NaviPoint, pointB: NaviPoint): number;
|
|
6
|
+
export declare function calculatePathLengthSafe(points: NaviPoint[]): number;
|
|
7
|
+
export declare function simplifyPolylineSafe(points: NaviPoint[], tolerance: number): NaviPoint[];
|
|
8
|
+
export declare function getDistanceToPathSafe(path: NaviPoint[], target: NaviPoint): number;
|
|
9
|
+
export declare function samplePolyline(points: NaviPoint[], targetSamples?: number): NaviPoint[];
|
|
10
|
+
export declare function selectEvenlySpacedPoints(points: NaviPoint[], count: number): NaviPoint[];
|
|
11
|
+
export declare function normalizeWebRoutePolyline(webRoute: WebPlannedRoute): NaviPoint[];
|
|
12
|
+
export declare function buildAnchorWaypointsFromWebRoute(options: BuildAnchorWaypointsOptions): NaviPoint[];
|
|
13
|
+
//# sourceMappingURL=route-geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-geometry.d.ts","sourceRoot":"","sources":["../../src/route-geometry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,2BAA2B,EAC3B,SAAS,EACT,eAAe,EAChB,MAAM,SAAS,CAAC;AAGjB,wBAAgB,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,CAqB5D;AAGD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAYrE;AAGD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM,CAa9E;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM,CAM3F;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAUnE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,CAWxF;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM,CAkBlF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,aAAa,SAAK,GAAG,SAAS,EAAE,CAiBnF;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,CAUxF;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,EAAE,CAUhF;AAED,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,2BAA2B,GACnC,SAAS,EAAE,CAwCb"}
|