expo-gaode-map-navigation 2.0.17 → 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 +10 -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 +13 -4
- 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/ErrorHandler.d.ts +4 -0
- package/build/map/utils/ErrorHandler.d.ts.map +1 -1
- package/build/map/utils/ErrorHandler.js +8 -0
- package/build/map/utils/ErrorHandler.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/cpp/ClusterEngine.cpp +4 -14
- package/ios/map/cpp/ClusterEngine.hpp +1 -12
- package/ios/map/cpp/ClusterTypes.hpp +18 -0
- package/ios/map/cpp/ColorParser.cpp +22 -3
- package/ios/map/cpp/GeometryEngine.cpp +1 -1
- package/ios/map/cpp/QuadTree.hpp +1 -1
- package/ios/map/managers/UIManager.swift +3 -0
- package/package.json +16 -8
- package/plugin/build/withGaodeMap.js +19 -14
- package/shared/cpp/ClusterEngine.cpp +4 -14
- package/shared/cpp/ClusterEngine.hpp +1 -12
- package/shared/cpp/ClusterTypes.hpp +18 -0
- package/shared/cpp/ColorParser.cpp +22 -3
- package/shared/cpp/GeometryEngine.cpp +1 -1
- package/shared/cpp/QuadTree.hpp +1 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { DriveStrategy } from './types';
|
|
2
|
+
import { parsePolyline } from './route-geometry';
|
|
3
|
+
async function loadWebApiFallback(feature) {
|
|
4
|
+
try {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
6
|
+
const webApi = require('expo-gaode-map-web-api');
|
|
7
|
+
if (typeof webApi?.GaodeWebAPI !== 'function') {
|
|
8
|
+
throw new Error('expo-gaode-map-web-api 未导出 GaodeWebAPI');
|
|
9
|
+
}
|
|
10
|
+
return webApi;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
throw new Error(`${feature}依赖 expo-gaode-map-web-api。请安装该包,并在 ExpoGaodeMapModule.initSDK 中提供 webKey。`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function normalizeAvoidPolygons(polygons) {
|
|
17
|
+
if (!polygons?.length) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
const normalized = polygons
|
|
21
|
+
.map((polygon) => polygon
|
|
22
|
+
.map((point) => `${point.longitude},${point.latitude}`)
|
|
23
|
+
.join(';'))
|
|
24
|
+
.filter(Boolean)
|
|
25
|
+
.join('|');
|
|
26
|
+
return normalized || undefined;
|
|
27
|
+
}
|
|
28
|
+
function normalizeDrivingStrategy(strategy) {
|
|
29
|
+
// 导航 SDK 与 Web API 的策略枚举不完全一致。
|
|
30
|
+
// 这里做“尽量等价”的映射,主要用于带规避参数时的路线预览。
|
|
31
|
+
switch (strategy) {
|
|
32
|
+
case DriveStrategy.FASTEST:
|
|
33
|
+
return 38;
|
|
34
|
+
case DriveStrategy.FEE_FIRST:
|
|
35
|
+
return 1;
|
|
36
|
+
case DriveStrategy.SHORTEST:
|
|
37
|
+
return 2;
|
|
38
|
+
case DriveStrategy.NO_EXPRESSWAYS:
|
|
39
|
+
return 37;
|
|
40
|
+
case DriveStrategy.AVOID_CONGESTION:
|
|
41
|
+
return 33;
|
|
42
|
+
case DriveStrategy.NO_HIGHWAY:
|
|
43
|
+
return 35;
|
|
44
|
+
case DriveStrategy.NO_HIGHWAY_AVOID_CONGESTION:
|
|
45
|
+
return 40;
|
|
46
|
+
case DriveStrategy.AVOID_COST_CONGESTION:
|
|
47
|
+
case DriveStrategy.AVOID_CONGESTION_COST:
|
|
48
|
+
return 41;
|
|
49
|
+
case DriveStrategy.NO_HIGHWAY_AVOID_COST_CONGESTION:
|
|
50
|
+
return 43;
|
|
51
|
+
default:
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function normalizeDrivingRouteResult(options, result) {
|
|
56
|
+
// 把 Web API 的原始字段翻译成导航包已经对外稳定的 RouteResult 结构。
|
|
57
|
+
// 这样上层代码不需要知道 Web API 的字段名,也不用为 fallback 单独写分支。
|
|
58
|
+
const paths = result?.route?.paths ?? [];
|
|
59
|
+
const routes = paths.map((path, index) => {
|
|
60
|
+
const segments = (path?.steps ?? []).map((step) => ({
|
|
61
|
+
instruction: step?.instruction ?? '',
|
|
62
|
+
orientation: step?.orientation,
|
|
63
|
+
road: step?.road_name,
|
|
64
|
+
distance: Number(step?.step_distance ?? 0),
|
|
65
|
+
duration: Number(step?.cost?.duration ?? 0),
|
|
66
|
+
polyline: parsePolyline(step?.polyline),
|
|
67
|
+
assistantAction: step?.assistant_action,
|
|
68
|
+
tollDistance: step?.cost?.toll_distance ? Number(step.cost.toll_distance) : undefined,
|
|
69
|
+
tollCost: step?.cost?.tolls ? Number(step.cost.tolls) : undefined,
|
|
70
|
+
}));
|
|
71
|
+
const restrictionCode = path?.restriction != null ? Number(path.restriction) : undefined;
|
|
72
|
+
return {
|
|
73
|
+
id: index,
|
|
74
|
+
start: options.from,
|
|
75
|
+
end: options.to,
|
|
76
|
+
distance: Number(path?.distance ?? 0),
|
|
77
|
+
duration: Number(path?.cost?.duration ?? path?.duration ?? 0),
|
|
78
|
+
segments,
|
|
79
|
+
polyline: segments.flatMap((segment) => segment.polyline),
|
|
80
|
+
tollDistance: path?.cost?.toll_distance ? Number(path.cost.toll_distance) : undefined,
|
|
81
|
+
tollCost: path?.cost?.tolls ? Number(path.cost.tolls) : undefined,
|
|
82
|
+
trafficLightCount: path?.cost?.traffic_lights ? Number(path.cost.traffic_lights) : undefined,
|
|
83
|
+
restrictionCode,
|
|
84
|
+
restrictionInfo: restrictionCode === 0
|
|
85
|
+
? '限行已规避或未限行'
|
|
86
|
+
: restrictionCode === 1
|
|
87
|
+
? '限行无法规避'
|
|
88
|
+
: undefined,
|
|
89
|
+
strategy: options.strategy,
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
count: Number(result?.count ?? routes.length),
|
|
94
|
+
mainPathIndex: 0,
|
|
95
|
+
routeIds: routes.map((route) => route.id),
|
|
96
|
+
routes,
|
|
97
|
+
taxiCost: result?.route?.taxi_cost ? Number(result.route.taxi_cost) : undefined,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export function shouldUseAvoidPreviewFallback(options) {
|
|
101
|
+
// 只有出现“规避道路 / 规避区域”时才需要走 Web API 预览。
|
|
102
|
+
// 普通驾车算路仍然优先走原生能力。
|
|
103
|
+
return Boolean(options.avoidRoad?.trim() || options.avoidPolygons?.length);
|
|
104
|
+
}
|
|
105
|
+
export async function calculateDriveRouteWithAvoidPreview(options) {
|
|
106
|
+
// Web API 只负责“预览规避后的路线”,不是替代原生导航 SDK。
|
|
107
|
+
// 失败时让调用方回退到原生实现,避免把可用路径规划直接变成报错。
|
|
108
|
+
const { GaodeWebAPI } = await loadWebApiFallback('规避路线预览');
|
|
109
|
+
const api = new GaodeWebAPI();
|
|
110
|
+
const result = await api.route.driving(`${options.from.longitude},${options.from.latitude}`, `${options.to.longitude},${options.to.latitude}`, {
|
|
111
|
+
strategy: normalizeDrivingStrategy(options.strategy),
|
|
112
|
+
waypoints: options.waypoints?.map((point) => `${point.longitude},${point.latitude}`),
|
|
113
|
+
avoidpolygons: normalizeAvoidPolygons(options.avoidPolygons),
|
|
114
|
+
avoidroad: options.avoidRoad?.trim() || undefined,
|
|
115
|
+
plate: options.carNumber,
|
|
116
|
+
show_fields: 'cost,navi,polyline',
|
|
117
|
+
});
|
|
118
|
+
return normalizeDrivingRouteResult(options, result);
|
|
119
|
+
}
|
|
120
|
+
function normalizeTransitRouteResult(options, result) {
|
|
121
|
+
// 导航包内部仍保持独立实现;
|
|
122
|
+
// 这里只是在“公交无法由导航 SDK 直算”时,把 Web API 结果映射成现有 RouteResult 形状。
|
|
123
|
+
const routes = (result?.route?.transits ?? []).map((transit, index) => {
|
|
124
|
+
const polyline = (transit?.segments ?? []).flatMap((segment) => [
|
|
125
|
+
...(segment.walking?.steps?.flatMap((step) => parsePolyline(step.polyline)) ?? []),
|
|
126
|
+
...(segment.bus?.buslines?.flatMap((line) => parsePolyline(line.polyline)) ?? []),
|
|
127
|
+
...(segment.railway?.buslines?.flatMap((line) => parsePolyline(line.polyline)) ?? []),
|
|
128
|
+
]);
|
|
129
|
+
return {
|
|
130
|
+
id: index,
|
|
131
|
+
start: options.from,
|
|
132
|
+
end: options.to,
|
|
133
|
+
distance: Number(transit?.distance ?? 0),
|
|
134
|
+
duration: Number(transit?.cost?.duration ?? 0),
|
|
135
|
+
segments: [],
|
|
136
|
+
polyline,
|
|
137
|
+
tollDistance: 0,
|
|
138
|
+
tollCost: Number(transit?.cost?.transit_fee ?? 0),
|
|
139
|
+
strategy: options.strategy,
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
count: routes.length,
|
|
144
|
+
mainPathIndex: 0,
|
|
145
|
+
routes,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
export async function calculateTransitRouteWithWebApi(options) {
|
|
149
|
+
// 公交换乘在当前 SDK 能力下统一回退到 Web API,再映射成同一份路线结构。
|
|
150
|
+
// 运行时按需加载,避免把 navigation 包和 web-api 包在构建期强绑定。
|
|
151
|
+
const { GaodeWebAPI, TransitStrategy } = await loadWebApiFallback('公交路径规划');
|
|
152
|
+
const api = new GaodeWebAPI();
|
|
153
|
+
const result = await api.route.transit(`${options.from.longitude},${options.from.latitude}`, `${options.to.longitude},${options.to.latitude}`, options.city1, options.city2, {
|
|
154
|
+
strategy: options.strategy ?? TransitStrategy.RECOMMENDED,
|
|
155
|
+
AlternativeRoute: options.alternativeRoute,
|
|
156
|
+
show_fields: 'cost,polyline',
|
|
157
|
+
});
|
|
158
|
+
return normalizeTransitRouteResult(options, result);
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=web-api-fallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-api-fallback.js","sourceRoot":"","sources":["../../src/web-api-fallback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,KAAK,UAAU,kBAAkB,CAAC,OAA4B;IAC5D,IAAI,CAAC;QACH,8DAA8D;QAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;Q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,QAAQ,IAAI,CAAC,CAAC;YAC9C,QAAQ,EAAE,EAAE;YACZ,QAAQ;YACR,YAAY,EAAE,CAAC;YACf,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,WAAW,IAAI,CAAC,CAAC;YACjD,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC3B,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM;QACpB,aAAa,EAAE,CAAC;QAChB,MAAM;KACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,OAA4B;IAE5B,4CAA4C;IAC5C,8CAA8C;IAC9C,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,MAAM,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC5E,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;IAC9B,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,OAAO,CACpC,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EACpD,GAAG,OAAO,CAAC,EAAE,CAAC,SAAS,IAAI,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,EAChD,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,KAAK,EACb;QACE,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAC,WAAW;QACzD,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,WAAW,EAAE,eAAe;KAC7B,CACF,CAAC;IAEF,OAAO,2BAA2B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import { DriveStrategy } from './types';\nimport type { DriveRouteOptions, DriveRouteResult, RouteResult, TransitRouteOptions } from './types';\nimport { parsePolyline } from './route-geometry';\n\nasync function loadWebApiFallback(feature: '公交路径规划' | '规避路线预览') {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const webApi = require('expo-gaode-map-web-api');\n if (typeof webApi?.GaodeWebAPI !== 'function') {\n throw new Error('expo-gaode-map-web-api 未导出 GaodeWebAPI');\n }\n return webApi;\n } catch {\n throw new Error(\n `${feature}依赖 expo-gaode-map-web-api。请安装该包,并在 ExpoGaodeMapModule.initSDK 中提供 webKey。`\n );\n }\n}\n\nfunction normalizeAvoidPolygons(polygons?: DriveRouteOptions['avoidPolygons']): string | undefined {\n if (!polygons?.length) {\n return undefined;\n }\n\n const normalized = polygons\n .map((polygon) =>\n polygon\n .map((point) => `${point.longitude},${point.latitude}`)\n .join(';')\n )\n .filter(Boolean)\n .join('|');\n\n return normalized || undefined;\n}\n\nfunction normalizeDrivingStrategy(\n strategy?: DriveStrategy\n): number | undefined {\n // 导航 SDK 与 Web API 的策略枚举不完全一致。\n // 这里做“尽量等价”的映射,主要用于带规避参数时的路线预览。\n switch (strategy) {\n case DriveStrategy.FASTEST:\n return 38;\n case DriveStrategy.FEE_FIRST:\n return 1;\n case DriveStrategy.SHORTEST:\n return 2;\n case DriveStrategy.NO_EXPRESSWAYS:\n return 37;\n case DriveStrategy.AVOID_CONGESTION:\n return 33;\n case DriveStrategy.NO_HIGHWAY:\n return 35;\n case DriveStrategy.NO_HIGHWAY_AVOID_CONGESTION:\n return 40;\n case DriveStrategy.AVOID_COST_CONGESTION:\n case DriveStrategy.AVOID_CONGESTION_COST:\n return 41;\n case DriveStrategy.NO_HIGHWAY_AVOID_COST_CONGESTION:\n return 43;\n default:\n return undefined;\n }\n}\n\nfunction normalizeDrivingRouteResult(\n options: DriveRouteOptions,\n result: any\n): DriveRouteResult {\n // 把 Web API 的原始字段翻译成导航包已经对外稳定的 RouteResult 结构。\n // 这样上层代码不需要知道 Web API 的字段名,也不用为 fallback 单独写分支。\n const paths = result?.route?.paths ?? [];\n const routes = paths.map((path: any, index: number) => {\n const segments = (path?.steps ?? []).map((step: any) => ({\n instruction: step?.instruction ?? '',\n orientation: step?.orientation,\n road: step?.road_name,\n distance: Number(step?.step_distance ?? 0),\n duration: Number(step?.cost?.duration ?? 0),\n polyline: parsePolyline(step?.polyline),\n assistantAction: step?.assistant_action,\n tollDistance: step?.cost?.toll_distance ? Number(step.cost.toll_distance) : undefined,\n tollCost: step?.cost?.tolls ? Number(step.cost.tolls) : undefined,\n }));\n\n const restrictionCode = path?.restriction != null ? Number(path.restriction) : undefined;\n\n return {\n id: index,\n start: options.from,\n end: options.to,\n distance: Number(path?.distance ?? 0),\n duration: Number(path?.cost?.duration ?? path?.duration ?? 0),\n segments,\n polyline: segments.flatMap((segment: { polyline: any[] }) => segment.polyline),\n tollDistance: path?.cost?.toll_distance ? Number(path.cost.toll_distance) : undefined,\n tollCost: path?.cost?.tolls ? Number(path.cost.tolls) : undefined,\n trafficLightCount: path?.cost?.traffic_lights ? Number(path.cost.traffic_lights) : undefined,\n restrictionCode,\n restrictionInfo:\n restrictionCode === 0\n ? '限行已规避或未限行'\n : restrictionCode === 1\n ? '限行无法规避'\n : undefined,\n strategy: options.strategy,\n };\n });\n\n return {\n count: Number(result?.count ?? routes.length),\n mainPathIndex: 0,\n routeIds: routes.map((route: RouteResult) => route.id),\n routes,\n taxiCost: result?.route?.taxi_cost ? Number(result.route.taxi_cost) : undefined,\n };\n}\n\nexport function shouldUseAvoidPreviewFallback(options: DriveRouteOptions): boolean {\n // 只有出现“规避道路 / 规避区域”时才需要走 Web API 预览。\n // 普通驾车算路仍然优先走原生能力。\n return Boolean(options.avoidRoad?.trim() || options.avoidPolygons?.length);\n}\n\nexport async function calculateDriveRouteWithAvoidPreview(\n options: DriveRouteOptions\n): Promise<DriveRouteResult> {\n // Web API 只负责“预览规避后的路线”,不是替代原生导航 SDK。\n // 失败时让调用方回退到原生实现,避免把可用路径规划直接变成报错。\n const { GaodeWebAPI } = await loadWebApiFallback('规避路线预览');\n const api = new GaodeWebAPI();\n const result = await api.route.driving(\n `${options.from.longitude},${options.from.latitude}`,\n `${options.to.longitude},${options.to.latitude}`,\n {\n strategy: normalizeDrivingStrategy(options.strategy),\n waypoints: options.waypoints?.map(\n (point) => `${point.longitude},${point.latitude}`\n ),\n avoidpolygons: normalizeAvoidPolygons(options.avoidPolygons),\n avoidroad: options.avoidRoad?.trim() || undefined,\n plate: options.carNumber,\n show_fields: 'cost,navi,polyline',\n }\n );\n\n return normalizeDrivingRouteResult(options, result);\n}\n\nfunction normalizeTransitRouteResult(\n options: TransitRouteOptions,\n result: any\n): DriveRouteResult {\n // 导航包内部仍保持独立实现;\n // 这里只是在“公交无法由导航 SDK 直算”时,把 Web API 结果映射成现有 RouteResult 形状。\n const routes = (result?.route?.transits ?? []).map((transit: any, index: number) => {\n const polyline = (transit?.segments ?? []).flatMap((segment: any) => [\n ...(segment.walking?.steps?.flatMap((step: any) => parsePolyline(step.polyline)) ?? []),\n ...(segment.bus?.buslines?.flatMap((line: any) => parsePolyline(line.polyline)) ?? []),\n ...(segment.railway?.buslines?.flatMap((line: any) => parsePolyline(line.polyline)) ?? []),\n ]);\n\n return {\n id: index,\n start: options.from,\n end: options.to,\n distance: Number(transit?.distance ?? 0),\n duration: Number(transit?.cost?.duration ?? 0),\n segments: [],\n polyline,\n tollDistance: 0,\n tollCost: Number(transit?.cost?.transit_fee ?? 0),\n strategy: options.strategy,\n };\n });\n\n return {\n count: routes.length,\n mainPathIndex: 0,\n routes,\n };\n}\n\nexport async function calculateTransitRouteWithWebApi(\n options: TransitRouteOptions\n): Promise<DriveRouteResult> {\n // 公交换乘在当前 SDK 能力下统一回退到 Web API,再映射成同一份路线结构。\n // 运行时按需加载,避免把 navigation 包和 web-api 包在构建期强绑定。\n const { GaodeWebAPI, TransitStrategy } = await loadWebApiFallback('公交路径规划');\n const api = new GaodeWebAPI();\n const result = await api.route.transit(\n `${options.from.longitude},${options.from.latitude}`,\n `${options.to.longitude},${options.to.latitude}`,\n options.city1,\n options.city2,\n {\n strategy: options.strategy ?? TransitStrategy.RECOMMENDED,\n AlternativeRoute: options.alternativeRoute,\n show_fields: 'cost,polyline',\n }\n );\n\n return normalizeTransitRouteResult(options, result);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-route-following.d.ts","sourceRoot":"","sources":["../../src/web-route-following.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,4BAA4B,EAC5B,2BAA2B,EAI5B,MAAM,SAAS,CAAC;AAuJjB,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,2BAA2B,CAAC,CA8HtC"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import ExpoGaodeMapNavigationModule from './ExpoGaodeMapNavigationModule';
|
|
2
|
+
import { buildAnchorWaypointsFromWebRoute, calculatePathLengthSafe, dedupeAdjacentPoints, getDistanceToPathSafe, normalizeWebRoutePolyline, samplePolyline } from './route-geometry';
|
|
3
|
+
function extractRoutePolyline(route) {
|
|
4
|
+
if (Array.isArray(route.polyline) && route.polyline.length > 0) {
|
|
5
|
+
return route.polyline;
|
|
6
|
+
}
|
|
7
|
+
const segments = Array.isArray(route.segments) ? route.segments : [];
|
|
8
|
+
if (segments.length > 0) {
|
|
9
|
+
return dedupeAdjacentPoints(segments.flatMap((segment) => segment.polyline ?? []));
|
|
10
|
+
}
|
|
11
|
+
const steps = Array.isArray(route.steps) ? route.steps : [];
|
|
12
|
+
if (steps.length > 0) {
|
|
13
|
+
return dedupeAdjacentPoints(steps.flatMap((step) => step.polyline ?? []));
|
|
14
|
+
}
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
function resolveIndependentRouteId(result, route, routeIndex) {
|
|
18
|
+
if (typeof route.id === 'number') {
|
|
19
|
+
return route.id;
|
|
20
|
+
}
|
|
21
|
+
if (typeof route.routeId === 'number') {
|
|
22
|
+
return route.routeId;
|
|
23
|
+
}
|
|
24
|
+
return result.routeIds?.[routeIndex];
|
|
25
|
+
}
|
|
26
|
+
function scoreIndependentRouteAgainstWebPolyline(result, route, routeIndex, webPolyline, anchorWaypoints, thresholdMeters) {
|
|
27
|
+
// 评分思路很简单:看原生独立路线与 Web 折线有多接近,
|
|
28
|
+
// 再把平均偏差、最大偏差、漏掉的锚点一起折成一个排序分数。
|
|
29
|
+
const nativePolyline = extractRoutePolyline(route);
|
|
30
|
+
if (nativePolyline.length === 0 || webPolyline.length === 0) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const sampledNativePoints = samplePolyline(nativePolyline);
|
|
34
|
+
const pointDistances = sampledNativePoints.map((point) => getDistanceToPathSafe(webPolyline, point));
|
|
35
|
+
const averageDeviationMeters = pointDistances.reduce((total, distance) => total + distance, 0) / pointDistances.length;
|
|
36
|
+
const maxDeviationMeters = Math.max(...pointDistances);
|
|
37
|
+
const missedAnchorCount = anchorWaypoints.reduce((count, point) => (getDistanceToPathSafe(nativePolyline, point) > thresholdMeters ? count + 1 : count), 0);
|
|
38
|
+
return {
|
|
39
|
+
routeId: resolveIndependentRouteId(result, route, routeIndex),
|
|
40
|
+
routeIndex,
|
|
41
|
+
averageDeviationMeters,
|
|
42
|
+
maxDeviationMeters,
|
|
43
|
+
missedAnchorCount,
|
|
44
|
+
score: averageDeviationMeters +
|
|
45
|
+
maxDeviationMeters * 0.35 +
|
|
46
|
+
missedAnchorCount * thresholdMeters * 0.5,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function evaluateIndependentResultAgainstWebRoute(independentResult, webPolyline, anchorWaypoints, maxDeviationMeters) {
|
|
50
|
+
// 先给每条原生候选路线打分,再把最接近的一条拿出来判断是 matched / approximate / preview_only。
|
|
51
|
+
const candidateMatches = independentResult.routes
|
|
52
|
+
.map((route, routeIndex) => scoreIndependentRouteAgainstWebPolyline(independentResult, route, routeIndex, webPolyline, anchorWaypoints, maxDeviationMeters))
|
|
53
|
+
.filter((candidate) => candidate !== null)
|
|
54
|
+
.sort((routeA, routeB) => routeA.score - routeB.score);
|
|
55
|
+
const bestMatch = candidateMatches[0];
|
|
56
|
+
const selectedRoute = bestMatch
|
|
57
|
+
? independentResult.routes[bestMatch.routeIndex]
|
|
58
|
+
: undefined;
|
|
59
|
+
const nativePolyline = selectedRoute ? extractRoutePolyline(selectedRoute) : [];
|
|
60
|
+
let mode = 'preview_only';
|
|
61
|
+
let reason = '未找到足够接近 Web 规划线的原生路线';
|
|
62
|
+
if (bestMatch) {
|
|
63
|
+
if (bestMatch.averageDeviationMeters <= maxDeviationMeters / 2 &&
|
|
64
|
+
bestMatch.maxDeviationMeters <= maxDeviationMeters &&
|
|
65
|
+
bestMatch.missedAnchorCount === 0) {
|
|
66
|
+
mode = 'matched';
|
|
67
|
+
reason = '原生路线与 Web 规划线高度接近,可直接按近似结果导航';
|
|
68
|
+
}
|
|
69
|
+
else if (bestMatch.averageDeviationMeters <= maxDeviationMeters &&
|
|
70
|
+
bestMatch.maxDeviationMeters <= maxDeviationMeters * 2) {
|
|
71
|
+
mode = 'approximate';
|
|
72
|
+
reason = '原生路线与 Web 规划线接近,但仍存在可见偏差';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
candidateMatches,
|
|
77
|
+
bestMatch,
|
|
78
|
+
selectedRoute,
|
|
79
|
+
nativePolyline,
|
|
80
|
+
mode,
|
|
81
|
+
reason,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
async function runIndependentDriveRoute(options) {
|
|
85
|
+
return ExpoGaodeMapNavigationModule.independentDriveRoute(options);
|
|
86
|
+
}
|
|
87
|
+
export async function followWebPlannedRoute(options) {
|
|
88
|
+
const { from, to, webRoute, strategy, carNumber, restriction, maxDeviationMeters = 120, startNavigation = false, naviType = 0, } = options;
|
|
89
|
+
const webPolyline = normalizeWebRoutePolyline(webRoute);
|
|
90
|
+
if (webPolyline.length < 2) {
|
|
91
|
+
throw new Error('webRoute.polyline 至少需要 2 个点');
|
|
92
|
+
}
|
|
93
|
+
// 第一步:从 Web 线路提取少量锚点,让原生独立算路先尽量往这条线靠。
|
|
94
|
+
const anchorWaypoints = buildAnchorWaypointsFromWebRoute(options);
|
|
95
|
+
const anchoredIndependentResult = await runIndependentDriveRoute({
|
|
96
|
+
from,
|
|
97
|
+
to,
|
|
98
|
+
strategy,
|
|
99
|
+
carNumber,
|
|
100
|
+
restriction,
|
|
101
|
+
waypoints: anchorWaypoints,
|
|
102
|
+
});
|
|
103
|
+
let independentResult = anchoredIndependentResult;
|
|
104
|
+
let evaluation = evaluateIndependentResultAgainstWebRoute(anchoredIndependentResult, webPolyline, anchorWaypoints, maxDeviationMeters);
|
|
105
|
+
let navigationUsesAnchorWaypoints = anchorWaypoints.length > 0;
|
|
106
|
+
// 如果锚点路线已经足够接近,再尝试去掉锚点重算一次。
|
|
107
|
+
// 这样可以避免“为了贴线而被锚点拖偏”的情况。
|
|
108
|
+
if (evaluation.bestMatch && evaluation.mode !== 'preview_only' && anchorWaypoints.length > 0) {
|
|
109
|
+
try {
|
|
110
|
+
const directIndependentResult = await runIndependentDriveRoute({
|
|
111
|
+
from,
|
|
112
|
+
to,
|
|
113
|
+
strategy,
|
|
114
|
+
carNumber,
|
|
115
|
+
restriction,
|
|
116
|
+
});
|
|
117
|
+
const directEvaluation = evaluateIndependentResultAgainstWebRoute(directIndependentResult, webPolyline, [], maxDeviationMeters);
|
|
118
|
+
const anchoredBest = evaluation.bestMatch;
|
|
119
|
+
const directBest = directEvaluation.bestMatch;
|
|
120
|
+
const canSwitchToDirectNavigation = Boolean(directBest) &&
|
|
121
|
+
directEvaluation.mode !== 'preview_only' &&
|
|
122
|
+
directBest.averageDeviationMeters <= Math.max(anchoredBest.averageDeviationMeters + 45, anchoredBest.averageDeviationMeters * 1.45) &&
|
|
123
|
+
directBest.maxDeviationMeters <= Math.max(anchoredBest.maxDeviationMeters + 90, anchoredBest.maxDeviationMeters * 1.45);
|
|
124
|
+
if (canSwitchToDirectNavigation) {
|
|
125
|
+
// 直连结果更自然,就切到直连结果,并清掉刚才的锚点算路缓存。
|
|
126
|
+
ExpoGaodeMapNavigationModule.clearIndependentRoute({
|
|
127
|
+
token: anchoredIndependentResult.token,
|
|
128
|
+
}).catch(() => { });
|
|
129
|
+
independentResult = directIndependentResult;
|
|
130
|
+
evaluation = directEvaluation;
|
|
131
|
+
navigationUsesAnchorWaypoints = false;
|
|
132
|
+
evaluation.reason =
|
|
133
|
+
directEvaluation.mode === 'matched'
|
|
134
|
+
? '已切换为无途经点导航结果,且与 Web 规划线高度接近'
|
|
135
|
+
: '已切换为无途经点导航结果,但与 Web 规划线仍存在轻微偏差';
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// 直连结果不如锚点方案,就保留锚点方案作为最终导航依据。
|
|
139
|
+
ExpoGaodeMapNavigationModule.clearIndependentRoute({
|
|
140
|
+
token: directIndependentResult.token,
|
|
141
|
+
}).catch(() => { });
|
|
142
|
+
evaluation.reason = `${evaluation.reason};最终导航仍需依赖锚点途经点逼近 Web 线路`;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
evaluation.reason = `${evaluation.reason};无途经点重算失败,最终导航仍需依赖锚点途经点`;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
let navigationStarted = false;
|
|
150
|
+
if (startNavigation && evaluation.bestMatch && evaluation.mode !== 'preview_only') {
|
|
151
|
+
// 只有当评估结果足够接近时才真正启动导航,避免把偏差过大的结果直接交给导航 SDK。
|
|
152
|
+
navigationStarted = await ExpoGaodeMapNavigationModule.startNaviWithIndependentPath({
|
|
153
|
+
token: independentResult.token,
|
|
154
|
+
naviType,
|
|
155
|
+
routeId: evaluation.bestMatch.routeId,
|
|
156
|
+
routeIndex: evaluation.bestMatch.routeId == null ? evaluation.bestMatch.routeIndex : undefined,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
mode: evaluation.mode,
|
|
161
|
+
token: independentResult.token,
|
|
162
|
+
anchorWaypoints,
|
|
163
|
+
webDistance: calculatePathLengthSafe(webPolyline),
|
|
164
|
+
nativeDistance: evaluation.nativePolyline.length > 1
|
|
165
|
+
? calculatePathLengthSafe(evaluation.nativePolyline)
|
|
166
|
+
: undefined,
|
|
167
|
+
selectedRouteId: evaluation.bestMatch?.routeId,
|
|
168
|
+
selectedRouteIndex: evaluation.bestMatch?.routeIndex,
|
|
169
|
+
averageDeviationMeters: evaluation.bestMatch?.averageDeviationMeters,
|
|
170
|
+
maxDeviationMeters: evaluation.bestMatch?.maxDeviationMeters,
|
|
171
|
+
navigationStarted,
|
|
172
|
+
navigationUsesAnchorWaypoints,
|
|
173
|
+
independentResult,
|
|
174
|
+
candidateMatches: evaluation.candidateMatches,
|
|
175
|
+
reason: evaluation.reason,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=web-route-following.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-route-following.js","sourceRoot":"","sources":["../../src/web-route-following.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,gCAAgC,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAerL,SAAS,oBAAoB,CAAC,KAAgB;IAC5C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/D,OAAO,KAAK,CAAC,QAAQ,CAAC;IACxB,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IACrE,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,OAAO,oBAAoB,CACzB,QAAQ,CAAC,OAAO,CAAC,CAAC,O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,EAAE,CAAC;QAClF,4CAA4C;QAC5C,iBAAiB,GAAG,MAAM,4BAA4B,CAAC,4BAA4B,CAAC;YAClF,KAAK,EAAE,iBAAiB,CAAC,KAAK;YAC9B,QAAQ;YACR,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,OAAO;YACrC,UAAU,EACR,UAAU,CAAC,SAAS,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;SACrF,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,KAAK,EAAE,iBAAiB,CAAC,KAAK;QAC9B,eAAe;QACf,WAAW,EAAE,uBAAuB,CAAC,WAAW,CAAC;QACjD,cAAc,EACZ,UAAU,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC;YAClC,CAAC,CAAC,uBAAuB,CAAC,UAAU,CAAC,cAAc,CAAC;YACpD,CAAC,CAAC,SAAS;QACf,eAAe,EAAE,UAAU,CAAC,SAAS,EAAE,OAAO;QAC9C,kBAAkB,EAAE,UAAU,CAAC,SAAS,EAAE,UAAU;QACpD,sBAAsB,EAAE,UAAU,CAAC,SAAS,EAAE,sBAAsB;QACpE,kBAAkB,EAAE,UAAU,CAAC,SAAS,EAAE,kBAAkB;QAC5D,iBAAiB;QACjB,6BAA6B;QAC7B,iBAAiB;QACjB,gBAAgB,EAAE,UAAU,CAAC,gBAAgB;QAC7C,MAAM,EAAE,UAAU,CAAC,MAAM;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["import ExpoGaodeMapNavigationModule from './ExpoGaodeMapNavigationModule';\nimport { buildAnchorWaypointsFromWebRoute, calculatePathLengthSafe, dedupeAdjacentPoints, getDistanceToPathSafe, normalizeWebRoutePolyline, samplePolyline } from './route-geometry';\nimport type {\n FollowWebPlannedRouteCandidate,\n FollowWebPlannedRouteOptions,\n FollowWebPlannedRouteResult,\n IndependentRouteResult,\n NaviPoint,\n RouteResult,\n} from './types';\n\ntype RouteLike = RouteResult & {\n routeId?: number;\n steps?: Array<{ polyline?: NaviPoint[] }>;\n};\n\nfunction extractRoutePolyline(route: RouteLike): NaviPoint[] {\n if (Array.isArray(route.polyline) && route.polyline.length > 0) {\n return route.polyline;\n }\n\n const segments = Array.isArray(route.segments) ? route.segments : [];\n if (segments.length > 0) {\n return dedupeAdjacentPoints(\n segments.flatMap((segment) => segment.polyline ?? [])\n );\n }\n\n const steps = Array.isArray(route.steps) ? route.steps : [];\n if (steps.length > 0) {\n return dedupeAdjacentPoints(\n steps.flatMap((step) => step.polyline ?? [])\n );\n }\n\n return [];\n}\n\nfunction resolveIndependentRouteId(\n result: IndependentRouteResult,\n route: RouteLike,\n routeIndex: number\n): number | undefined {\n if (typeof route.id === 'number') {\n return route.id;\n }\n if (typeof route.routeId === 'number') {\n return route.routeId;\n }\n return result.routeIds?.[routeIndex];\n}\n\nfunction scoreIndependentRouteAgainstWebPolyline(\n result: IndependentRouteResult,\n route: RouteLike,\n routeIndex: number,\n webPolyline: NaviPoint[],\n anchorWaypoints: NaviPoint[],\n thresholdMeters: number\n): FollowWebPlannedRouteCandidate | null {\n // 评分思路很简单:看原生独立路线与 Web 折线有多接近,\n // 再把平均偏差、最大偏差、漏掉的锚点一起折成一个排序分数。\n const nativePolyline = extractRoutePolyline(route);\n if (nativePolyline.length === 0 || webPolyline.length === 0) {\n return null;\n }\n\n const sampledNativePoints = samplePolyline(nativePolyline);\n const pointDistances = sampledNativePoints.map((point) =>\n getDistanceToPathSafe(webPolyline, point)\n );\n const averageDeviationMeters =\n pointDistances.reduce((total, distance) => total + distance, 0) / pointDistances.length;\n const maxDeviationMeters = Math.max(...pointDistances);\n\n const missedAnchorCount = anchorWaypoints.reduce((count, point) => (\n getDistanceToPathSafe(nativePolyline, point) > thresholdMeters ? count + 1 : count\n ), 0);\n\n return {\n routeId: resolveIndependentRouteId(result, route, routeIndex),\n routeIndex,\n averageDeviationMeters,\n maxDeviationMeters,\n missedAnchorCount,\n score:\n averageDeviationMeters +\n maxDeviationMeters * 0.35 +\n missedAnchorCount * thresholdMeters * 0.5,\n };\n}\n\nfunction evaluateIndependentResultAgainstWebRoute(\n independentResult: IndependentRouteResult,\n webPolyline: NaviPoint[],\n anchorWaypoints: NaviPoint[],\n maxDeviationMeters: number\n) {\n // 先给每条原生候选路线打分,再把最接近的一条拿出来判断是 matched / approximate / preview_only。\n const candidateMatches = independentResult.routes\n .map((route, routeIndex) =>\n scoreIndependentRouteAgainstWebPolyline(\n independentResult,\n route as RouteLike,\n routeIndex,\n webPolyline,\n anchorWaypoints,\n maxDeviationMeters\n )\n )\n .filter((candidate): candidate is FollowWebPlannedRouteCandidate => candidate !== null)\n .sort((routeA, routeB) => routeA.score - routeB.score);\n\n const bestMatch = candidateMatches[0];\n const selectedRoute = bestMatch\n ? independentResult.routes[bestMatch.routeIndex] as RouteLike\n : undefined;\n const nativePolyline = selectedRoute ? extractRoutePolyline(selectedRoute) : [];\n\n let mode: FollowWebPlannedRouteResult['mode'] = 'preview_only';\n let reason = '未找到足够接近 Web 规划线的原生路线';\n\n if (bestMatch) {\n if (\n bestMatch.averageDeviationMeters <= maxDeviationMeters / 2 &&\n bestMatch.maxDeviationMeters <= maxDeviationMeters &&\n bestMatch.missedAnchorCount === 0\n ) {\n mode = 'matched';\n reason = '原生路线与 Web 规划线高度接近,可直接按近似结果导航';\n } else if (\n bestMatch.averageDeviationMeters <= maxDeviationMeters &&\n bestMatch.maxDeviationMeters <= maxDeviationMeters * 2\n ) {\n mode = 'approximate';\n reason = '原生路线与 Web 规划线接近,但仍存在可见偏差';\n }\n }\n\n return {\n candidateMatches,\n bestMatch,\n selectedRoute,\n nativePolyline,\n mode,\n reason,\n };\n}\n\nasync function runIndependentDriveRoute(options: {\n from: FollowWebPlannedRouteOptions['from'];\n to: FollowWebPlannedRouteOptions['to'];\n strategy?: FollowWebPlannedRouteOptions['strategy'];\n carNumber?: FollowWebPlannedRouteOptions['carNumber'];\n restriction?: FollowWebPlannedRouteOptions['restriction'];\n waypoints?: NaviPoint[];\n}): Promise<IndependentRouteResult> {\n return ExpoGaodeMapNavigationModule.independentDriveRoute(options);\n}\n\nexport async function followWebPlannedRoute(\n options: FollowWebPlannedRouteOptions\n): Promise<FollowWebPlannedRouteResult> {\n const {\n from,\n to,\n webRoute,\n strategy,\n carNumber,\n restriction,\n maxDeviationMeters = 120,\n startNavigation = false,\n naviType = 0,\n } = options;\n\n const webPolyline = normalizeWebRoutePolyline(webRoute);\n if (webPolyline.length < 2) {\n throw new Error('webRoute.polyline 至少需要 2 个点');\n }\n\n // 第一步:从 Web 线路提取少量锚点,让原生独立算路先尽量往这条线靠。\n const anchorWaypoints = buildAnchorWaypointsFromWebRoute(options);\n const anchoredIndependentResult = await runIndependentDriveRoute({\n from,\n to,\n strategy,\n carNumber,\n restriction,\n waypoints: anchorWaypoints,\n });\n\n let independentResult = anchoredIndependentResult;\n let evaluation = evaluateIndependentResultAgainstWebRoute(\n anchoredIndependentResult,\n webPolyline,\n anchorWaypoints,\n maxDeviationMeters\n );\n let navigationUsesAnchorWaypoints = anchorWaypoints.length > 0;\n\n // 如果锚点路线已经足够接近,再尝试去掉锚点重算一次。\n // 这样可以避免“为了贴线而被锚点拖偏”的情况。\n if (evaluation.bestMatch && evaluation.mode !== 'preview_only' && anchorWaypoints.length > 0) {\n try {\n const directIndependentResult = await runIndependentDriveRoute({\n from,\n to,\n strategy,\n carNumber,\n restriction,\n });\n\n const directEvaluation = evaluateIndependentResultAgainstWebRoute(\n directIndependentResult,\n webPolyline,\n [],\n maxDeviationMeters\n );\n const anchoredBest = evaluation.bestMatch;\n const directBest = directEvaluation.bestMatch;\n\n const canSwitchToDirectNavigation =\n Boolean(directBest) &&\n directEvaluation.mode !== 'preview_only' &&\n directBest!.averageDeviationMeters <= Math.max(\n anchoredBest.averageDeviationMeters + 45,\n anchoredBest.averageDeviationMeters * 1.45\n ) &&\n directBest!.maxDeviationMeters <= Math.max(\n anchoredBest.maxDeviationMeters + 90,\n anchoredBest.maxDeviationMeters * 1.45\n );\n\n if (canSwitchToDirectNavigation) {\n // 直连结果更自然,就切到直连结果,并清掉刚才的锚点算路缓存。\n ExpoGaodeMapNavigationModule.clearIndependentRoute({\n token: anchoredIndependentResult.token,\n }).catch(() => {});\n independentResult = directIndependentResult;\n evaluation = directEvaluation;\n navigationUsesAnchorWaypoints = false;\n evaluation.reason =\n directEvaluation.mode === 'matched'\n ? '已切换为无途经点导航结果,且与 Web 规划线高度接近'\n : '已切换为无途经点导航结果,但与 Web 规划线仍存在轻微偏差';\n } else {\n // 直连结果不如锚点方案,就保留锚点方案作为最终导航依据。\n ExpoGaodeMapNavigationModule.clearIndependentRoute({\n token: directIndependentResult.token,\n }).catch(() => {});\n evaluation.reason = `${evaluation.reason};最终导航仍需依赖锚点途经点逼近 Web 线路`;\n }\n } catch {\n evaluation.reason = `${evaluation.reason};无途经点重算失败,最终导航仍需依赖锚点途经点`;\n }\n }\n\n let navigationStarted = false;\n if (startNavigation && evaluation.bestMatch && evaluation.mode !== 'preview_only') {\n // 只有当评估结果足够接近时才真正启动导航,避免把偏差过大的结果直接交给导航 SDK。\n navigationStarted = await ExpoGaodeMapNavigationModule.startNaviWithIndependentPath({\n token: independentResult.token,\n naviType,\n routeId: evaluation.bestMatch.routeId,\n routeIndex:\n evaluation.bestMatch.routeId == null ? evaluation.bestMatch.routeIndex : undefined,\n });\n }\n\n return {\n mode: evaluation.mode,\n token: independentResult.token,\n anchorWaypoints,\n webDistance: calculatePathLengthSafe(webPolyline),\n nativeDistance:\n evaluation.nativePolyline.length > 1\n ? calculatePathLengthSafe(evaluation.nativePolyline)\n : undefined,\n selectedRouteId: evaluation.bestMatch?.routeId,\n selectedRouteIndex: evaluation.bestMatch?.routeIndex,\n averageDeviationMeters: evaluation.bestMatch?.averageDeviationMeters,\n maxDeviationMeters: evaluation.bestMatch?.maxDeviationMeters,\n navigationStarted,\n navigationUsesAnchorWaypoints,\n independentResult,\n candidateMatches: evaluation.candidateMatches,\n reason: evaluation.reason,\n };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NativeModule } from 'expo';
|
|
2
|
-
import { DriveRouteOptions, DriveRouteResult, EBikeRouteOptions, OfficialNaviPageOptions, RideRouteOptions, RouteResult, TruckRouteOptions, WalkRouteOptions } from './route.types';
|
|
3
|
-
import { MotorcycleRouteOptions, IndependentDriveRouteOptions, IndependentTruckRouteOptions, IndependentWalkRouteOptions, IndependentRideRouteOptions, IndependentMotorcycleRouteOptions, IndependentRouteResult, SelectIndependentRouteOptions, StartNaviWithIndependentPathOptions, ClearIndependentRouteOptions } from './independent.types';
|
|
2
|
+
import type { DriveRouteOptions, DriveRouteResult, EBikeRouteOptions, OfficialNaviPageOptions, RideRouteOptions, RouteResult, TruckRouteOptions, WalkRouteOptions } from './route.types';
|
|
3
|
+
import type { MotorcycleRouteOptions, IndependentDriveRouteOptions, IndependentTruckRouteOptions, IndependentWalkRouteOptions, IndependentRideRouteOptions, IndependentMotorcycleRouteOptions, IndependentRouteResult, SelectIndependentRouteOptions, StartNaviWithIndependentPathOptions, ClearIndependentRouteOptions } from './independent.types';
|
|
4
4
|
export interface ExpoGaodeMapNavigationModule extends NativeModule {
|
|
5
5
|
/**
|
|
6
6
|
* 初始化导航模块
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-module.types.d.ts","sourceRoot":"","sources":["../../src/types/native-module.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,WAAW,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"native-module.types.d.ts","sourceRoot":"","sources":["../../src/types/native-module.types.ts"],"names":[],"mappings":"AAAA,OAAO,K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AqB,EAAE,CAAC,OAAO,EAAE,4BAA4B,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAA;IACjG;;OAEG;IACH,oBAAoB,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAA;IAC/F;;OAEG;IACH,oBAAoB,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAA;IAC/F;;OAEG;IACH,0BAA0B,EAAE,CAAC,OAAO,EAAE,iCAAiC,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAA;IAE3G;;OAEG;IACH,sBAAsB,EAAE,CAAC,OAAO,EAAE,6BAA6B,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IACpF;;OAEG;IACH,4BAA4B,EAAE,CAAC,OAAO,EAAE,mCAAmC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAChG;;OAEG;IACH,oBAAoB,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAC5E;;OAEG;IACH,qBAAqB,EAAE,CAAC,OAAO,EAAE,4BAA4B,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CACrF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-module.types.js","sourceRoot":"","sources":["../../src/types/native-module.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { NativeModule } from 'expo';\nimport { DriveRouteOptions, DriveRouteResult, EBikeRouteOptions, OfficialNaviPageOptions, RideRouteOptions, RouteResult, TruckRouteOptions, WalkRouteOptions } from './route.types';\nimport {
|
|
1
|
+
{"version":3,"file":"native-module.types.js","sourceRoot":"","sources":["../../src/types/native-module.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { NativeModule } from 'expo';\nimport type { DriveRouteOptions, DriveRouteResult, EBikeRouteOptions, OfficialNaviPageOptions, RideRouteOptions, RouteResult, TruckRouteOptions, WalkRouteOptions } from './route.types';\nimport type {\n MotorcycleRouteOptions, \n IndependentDriveRouteOptions, \n IndependentTruckRouteOptions, \n IndependentWalkRouteOptions, \n IndependentRideRouteOptions,\n IndependentMotorcycleRouteOptions,\n IndependentRouteResult,\n SelectIndependentRouteOptions,\n StartNaviWithIndependentPathOptions,\n ClearIndependentRouteOptions\n} from './independent.types';\n\nexport interface ExpoGaodeMapNavigationModule extends NativeModule {\n /**\n * 初始化导航模块\n */\n initNavigation: () => void\n /**\n * 销毁所有路径规划器\n */\n destroyAllCalculators: () => void\n /**\n * 驾车路径规划\n */\n calculateDriveRoute: (options: DriveRouteOptions) => Promise<DriveRouteResult>\n /**\n * 步行路径规划\n */\n calculateWalkRoute: (options: WalkRouteOptions) => Promise<RouteResult>\n /**\n * 骑行路径规划\n */\n calculateRideRoute: (options: RideRouteOptions) => Promise<RouteResult>\n /**\n * 骑行电动车路径规划\n */\n calculateEBikeRoute: (options: EBikeRouteOptions) => Promise<RouteResult>\n /**\n * 货车路径规划\n */\n calculateTruckRoute: (options: TruckRouteOptions) => Promise<DriveRouteResult>\n /**\n * 摩托车路径规划(车类型为 11,支持传入排量)\n */ \n calculateMotorcycleRoute: (options: MotorcycleRouteOptions) => Promise<DriveRouteResult>\n \n /**\n * 独立路径规划(不会影响当前导航;适合路线预览/行前选路)\n */\n independentDriveRoute: (options: IndependentDriveRouteOptions) => Promise<IndependentRouteResult>\n /**\n * 独立货车路径规划(不会影响当前导航;适合路线预览/行前选路)\n */\n independentTruckRoute: (options: IndependentTruckRouteOptions) => Promise<IndependentRouteResult>\n /**\n * 独立步行路径规划(不会影响当前导航;适合路线预览/行前选路)\n */\n independentWalkRoute: (options: IndependentWalkRouteOptions) => Promise<IndependentRouteResult>\n /**\n * 独立骑行路径规划(不会影响当前导航;适合路线预览/行前选路)\n */\n independentRideRoute: (options: IndependentRideRouteOptions) => Promise<IndependentRouteResult>\n /**\n * 独立摩托车路径规划(不会影响当前导航;适合路线预览/行前选路)\n */ \n independentMotorcycleRoute: (options: IndependentMotorcycleRouteOptions) => Promise<IndependentRouteResult>\n \n /**\n * 选择独立路径(会影响当前导航)\n */\n selectIndependentRoute: (options: SelectIndependentRouteOptions) => Promise<boolean>\n /**\n * 启动独立路径导航(会影响当前导航)\n */\n startNaviWithIndependentPath: (options: StartNaviWithIndependentPathOptions) => Promise<boolean>\n /**\n * 打开官方导航页(Android: AmapNaviPage.showRouteActivity,)\n */\n openOfficialNaviPage: (options: OfficialNaviPageOptions) => Promise<boolean>\n /**\n * 清除独立路径(会影响当前导航)\n */\n clearIndependentRoute: (options: ClearIndependentRouteOptions) => Promise<boolean>\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ViewProps, NativeSyntheticEvent, ImageSourcePropType } from "react-native";
|
|
1
|
+
import type { ViewProps, NativeSyntheticEvent, ImageSourcePropType } from "react-native";
|
|
2
2
|
export type NaviColorValue = string | number;
|
|
3
3
|
export type NaviImageSource = string | ImageSourcePropType;
|
|
4
4
|
export type NaviMapViewModeType = 0 | 1 | 2 | 3;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naviview.types.d.ts","sourceRoot":"","sources":["../../src/types/naviview.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"naviview.types.d.ts","sourceRoot":"","sources":["../../src/types/naviview.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEzF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAC7C,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,mBAAmB,CAAC;AAC3D,MAAM,MAAM,mBAAmB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEhD,MAAM,WAAW,QAAQ;IACvB,CAAC,CAAC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C,KAAK,IAAI,CAAC;IAE5E;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,qBAAqB,CAAC,KAAK,IAAI,CAAC;IAElF;;;OAGG;IACH,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC;IAEtF;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAE5E;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,wBAAwB,CAAC,KAAK,IAAI,CAAC;CAC3F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naviview.types.js","sourceRoot":"","sources":["../../src/types/naviview.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ViewProps, NativeSyntheticEvent, ImageSourcePropType } from \"react-native\";\n\nexport type NaviColorValue = string | number;\nexport type NaviImageSource = string | ImageSourcePropType;\nexport type NaviMapViewModeType = 0 | 1 | 2 | 3;\n\nexport interface NaviRect {\n x?: number;\n y?: number;\n width?: number;\n height?: number;\n}\n\nexport interface NaviTrafficBarColors {\n unknown?: NaviColorValue;\n smooth?: NaviColorValue;\n fineOpen?: NaviColorValue;\n slow?: NaviColorValue;\n jam?: NaviColorValue;\n seriousJam?: NaviColorValue;\n defaultRoad?: NaviColorValue;\n}\n\n// 导航信息更新事件\nexport interface NaviInfoUpdateEvent {\n naviMode?: number;\n pathRetainDistance: number;\n pathRetainTime: number;\n curStepRetainDistance?: number;\n curStepRetainTime?: number;\n currentRoadName: string;\n nextRoadName: string;\n currentSpeed?: number;\n iconType?: number;\n nextIconType?: number;\n /** 当前导航动作的原生转向图标 URI,优先级高于 iconType */\n turnIconImage?: string;\n /** 下一导航动作的原生转向图标 URI;当前主要由 iOS 驾车场景提供,Android 与 iOS 骑步行场景通常为空 */\n nextTurnIconImage?: string;\n iconDirection?: number;\n currentSegmentIndex?: number;\n currentLinkIndex?: number;\n currentPointIndex?: number;\n routeRemainTrafficLightCount?: number;\n driveDistance?: number;\n driveTime?: number;\n}\n\nexport interface NaviVisualStateEvent {\n /** 是否正在显示实景路口放大图 */\n isCrossVisible: boolean;\n /** 是否正在显示 3D 路口模型;当前仅 Android 支持,iOS 恒为 false */\n isModeCrossVisible: boolean;\n isLaneInfoVisible: boolean;\n}\n\nexport interface NaviLaneInfoEvent {\n laneCount: number;\n backgroundLane: number[];\n frontLane: number[];\n}\n\n/** 导航路线的连续路况分段,供统一自绘光柱消费 */\nexport interface NaviTrafficStatusItem {\n /** 路况状态值,跨平台统一对齐高德原始 status 枚举 */\n status: number;\n /** 该路况分段长度,单位米 */\n length: number;\n /** iOS 细粒度路况值;Android 当前无此字段 */\n fineStatus?: number;\n}\n\n/** 当前整条引导路线的路况快照 */\nexport interface NaviTrafficStatusesEvent {\n /** 当前整条路线长度,单位米 */\n totalLength?: number;\n /** 当前剩余距离,单位米 */\n retainDistance?: number;\n /** 当前路线的连续路况分段数组 */\n items: NaviTrafficStatusItem[];\n}\n\n// 导航开始事件\nexport interface NaviStartEvent {\n type?: number;\n loaded?: boolean;\n}\n\n// 导航结束事件\nexport interface NaviEndEvent {\n reason: string;\n}\n\n// 到达目的地事件\nexport interface NaviArriveEvent {\n arrived: boolean;\n}\n\n// 路径规划成功事件\nexport interface CalculateRouteSuccessEvent {\n routeIds?: number[];\n success?: boolean;\n}\n\n// 路径规划失败事件\nexport interface CalculateRouteFailureEvent {\n error?: string;\n errorCode?: number;\n}\n\n// 重新规划路径事件\nexport interface ReCalculateEvent {\n reason: string;\n}\n\n// 语音播报事件\nexport interface PlayVoiceEvent {\n text: string;\n type?: number;\n}\n\n// GPS信号弱事件\nexport interface GpsSignalWeakEvent {\n isWeak: boolean;\n}\n\nexport interface NaviEdgePadding {\n top?: number;\n left?: number;\n bottom?: number;\n right?: number;\n}\n\nexport interface NaviAnchorPoint {\n x?: number;\n y?: number;\n}\n\nexport interface NaviImageSize {\n width?: number;\n height?: number;\n}\n\nexport interface NaviCustomWaypointMarker {\n latitude: number;\n longitude: number;\n /** 气泡文案;iOS 当前仅驾车场景支持真正的自定义气泡视图,骑步行场景会回退为 SDK 默认途经点表现 */\n title?: string;\n}\n\n// 路线重算事件\nexport interface RouteRecalculateEvent {\n reason: string;\n}\n\n/**\n * 导航视图属性\n */\nexport interface ExpoGaodeMapNaviViewProps extends ViewProps {\n /**\n * 导航类型\n * - 0: GPS 导航\n * - 1: 模拟导航\n */\n naviType?: number;\n \n /**\n * 是否启用语音播报\n * @default true\n */\n enableVoice?: boolean;\n \n /**\n * 是否显示摄像头\n * @default true\n */\n showCamera?: boolean;\n \n /**\n * 是否自动锁车(非锁车模式7秒后自动切换为锁车模式)\n * @default true\n */\n autoLockCar?: boolean;\n \n /**\n * 是否开启自动缩放(锁车模式下自动缩放地图以预见下一导航动作)\n * @default true\n */\n autoChangeZoom?: boolean;\n \n /**\n * 是否显示实时交通路况线\n * 说明:Android 对应 `isTrafficLine`,iOS 对应 `mapShowTraffic`\n * @default true\n */\n trafficLayerEnabled?: boolean;\n \n /**\n * 是否显示路口放大图\n * @default true\n */\n realCrossDisplay?: boolean;\n \n /**\n * 导航视角模式\n * - 0: 车头朝上 (carNorth)\n * - 1: 正北朝上 (mapNorth)\n * @default 0\n */\n naviMode?: number;\n \n /**\n * 导航显示模式\n * - 1: 锁车态 (carPositionLocked) - 自车图标锁定在屏幕固定位置\n * - 2: 全览态 (overview) - 整条路线显示在可见区域内\n * - 3: 普通态 (normal) - 地图不动,自车图标移动\n * @default 1\n */\n showMode?: number;\n \n /**\n * 是否开启夜间模式\n * @deprecated 建议改用 `mapViewModeType`,跨平台表达力更完整\n * 说明:Android 映射 `setNaviNight`(并关闭 `setAutoNaviViewNightMode`),\n * iOS 映射 `mapViewModeType = Night/Day`;若同时传 `mapViewModeType`,以后者为准\n * @default false\n */\n isNightMode?: boolean;\n \n /**\n * 是否显示自车和罗盘\n * @platform android\n * @default true\n * @since 6.2.0\n */\n carOverlayVisible?: boolean;\n\n /**\n * 自定义导航车标图片\n * @platform android ios\n * 说明:iOS 对应 `setCarImage`,Android 对应 `AMapNaviViewOptions.setCarBitmap`\n */\n carImage?: NaviImageSource;\n\n /**\n * 自定义导航车标尺寸\n * @platform android ios\n * 说明:单位为 RN 逻辑像素(dp/pt),需同时传 `width` 与 `height` 才会生效\n */\n carImageSize?: NaviImageSize;\n\n /**\n * 自定义车标四角朝向图\n * @platform android\n * 说明:对应 `AMapNaviViewOptions.setFourCornersBitmap`\n */\n fourCornersImage?: NaviImageSource;\n\n /**\n * 自定义自车罗盘图\n * @platform ios\n * 说明:对应 `setCarCompassImage`\n */\n carCompassImage?: NaviImageSource;\n\n /**\n * 自定义起点标注图片\n * @platform android ios\n * 说明:iOS 对应 `setStartPointImage`,Android 对应 `setStartPointBitmap`\n */\n startPointImage?: NaviImageSource;\n\n /**\n * 自定义途经点标注图片\n * @platform android ios\n * 说明:iOS 对应 `setWayPointImage`,Android 对应 `setWayPointBitmap`\n */\n wayPointImage?: NaviImageSource;\n\n /**\n * 导航态自定义途经点气泡\n * @platform android ios\n * 说明:会额外挂载在导航地图上,而不是替换 SDK 默认途经点 icon。\n * Android 当前可用于驾车/骑行/步行;iOS 当前仅驾车场景支持真正的自定义气泡,骑步行场景会忽略该气泡并保留默认途经点表现。\n */\n customWaypointMarkers?: NaviCustomWaypointMarker[];\n\n /**\n * 自定义终点标注图片\n * @platform android ios\n * 说明:iOS 对应 `setEndPointImage`,Android 对应 `setEndPointBitmap`\n */\n endPointImage?: NaviImageSource;\n\n /**\n * 自定义摄像头图标\n * @platform ios\n * 说明:对应 `setCameraImage`\n */\n cameraImage?: NaviImageSource;\n\n \n /**\n * 路线标记点可见性配置\n * @platform android\n * @since 9.0.0\n */\n routeMarkerVisible?: {\n /** 是否显示起终途点 @default true */\n showStartEndVia?: boolean;\n /** 是否显示步行轮渡扎点 @default true */\n showFootFerry?: boolean;\n /** 是否显示禁行限行封路icon @default true */\n showForbidden?: boolean;\n /** 是否显示路线起点icon @default true @since 9.0.0 */\n showRouteStartIcon?: boolean;\n /** 是否显示路线终点icon @default true @since 9.0.0 */\n showRouteEndIcon?: boolean;\n };\n \n /**\n * 是否显示路线转向箭头\n * @platform android\n * @default true\n * @since 6.3.0\n */\n naviArrowVisible?: boolean;\n\n /**\n * 是否显示车道信息\n * @platform android\n * @default true\n */\n laneInfoVisible?: boolean;\n\n /**\n * 是否显示 3D 路口模型\n * @platform android\n * 说明:当前仅 Android 高德导航 SDK 提供该能力,iOS 会忽略此参数\n * @default true\n */\n modeCrossDisplay?: boolean;\n\n /**\n * 是否显示鹰眼路口图\n * @platform android\n * @default true\n */\n eyrieCrossDisplay?: boolean;\n\n /**\n * 是否显示辅助操作区域\n * @platform android\n * @default true\n */\n secondActionVisible?: boolean;\n\n /**\n * 是否显示备用路线覆盖物\n * @platform android\n * @default true\n */\n backupOverlayVisible?: boolean;\n \n /**\n * 是否显示拥堵气泡\n * 说明:当前主要用于驾车导航场景\n * @default true\n * @since Android 10.0.5 / iOS 10.0.900\n */\n showDriveCongestion?: boolean;\n \n /**\n * 是否显示红绿灯倒计时气泡\n * 说明:当前主要用于驾车导航场景\n * @default true\n * 提示:iOS 需开通红绿灯倒计时服务\n * @since Android 10.0.5 / iOS 10.0.900\n */\n showTrafficLightView?: boolean;\n\n\n /**\n * 导航界面顶部与状态栏的间距(单位:dp)\n * @platform android\n * 说明:当显示官方原生顶部信息区且未显式传值时,封装会自动补系统状态栏高度;\n * 若你需要关闭这层自动补偿,可显式传 `0`\n */\n androidStatusBarPaddingTop?: number;\n\n /**\n * 是否启用导航状态栏\n * @platform android\n * 说明:使用高德官方导航状态栏,而不是封装层手动偏移顶部 UI\n */\n naviStatusBarEnabled?: boolean;\n\n /**\n * 锁车态缩放级别\n * @platform android\n * @default 18\n */\n lockZoom?: number;\n\n /**\n * 锁车态倾斜角度\n * @platform android\n * @default 35\n */\n lockTilt?: number;\n\n /**\n * 是否显示鹰眼小地图\n * @platform android\n * @default false\n */\n eagleMapVisible?: boolean;\n\n /**\n * Android 锁车态自车锚点位置\n * @platform android\n * 说明:取值范围 `(0,1]`,传 `0` 时回退 SDK 默认值\n */\n pointToCenter?: NaviAnchorPoint;\n\n /**\n * 是否隐藏 Android 原生顶部导航信息卡片\n * @platform android\n * 说明:用于只保留地图/车道/路口图,自行绘制顶部 HUD\n * @default false\n */\n hideNativeTopInfoLayout?: boolean;\n\n /**\n * 是否在 Android 应用进入后台后显示导航常驻通知\n * @platform android\n * 说明:默认关闭;开启后会在后台通过前台服务持续更新导航进度通知。\n * Android 13+ 下封装会自动检查并请求 `POST_NOTIFICATIONS`,避免业务侧遗漏运行时权限申请。\n * @default false\n */\n androidBackgroundNavigationNotificationEnabled?: boolean;\n\n /**\n * 是否启用 iOS 导航 Live Activity(锁屏/灵动岛)\n * @platform ios\n * 说明:开启后会在导航信息更新时自动请求/更新 Live Activity;需同时在 Info.plist 开启 `NSSupportsLiveActivities`\n * 说明:驾车场景可直接使用 SDK 回调的转向图;骑步行场景当前回退为根据 `iconType` 生成的图标,不保证能拿到与驾车完全一致的原生素材\n * @default false\n */\n iosLiveActivityEnabled?: boolean;\n\n /**\n * 是否隐藏 iOS 原生车道信息条\n * @platform ios\n * 说明:用于保留官方地图/路况等元素,但把车道信息交给 RN 自绘 HUD 统一展示\n * @default false\n */\n hideNativeLaneInfoLayout?: boolean;\n \n // ========== iOS 特有属性 ==========\n \n /**\n * 是否显示路线\n * @platform ios\n * @default true\n */\n showRoute?: boolean;\n \n\n /**\n * 是否显示路况光柱\n * @default true\n */\n showTrafficBar?: boolean;\n\n /**\n * 路况光柱图位置\n * @platform ios\n * 说明:基于 `AMapNaviDriveView.tmcRouteFrame`,单位为 pt\n */\n trafficBarFrame?: NaviRect;\n\n /**\n * 路况光柱图颜色\n * @platform ios\n * 说明:基于 `AMapNaviDriveView.tmcRouteColor`,可分别配置不同路况颜色\n */\n trafficBarColors?: NaviTrafficBarColors;\n \n /**\n * 是否显示全览按钮\n * \n * @default true\n */\n showBrowseRouteButton?: boolean;\n \n /**\n * 是否显示更多按钮\n * @platform ios\n * @default true\n */\n showMoreButton?: boolean;\n \n /**\n * 是否显示实时交通按钮\n * 说明:Android 对应交通图层开关按钮,iOS 对应官方交通按钮\n *\n * @default true\n */\n showTrafficButton?: boolean;\n \n /**\n * 是否显示界面元素(设为false可完全自定义界面)\n * 说明:Android / iOS 均已实现;iOS 会在导航视图就绪后应用\n * @default true\n */\n showUIElements?: boolean;\n \n /**\n * 走过的路线是否置灰\n * \n * @default false\n */\n showGreyAfterPass?: boolean;\n \n /**\n * 是否显示牵引线(起点到终点的飞线)\n * \n * @default true\n */\n showVectorline?: boolean;\n\n /**\n * 设置是否为骑步行视图\n * @platform android\n * 说明:对应高德 Android 文档里的 `setIsNaviTravelView(true)` 兼容开关;驾车传 `false`,骑行/步行传 `true`\n * @default false\n */\n isNaviTravelView?:boolean\n\n /**\n * 是否显示指南针\n * 说明:Android 默认显示;iOS 仅在显式传值时覆盖官方默认行为\n */\n showCompassEnabled?: boolean;\n \n /**\n * 是否显示红绿灯图标\n * @default true\n */\n showTrafficLights?: boolean;\n \n /**\n * 地图样式类型\n * - 0: 白天模式 (day)\n * - 1: 黑夜模式 (night)\n * - 2: 根据日出日落自动切换 (dayNightAuto)\n * - 3: 自定义地图样式 (custom)\n * 说明:Android 对应 `setNaviNight` / `setAutoNaviViewNightMode`;当前 Android 的 `3`(custom)需要额外样式路径支持,未配置时会降级为 day\n * @default 0\n */\n mapViewModeType?: NaviMapViewModeType;\n \n /**\n * 路线polyline的宽度,设置0恢复默认宽度\n * @platform ios\n */\n lineWidth?: number;\n\n /**\n * iOS 导航内容边距\n * @platform ios\n * 说明:用于调整导航 HUD 和地图可视区域的边距\n */\n driveViewEdgePadding?: NaviEdgePadding;\n\n /**\n * iOS 地图视图锚点\n * @platform ios\n * 说明:取值范围 `[0,1]`;仅在 `showUIElements=false` 时生效\n */\n screenAnchor?: NaviAnchorPoint;\n\n /**\n * 是否显示备选路线\n * @platform ios\n * @default true\n */\n showBackupRoute?: boolean;\n\n /**\n * 是否显示鹰眼小地图\n * @platform ios\n */\n showEagleMap?: boolean;\n \n /**\n * 导航信息更新回调\n */\n onNaviInfoUpdate?: (event: NativeSyntheticEvent<NaviInfoUpdateEvent>) => void;\n \n /**\n * 导航开始回调\n */\n onNaviStart?: (event: NativeSyntheticEvent<NaviStartEvent>) => void;\n \n /**\n * 导航结束回调\n */\n onNaviEnd?: (event: NativeSyntheticEvent<NaviEndEvent>) => void;\n \n /**\n * 到达目的地回调\n */\n onArrive?: (event: NativeSyntheticEvent<NaviArriveEvent>) => void;\n \n /**\n * 路径规划成功回调\n */\n onCalculateRouteSuccess?: (event: NativeSyntheticEvent<CalculateRouteSuccessEvent>) => void;\n \n /**\n * 路径规划失败回调\n */\n onCalculateRouteFailure?: (event: NativeSyntheticEvent<CalculateRouteFailureEvent>) => void;\n \n /**\n * 重新规划路径回调\n */\n onReCalculate?: (event: NativeSyntheticEvent<ReCalculateEvent>) => void;\n \n /**\n * 语音播报回调\n */\n onPlayVoice?: (event: NativeSyntheticEvent<PlayVoiceEvent>) => void;\n \n /**\n * GPS信号弱回调\n */\n onGpsSignalWeak?: (event: NativeSyntheticEvent<GpsSignalWeakEvent>) => void;\n \n /**\n * 路线重算回调\n */\n onRouteRecalculate?: (event: NativeSyntheticEvent<RouteRecalculateEvent>) => void;\n\n /**\n * 导航视觉状态回调\n * 说明:用于感知路口大图 / 3D 路口 / 车道线显示状态,便于自绘 HUD 收窄或调整布局\n */\n onNaviVisualStateChange?: (event: NativeSyntheticEvent<NaviVisualStateEvent>) => void;\n\n /**\n * 车道信息更新回调\n * @platform android ios\n * 说明:用于自绘车道条。Android 直接对齐高德 `AMapLaneInfo` 核心字段;\n * iOS 则将 `showLaneBackInfo/laneSelectInfo` 解析为同结构数据。\n */\n onLaneInfoUpdate?: (event: NativeSyntheticEvent<NaviLaneInfoEvent>) => void;\n\n /**\n * 路况光柱分段数据更新回调\n * @platform android ios\n * 说明:用于自绘路况光柱。Android 基于 `getTrafficStatuses(0, 0)`,\n * iOS 基于 `updateTrafficStatus` 回调,对齐为统一结构。\n */\n onTrafficStatusesUpdate?: (event: NativeSyntheticEvent<NaviTrafficStatusesEvent>) => void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"naviview.types.js","sourceRoot":"","sources":["../../src/types/naviview.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ViewProps, NativeSyntheticEvent, ImageSourcePropType } from \"react-native\";\n\nexport type NaviColorValue = string | number;\nexport type NaviImageSource = string | ImageSourcePropType;\nexport type NaviMapViewModeType = 0 | 1 | 2 | 3;\n\nexport interface NaviRect {\n x?: number;\n y?: number;\n width?: number;\n height?: number;\n}\n\nexport interface NaviTrafficBarColors {\n unknown?: NaviColorValue;\n smooth?: NaviColorValue;\n fineOpen?: NaviColorValue;\n slow?: NaviColorValue;\n jam?: NaviColorValue;\n seriousJam?: NaviColorValue;\n defaultRoad?: NaviColorValue;\n}\n\n// 导航信息更新事件\nexport interface NaviInfoUpdateEvent {\n naviMode?: number;\n pathRetainDistance: number;\n pathRetainTime: number;\n curStepRetainDistance?: number;\n curStepRetainTime?: number;\n currentRoadName: string;\n nextRoadName: string;\n currentSpeed?: number;\n iconType?: number;\n nextIconType?: number;\n /** 当前导航动作的原生转向图标 URI,优先级高于 iconType */\n turnIconImage?: string;\n /** 下一导航动作的原生转向图标 URI;当前主要由 iOS 驾车场景提供,Android 与 iOS 骑步行场景通常为空 */\n nextTurnIconImage?: string;\n iconDirection?: number;\n currentSegmentIndex?: number;\n currentLinkIndex?: number;\n currentPointIndex?: number;\n routeRemainTrafficLightCount?: number;\n driveDistance?: number;\n driveTime?: number;\n}\n\nexport interface NaviVisualStateEvent {\n /** 是否正在显示实景路口放大图 */\n isCrossVisible: boolean;\n /** 是否正在显示 3D 路口模型;当前仅 Android 支持,iOS 恒为 false */\n isModeCrossVisible: boolean;\n isLaneInfoVisible: boolean;\n}\n\nexport interface NaviLaneInfoEvent {\n laneCount: number;\n backgroundLane: number[];\n frontLane: number[];\n}\n\n/** 导航路线的连续路况分段,供统一自绘光柱消费 */\nexport interface NaviTrafficStatusItem {\n /** 路况状态值,跨平台统一对齐高德原始 status 枚举 */\n status: number;\n /** 该路况分段长度,单位米 */\n length: number;\n /** iOS 细粒度路况值;Android 当前无此字段 */\n fineStatus?: number;\n}\n\n/** 当前整条引导路线的路况快照 */\nexport interface NaviTrafficStatusesEvent {\n /** 当前整条路线长度,单位米 */\n totalLength?: number;\n /** 当前剩余距离,单位米 */\n retainDistance?: number;\n /** 当前路线的连续路况分段数组 */\n items: NaviTrafficStatusItem[];\n}\n\n// 导航开始事件\nexport interface NaviStartEvent {\n type?: number;\n loaded?: boolean;\n}\n\n// 导航结束事件\nexport interface NaviEndEvent {\n reason: string;\n}\n\n// 到达目的地事件\nexport interface NaviArriveEvent {\n arrived: boolean;\n}\n\n// 路径规划成功事件\nexport interface CalculateRouteSuccessEvent {\n routeIds?: number[];\n success?: boolean;\n}\n\n// 路径规划失败事件\nexport interface CalculateRouteFailureEvent {\n error?: string;\n errorCode?: number;\n}\n\n// 重新规划路径事件\nexport interface ReCalculateEvent {\n reason: string;\n}\n\n// 语音播报事件\nexport interface PlayVoiceEvent {\n text: string;\n type?: number;\n}\n\n// GPS信号弱事件\nexport interface GpsSignalWeakEvent {\n isWeak: boolean;\n}\n\nexport interface NaviEdgePadding {\n top?: number;\n left?: number;\n bottom?: number;\n right?: number;\n}\n\nexport interface NaviAnchorPoint {\n x?: number;\n y?: number;\n}\n\nexport interface NaviImageSize {\n width?: number;\n height?: number;\n}\n\nexport interface NaviCustomWaypointMarker {\n latitude: number;\n longitude: number;\n /** 气泡文案;iOS 当前仅驾车场景支持真正的自定义气泡视图,骑步行场景会回退为 SDK 默认途经点表现 */\n title?: string;\n}\n\n// 路线重算事件\nexport interface RouteRecalculateEvent {\n reason: string;\n}\n\n/**\n * 导航视图属性\n */\nexport interface ExpoGaodeMapNaviViewProps extends ViewProps {\n /**\n * 导航类型\n * - 0: GPS 导航\n * - 1: 模拟导航\n */\n naviType?: number;\n \n /**\n * 是否启用语音播报\n * @default true\n */\n enableVoice?: boolean;\n \n /**\n * 是否显示摄像头\n * @default true\n */\n showCamera?: boolean;\n \n /**\n * 是否自动锁车(非锁车模式7秒后自动切换为锁车模式)\n * @default true\n */\n autoLockCar?: boolean;\n \n /**\n * 是否开启自动缩放(锁车模式下自动缩放地图以预见下一导航动作)\n * @default true\n */\n autoChangeZoom?: boolean;\n \n /**\n * 是否显示实时交通路况线\n * 说明:Android 对应 `isTrafficLine`,iOS 对应 `mapShowTraffic`\n * @default true\n */\n trafficLayerEnabled?: boolean;\n \n /**\n * 是否显示路口放大图\n * @default true\n */\n realCrossDisplay?: boolean;\n \n /**\n * 导航视角模式\n * - 0: 车头朝上 (carNorth)\n * - 1: 正北朝上 (mapNorth)\n * @default 0\n */\n naviMode?: number;\n \n /**\n * 导航显示模式\n * - 1: 锁车态 (carPositionLocked) - 自车图标锁定在屏幕固定位置\n * - 2: 全览态 (overview) - 整条路线显示在可见区域内\n * - 3: 普通态 (normal) - 地图不动,自车图标移动\n * @default 1\n */\n showMode?: number;\n \n /**\n * 是否开启夜间模式\n * @deprecated 建议改用 `mapViewModeType`,跨平台表达力更完整\n * 说明:Android 映射 `setNaviNight`(并关闭 `setAutoNaviViewNightMode`),\n * iOS 映射 `mapViewModeType = Night/Day`;若同时传 `mapViewModeType`,以后者为准\n * @default false\n */\n isNightMode?: boolean;\n \n /**\n * 是否显示自车和罗盘\n * @platform android\n * @default true\n * @since 6.2.0\n */\n carOverlayVisible?: boolean;\n\n /**\n * 自定义导航车标图片\n * @platform android ios\n * 说明:iOS 对应 `setCarImage`,Android 对应 `AMapNaviViewOptions.setCarBitmap`\n */\n carImage?: NaviImageSource;\n\n /**\n * 自定义导航车标尺寸\n * @platform android ios\n * 说明:单位为 RN 逻辑像素(dp/pt),需同时传 `width` 与 `height` 才会生效\n */\n carImageSize?: NaviImageSize;\n\n /**\n * 自定义车标四角朝向图\n * @platform android\n * 说明:对应 `AMapNaviViewOptions.setFourCornersBitmap`\n */\n fourCornersImage?: NaviImageSource;\n\n /**\n * 自定义自车罗盘图\n * @platform ios\n * 说明:对应 `setCarCompassImage`\n */\n carCompassImage?: NaviImageSource;\n\n /**\n * 自定义起点标注图片\n * @platform android ios\n * 说明:iOS 对应 `setStartPointImage`,Android 对应 `setStartPointBitmap`\n */\n startPointImage?: NaviImageSource;\n\n /**\n * 自定义途经点标注图片\n * @platform android ios\n * 说明:iOS 对应 `setWayPointImage`,Android 对应 `setWayPointBitmap`\n */\n wayPointImage?: NaviImageSource;\n\n /**\n * 导航态自定义途经点气泡\n * @platform android ios\n * 说明:会额外挂载在导航地图上,而不是替换 SDK 默认途经点 icon。\n * Android 当前可用于驾车/骑行/步行;iOS 当前仅驾车场景支持真正的自定义气泡,骑步行场景会忽略该气泡并保留默认途经点表现。\n */\n customWaypointMarkers?: NaviCustomWaypointMarker[];\n\n /**\n * 自定义终点标注图片\n * @platform android ios\n * 说明:iOS 对应 `setEndPointImage`,Android 对应 `setEndPointBitmap`\n */\n endPointImage?: NaviImageSource;\n\n /**\n * 自定义摄像头图标\n * @platform ios\n * 说明:对应 `setCameraImage`\n */\n cameraImage?: NaviImageSource;\n\n \n /**\n * 路线标记点可见性配置\n * @platform android\n * @since 9.0.0\n */\n routeMarkerVisible?: {\n /** 是否显示起终途点 @default true */\n showStartEndVia?: boolean;\n /** 是否显示步行轮渡扎点 @default true */\n showFootFerry?: boolean;\n /** 是否显示禁行限行封路icon @default true */\n showForbidden?: boolean;\n /** 是否显示路线起点icon @default true @since 9.0.0 */\n showRouteStartIcon?: boolean;\n /** 是否显示路线终点icon @default true @since 9.0.0 */\n showRouteEndIcon?: boolean;\n };\n \n /**\n * 是否显示路线转向箭头\n * @platform android\n * @default true\n * @since 6.3.0\n */\n naviArrowVisible?: boolean;\n\n /**\n * 是否显示车道信息\n * @platform android\n * @default true\n */\n laneInfoVisible?: boolean;\n\n /**\n * 是否显示 3D 路口模型\n * @platform android\n * 说明:当前仅 Android 高德导航 SDK 提供该能力,iOS 会忽略此参数\n * @default true\n */\n modeCrossDisplay?: boolean;\n\n /**\n * 是否显示鹰眼路口图\n * @platform android\n * @default true\n */\n eyrieCrossDisplay?: boolean;\n\n /**\n * 是否显示辅助操作区域\n * @platform android\n * @default true\n */\n secondActionVisible?: boolean;\n\n /**\n * 是否显示备用路线覆盖物\n * @platform android\n * @default true\n */\n backupOverlayVisible?: boolean;\n \n /**\n * 是否显示拥堵气泡\n * 说明:当前主要用于驾车导航场景\n * @default true\n * @since Android 10.0.5 / iOS 10.0.900\n */\n showDriveCongestion?: boolean;\n \n /**\n * 是否显示红绿灯倒计时气泡\n * 说明:当前主要用于驾车导航场景\n * @default true\n * 提示:iOS 需开通红绿灯倒计时服务\n * @since Android 10.0.5 / iOS 10.0.900\n */\n showTrafficLightView?: boolean;\n\n\n /**\n * 导航界面顶部与状态栏的间距(单位:dp)\n * @platform android\n * 说明:当显示官方原生顶部信息区且未显式传值时,封装会自动补系统状态栏高度;\n * 若你需要关闭这层自动补偿,可显式传 `0`\n */\n androidStatusBarPaddingTop?: number;\n\n /**\n * 是否启用导航状态栏\n * @platform android\n * 说明:使用高德官方导航状态栏,而不是封装层手动偏移顶部 UI\n */\n naviStatusBarEnabled?: boolean;\n\n /**\n * 锁车态缩放级别\n * @platform android\n * @default 18\n */\n lockZoom?: number;\n\n /**\n * 锁车态倾斜角度\n * @platform android\n * @default 35\n */\n lockTilt?: number;\n\n /**\n * 是否显示鹰眼小地图\n * @platform android\n * @default false\n */\n eagleMapVisible?: boolean;\n\n /**\n * Android 锁车态自车锚点位置\n * @platform android\n * 说明:取值范围 `(0,1]`,传 `0` 时回退 SDK 默认值\n */\n pointToCenter?: NaviAnchorPoint;\n\n /**\n * 是否隐藏 Android 原生顶部导航信息卡片\n * @platform android\n * 说明:用于只保留地图/车道/路口图,自行绘制顶部 HUD\n * @default false\n */\n hideNativeTopInfoLayout?: boolean;\n\n /**\n * 是否在 Android 应用进入后台后显示导航常驻通知\n * @platform android\n * 说明:默认关闭;开启后会在后台通过前台服务持续更新导航进度通知。\n * Android 13+ 下封装会自动检查并请求 `POST_NOTIFICATIONS`,避免业务侧遗漏运行时权限申请。\n * @default false\n */\n androidBackgroundNavigationNotificationEnabled?: boolean;\n\n /**\n * 是否启用 iOS 导航 Live Activity(锁屏/灵动岛)\n * @platform ios\n * 说明:开启后会在导航信息更新时自动请求/更新 Live Activity;需同时在 Info.plist 开启 `NSSupportsLiveActivities`\n * 说明:驾车场景可直接使用 SDK 回调的转向图;骑步行场景当前回退为根据 `iconType` 生成的图标,不保证能拿到与驾车完全一致的原生素材\n * @default false\n */\n iosLiveActivityEnabled?: boolean;\n\n /**\n * 是否隐藏 iOS 原生车道信息条\n * @platform ios\n * 说明:用于保留官方地图/路况等元素,但把车道信息交给 RN 自绘 HUD 统一展示\n * @default false\n */\n hideNativeLaneInfoLayout?: boolean;\n \n // ========== iOS 特有属性 ==========\n \n /**\n * 是否显示路线\n * @platform ios\n * @default true\n */\n showRoute?: boolean;\n \n\n /**\n * 是否显示路况光柱\n * @default true\n */\n showTrafficBar?: boolean;\n\n /**\n * 路况光柱图位置\n * @platform ios\n * 说明:基于 `AMapNaviDriveView.tmcRouteFrame`,单位为 pt\n */\n trafficBarFrame?: NaviRect;\n\n /**\n * 路况光柱图颜色\n * @platform ios\n * 说明:基于 `AMapNaviDriveView.tmcRouteColor`,可分别配置不同路况颜色\n */\n trafficBarColors?: NaviTrafficBarColors;\n \n /**\n * 是否显示全览按钮\n * \n * @default true\n */\n showBrowseRouteButton?: boolean;\n \n /**\n * 是否显示更多按钮\n * @platform ios\n * @default true\n */\n showMoreButton?: boolean;\n \n /**\n * 是否显示实时交通按钮\n * 说明:Android 对应交通图层开关按钮,iOS 对应官方交通按钮\n *\n * @default true\n */\n showTrafficButton?: boolean;\n \n /**\n * 是否显示界面元素(设为false可完全自定义界面)\n * 说明:Android / iOS 均已实现;iOS 会在导航视图就绪后应用\n * @default true\n */\n showUIElements?: boolean;\n \n /**\n * 走过的路线是否置灰\n * \n * @default false\n */\n showGreyAfterPass?: boolean;\n \n /**\n * 是否显示牵引线(起点到终点的飞线)\n * \n * @default true\n */\n showVectorline?: boolean;\n\n /**\n * 设置是否为骑步行视图\n * @platform android\n * 说明:对应高德 Android 文档里的 `setIsNaviTravelView(true)` 兼容开关;驾车传 `false`,骑行/步行传 `true`\n * @default false\n */\n isNaviTravelView?:boolean\n\n /**\n * 是否显示指南针\n * 说明:Android 默认显示;iOS 仅在显式传值时覆盖官方默认行为\n */\n showCompassEnabled?: boolean;\n \n /**\n * 是否显示红绿灯图标\n * @default true\n */\n showTrafficLights?: boolean;\n \n /**\n * 地图样式类型\n * - 0: 白天模式 (day)\n * - 1: 黑夜模式 (night)\n * - 2: 根据日出日落自动切换 (dayNightAuto)\n * - 3: 自定义地图样式 (custom)\n * 说明:Android 对应 `setNaviNight` / `setAutoNaviViewNightMode`;当前 Android 的 `3`(custom)需要额外样式路径支持,未配置时会降级为 day\n * @default 0\n */\n mapViewModeType?: NaviMapViewModeType;\n \n /**\n * 路线polyline的宽度,设置0恢复默认宽度\n * @platform ios\n */\n lineWidth?: number;\n\n /**\n * iOS 导航内容边距\n * @platform ios\n * 说明:用于调整导航 HUD 和地图可视区域的边距\n */\n driveViewEdgePadding?: NaviEdgePadding;\n\n /**\n * iOS 地图视图锚点\n * @platform ios\n * 说明:取值范围 `[0,1]`;仅在 `showUIElements=false` 时生效\n */\n screenAnchor?: NaviAnchorPoint;\n\n /**\n * 是否显示备选路线\n * @platform ios\n * @default true\n */\n showBackupRoute?: boolean;\n\n /**\n * 是否显示鹰眼小地图\n * @platform ios\n */\n showEagleMap?: boolean;\n \n /**\n * 导航信息更新回调\n */\n onNaviInfoUpdate?: (event: NativeSyntheticEvent<NaviInfoUpdateEvent>) => void;\n \n /**\n * 导航开始回调\n */\n onNaviStart?: (event: NativeSyntheticEvent<NaviStartEvent>) => void;\n \n /**\n * 导航结束回调\n */\n onNaviEnd?: (event: NativeSyntheticEvent<NaviEndEvent>) => void;\n \n /**\n * 到达目的地回调\n */\n onArrive?: (event: NativeSyntheticEvent<NaviArriveEvent>) => void;\n \n /**\n * 路径规划成功回调\n */\n onCalculateRouteSuccess?: (event: NativeSyntheticEvent<CalculateRouteSuccessEvent>) => void;\n \n /**\n * 路径规划失败回调\n */\n onCalculateRouteFailure?: (event: NativeSyntheticEvent<CalculateRouteFailureEvent>) => void;\n \n /**\n * 重新规划路径回调\n */\n onReCalculate?: (event: NativeSyntheticEvent<ReCalculateEvent>) => void;\n \n /**\n * 语音播报回调\n */\n onPlayVoice?: (event: NativeSyntheticEvent<PlayVoiceEvent>) => void;\n \n /**\n * GPS信号弱回调\n */\n onGpsSignalWeak?: (event: NativeSyntheticEvent<GpsSignalWeakEvent>) => void;\n \n /**\n * 路线重算回调\n */\n onRouteRecalculate?: (event: NativeSyntheticEvent<RouteRecalculateEvent>) => void;\n\n /**\n * 导航视觉状态回调\n * 说明:用于感知路口大图 / 3D 路口 / 车道线显示状态,便于自绘 HUD 收窄或调整布局\n */\n onNaviVisualStateChange?: (event: NativeSyntheticEvent<NaviVisualStateEvent>) => void;\n\n /**\n * 车道信息更新回调\n * @platform android ios\n * 说明:用于自绘车道条。Android 直接对齐高德 `AMapLaneInfo` 核心字段;\n * iOS 则将 `showLaneBackInfo/laneSelectInfo` 解析为同结构数据。\n */\n onLaneInfoUpdate?: (event: NativeSyntheticEvent<NaviLaneInfoEvent>) => void;\n\n /**\n * 路况光柱分段数据更新回调\n * @platform android ios\n * 说明:用于自绘路况光柱。Android 基于 `getTrafficStatuses(0, 0)`,\n * iOS 基于 `updateTrafficStatus` 回调,对齐为统一结构。\n */\n onTrafficStatusesUpdate?: (event: NativeSyntheticEvent<NaviTrafficStatusesEvent>) => void;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-api-fallback.d.ts","sourceRoot":"","sources":["../src/web-api-fallback.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAe,mBAAmB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"web-api-fallback.d.ts","sourceRoot":"","sources":["../src/web-api-fallback.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAe,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAqHrG,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAIjF;AAED,wBAAsB,mCAAmC,CACvD,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAqB3B;AAoCD,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,gBAAgB,CAAC,CAkB3B"}
|
|
@@ -2,7 +2,6 @@ import { DriveStrategy } from './types';
|
|
|
2
2
|
import { parsePolyline } from './route-geometry';
|
|
3
3
|
async function loadWebApiFallback(feature) {
|
|
4
4
|
try {
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
6
5
|
const webApi = require('expo-gaode-map-web-api');
|
|
7
6
|
if (typeof webApi?.GaodeWebAPI !== 'function') {
|
|
8
7
|
throw new Error('expo-gaode-map-web-api 未导出 GaodeWebAPI');
|