expo-gaode-map-navigation 2.0.12-next.0 → 2.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +296 -7
- package/android/build.gradle +12 -4
- package/android/src/main/AndroidManifest.xml +10 -1
- package/android/src/main/cpp/cluster_jni.cpp +56 -0
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapModule.kt +49 -8
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapOfflineModule.kt +83 -15
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapView.kt +13 -3
- package/android/src/main/java/expo/modules/gaodemap/map/managers/UIManager.kt +36 -39
- package/android/src/main/java/expo/modules/gaodemap/map/modules/SDKInitializer.kt +23 -17
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/ClusterView.kt +5 -2
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/HeatMapView.kt +122 -10
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/HeatMapViewModule.kt +2 -2
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/MarkerView.kt +37 -25
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/MarkerViewModule.kt +6 -6
- package/android/src/main/java/expo/modules/gaodemap/map/search/ExpoGaodeMapSearchModule.kt +751 -0
- package/android/src/main/java/expo/modules/gaodemap/map/utils/GeometryUtils.kt +103 -0
- package/android/src/main/java/expo/modules/gaodemap/navigation/ExpoGaodeMapNaviView.kt +1408 -394
- package/android/src/main/java/expo/modules/gaodemap/navigation/ExpoGaodeMapNaviViewModule.kt +121 -1
- package/android/src/main/java/expo/modules/gaodemap/navigation/ExpoGaodeMapNavigationModule.kt +14 -28
- package/android/src/main/java/expo/modules/gaodemap/navigation/listeners/IndependentRouteListener.kt +28 -3
- package/android/src/main/java/expo/modules/gaodemap/navigation/listeners/RouteCalculateListener.kt +2 -2
- package/android/src/main/java/expo/modules/gaodemap/navigation/managers/IndependentRouteManager.kt +114 -15
- package/android/src/main/java/expo/modules/gaodemap/navigation/routes/drive/DriveTruckRouteCalculator.kt +24 -35
- package/android/src/main/java/expo/modules/gaodemap/navigation/services/IndependentRouteService.kt +50 -36
- package/android/src/main/java/expo/modules/gaodemap/navigation/services/NavigationForegroundService.kt +661 -0
- package/android/src/main/java/expo/modules/gaodemap/navigation/utils/Converters.kt +21 -12
- package/android/src/main/res/drawable/ic_nav_notification_small.xml +10 -0
- package/android/src/main/res/drawable/landback_0.png +0 -0
- package/android/src/main/res/drawable/landback_1.png +0 -0
- package/android/src/main/res/drawable/landback_2.png +0 -0
- package/android/src/main/res/drawable/landback_3.png +0 -0
- package/android/src/main/res/drawable/landback_4.png +0 -0
- package/android/src/main/res/drawable/landback_5.png +0 -0
- package/android/src/main/res/drawable/landback_6.png +0 -0
- package/android/src/main/res/drawable/landback_7.png +0 -0
- package/android/src/main/res/drawable/landback_8.png +0 -0
- package/android/src/main/res/drawable/landback_9.png +0 -0
- package/android/src/main/res/drawable/landback_a.png +0 -0
- package/android/src/main/res/drawable/landback_b.png +0 -0
- package/android/src/main/res/drawable/landback_c.png +0 -0
- package/android/src/main/res/drawable/landback_d.png +0 -0
- package/android/src/main/res/drawable/landback_e.png +0 -0
- package/android/src/main/res/drawable/landback_f.png +0 -0
- package/android/src/main/res/drawable/landback_g.png +0 -0
- package/android/src/main/res/drawable/landback_h.png +0 -0
- package/android/src/main/res/drawable/landback_i.png +0 -0
- package/android/src/main/res/drawable/landback_j.png +0 -0
- package/android/src/main/res/drawable/landback_k.png +0 -0
- package/android/src/main/res/drawable/landback_l.png +0 -0
- package/android/src/main/res/drawable/landfront_0.png +0 -0
- package/android/src/main/res/drawable/landfront_00.png +0 -0
- package/android/src/main/res/drawable/landfront_1.png +0 -0
- package/android/src/main/res/drawable/landfront_11.png +0 -0
- package/android/src/main/res/drawable/landfront_20.png +0 -0
- package/android/src/main/res/drawable/landfront_21.png +0 -0
- package/android/src/main/res/drawable/landfront_22.png +0 -0
- package/android/src/main/res/drawable/landfront_3.png +0 -0
- package/android/src/main/res/drawable/landfront_33.png +0 -0
- package/android/src/main/res/drawable/landfront_40.png +0 -0
- package/android/src/main/res/drawable/landfront_43.png +0 -0
- package/android/src/main/res/drawable/landfront_44.png +0 -0
- package/android/src/main/res/drawable/landfront_5.png +0 -0
- package/android/src/main/res/drawable/landfront_55.png +0 -0
- package/android/src/main/res/drawable/landfront_61.png +0 -0
- package/android/src/main/res/drawable/landfront_63.png +0 -0
- package/android/src/main/res/drawable/landfront_66.png +0 -0
- package/android/src/main/res/drawable/landfront_70.png +0 -0
- package/android/src/main/res/drawable/landfront_71.png +0 -0
- package/android/src/main/res/drawable/landfront_73.png +0 -0
- package/android/src/main/res/drawable/landfront_77.png +0 -0
- package/android/src/main/res/drawable/landfront_8.png +0 -0
- package/android/src/main/res/drawable/landfront_88.png +0 -0
- package/android/src/main/res/drawable/landfront_90.png +0 -0
- package/android/src/main/res/drawable/landfront_95.png +0 -0
- package/android/src/main/res/drawable/landfront_99.png +0 -0
- package/android/src/main/res/drawable/landfront_a0.png +0 -0
- package/android/src/main/res/drawable/landfront_a8.png +0 -0
- package/android/src/main/res/drawable/landfront_aa.png +0 -0
- package/android/src/main/res/drawable/landfront_b1.png +0 -0
- package/android/src/main/res/drawable/landfront_b5.png +0 -0
- package/android/src/main/res/drawable/landfront_bb.png +0 -0
- package/android/src/main/res/drawable/landfront_c3.png +0 -0
- package/android/src/main/res/drawable/landfront_c8.png +0 -0
- package/android/src/main/res/drawable/landfront_cc.png +0 -0
- package/android/src/main/res/drawable/landfront_d.png +0 -0
- package/android/src/main/res/drawable/landfront_dd.png +0 -0
- package/android/src/main/res/drawable/landfront_e1.png +0 -0
- package/android/src/main/res/drawable/landfront_e5.png +0 -0
- package/android/src/main/res/drawable/landfront_ee.png +0 -0
- package/android/src/main/res/drawable/landfront_f0.png +0 -0
- package/android/src/main/res/drawable/landfront_f1.png +0 -0
- package/android/src/main/res/drawable/landfront_f5.png +0 -0
- package/android/src/main/res/drawable/landfront_ff.png +0 -0
- package/android/src/main/res/drawable/landfront_g3.png +0 -0
- package/android/src/main/res/drawable/landfront_g5.png +0 -0
- package/android/src/main/res/drawable/landfront_gg.png +0 -0
- package/android/src/main/res/drawable/landfront_h1.png +0 -0
- package/android/src/main/res/drawable/landfront_h3.png +0 -0
- package/android/src/main/res/drawable/landfront_h5.png +0 -0
- package/android/src/main/res/drawable/landfront_hh.png +0 -0
- package/android/src/main/res/drawable/landfront_i0.png +0 -0
- package/android/src/main/res/drawable/landfront_i3.png +0 -0
- package/android/src/main/res/drawable/landfront_i5.png +0 -0
- package/android/src/main/res/drawable/landfront_ii.png +0 -0
- package/android/src/main/res/drawable/landfront_j1.png +0 -0
- package/android/src/main/res/drawable/landfront_j8.png +0 -0
- package/android/src/main/res/drawable/landfront_jj.png +0 -0
- package/android/src/main/res/drawable/landfront_kk.png +0 -0
- package/android/src/main/res/drawable/landfront_ll.png +0 -0
- package/android/src/main/res/drawable/nav_notification_brand_icon.xml +16 -0
- package/android/src/main/res/drawable/navi_arrow_leftline.png +0 -0
- package/android/src/main/res/drawable/navi_lane_shape_bg_center.xml +5 -0
- package/android/src/main/res/drawable/navi_lane_shape_bg_left.xml +8 -0
- package/android/src/main/res/drawable/navi_lane_shape_bg_over.xml +6 -0
- package/android/src/main/res/drawable/navi_lane_shape_bg_right.xml +8 -0
- package/android/src/main/res/drawable-nodpi/nav_tracker_car.png +0 -0
- package/build/ExpoGaodeMapNaviView.d.ts +16 -0
- package/build/ExpoGaodeMapNaviView.d.ts.map +1 -1
- package/build/ExpoGaodeMapNaviView.js +74 -1
- package/build/ExpoGaodeMapNaviView.js.map +1 -1
- package/build/index.d.ts +56 -8
- package/build/index.d.ts.map +1 -1
- package/build/index.js +452 -10
- package/build/index.js.map +1 -1
- package/build/map/ExpoGaodeMapModule.d.ts +15 -13
- package/build/map/ExpoGaodeMapModule.d.ts.map +1 -1
- package/build/map/ExpoGaodeMapModule.js +31 -39
- package/build/map/ExpoGaodeMapModule.js.map +1 -1
- package/build/map/ExpoGaodeMapOfflineModule.d.ts +5 -0
- package/build/map/ExpoGaodeMapOfflineModule.d.ts.map +1 -1
- package/build/map/ExpoGaodeMapOfflineModule.js.map +1 -1
- package/build/map/ExpoGaodeMapView.d.ts +3 -4
- package/build/map/ExpoGaodeMapView.d.ts.map +1 -1
- package/build/map/ExpoGaodeMapView.js +28 -25
- package/build/map/ExpoGaodeMapView.js.map +1 -1
- package/build/map/components/overlays/Circle.d.ts.map +1 -1
- package/build/map/components/overlays/Circle.js +1 -30
- package/build/map/components/overlays/Circle.js.map +1 -1
- package/build/map/components/overlays/Cluster.d.ts.map +1 -1
- package/build/map/components/overlays/Cluster.js +1 -42
- package/build/map/components/overlays/Cluster.js.map +1 -1
- package/build/map/components/overlays/HeatMap.d.ts.map +1 -1
- package/build/map/components/overlays/HeatMap.js +21 -21
- package/build/map/components/overlays/HeatMap.js.map +1 -1
- package/build/map/components/overlays/Marker.d.ts.map +1 -1
- package/build/map/components/overlays/Marker.js +76 -80
- package/build/map/components/overlays/Marker.js.map +1 -1
- package/build/map/components/overlays/Polygon.d.ts.map +1 -1
- package/build/map/components/overlays/Polygon.js +1 -25
- package/build/map/components/overlays/Polygon.js.map +1 -1
- package/build/map/components/overlays/Polyline.d.ts.map +1 -1
- package/build/map/components/overlays/Polyline.js +1 -31
- package/build/map/components/overlays/Polyline.js.map +1 -1
- package/build/map/index.d.ts +9 -2
- package/build/map/index.d.ts.map +1 -1
- package/build/map/index.js +9 -2
- package/build/map/index.js.map +1 -1
- package/build/map/search/ExpoGaodeMapSearch.types.d.ts +340 -0
- package/build/map/search/ExpoGaodeMapSearch.types.d.ts.map +1 -0
- package/build/map/search/ExpoGaodeMapSearch.types.js +19 -0
- package/build/map/search/ExpoGaodeMapSearch.types.js.map +1 -0
- package/build/map/search/ExpoGaodeMapSearchModule.d.ts +74 -0
- package/build/map/search/ExpoGaodeMapSearchModule.d.ts.map +1 -0
- package/build/map/search/ExpoGaodeMapSearchModule.js +47 -0
- package/build/map/search/ExpoGaodeMapSearchModule.js.map +1 -0
- package/build/map/search/index.d.ts +156 -0
- package/build/map/search/index.d.ts.map +1 -0
- package/build/map/search/index.js +171 -0
- package/build/map/search/index.js.map +1 -0
- package/build/map/types/index.d.ts +2 -2
- package/build/map/types/index.d.ts.map +1 -1
- package/build/map/types/index.js.map +1 -1
- package/build/map/types/map-view.types.d.ts +4 -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/types/native-module.types.d.ts +11 -12
- package/build/map/types/native-module.types.d.ts.map +1 -1
- package/build/map/types/native-module.types.js.map +1 -1
- package/build/map/types/overlays.types.d.ts +9 -14
- package/build/map/types/overlays.types.d.ts.map +1 -1
- package/build/map/types/overlays.types.js.map +1 -1
- package/build/map/types/route-playback.types.d.ts +16 -0
- package/build/map/types/route-playback.types.d.ts.map +1 -1
- package/build/map/types/route-playback.types.js.map +1 -1
- package/build/map/utils/ErrorHandler.js +11 -11
- package/build/map/utils/ErrorHandler.js.map +1 -1
- package/build/map/utils/OfflineMapManager.d.ts +4 -0
- package/build/map/utils/OfflineMapManager.d.ts.map +1 -1
- package/build/map/utils/OfflineMapManager.js +6 -0
- package/build/map/utils/OfflineMapManager.js.map +1 -1
- package/build/types/coordinates.types.d.ts +3 -0
- package/build/types/coordinates.types.d.ts.map +1 -1
- package/build/types/coordinates.types.js.map +1 -1
- package/build/types/independent.types.d.ts +111 -12
- package/build/types/independent.types.d.ts.map +1 -1
- package/build/types/independent.types.js.map +1 -1
- package/build/types/native-module.types.d.ts +1 -1
- package/build/types/native-module.types.js.map +1 -1
- package/build/types/naviview.types.d.ts +304 -14
- package/build/types/naviview.types.d.ts.map +1 -1
- package/build/types/naviview.types.js.map +1 -1
- package/build/types/route.types.d.ts +12 -2
- package/build/types/route.types.d.ts.map +1 -1
- package/build/types/route.types.js.map +1 -1
- package/expo-module.config.json +4 -2
- package/ios/ExpoGaodeMapNaviView.swift +2331 -201
- package/ios/ExpoGaodeMapNaviViewModule.swift +109 -1
- package/ios/ExpoGaodeMapNavigation.podspec +2 -1
- package/ios/ExpoGaodeMapNavigationModule.swift +7 -5
- package/ios/managers/IndependentRouteManager.swift +90 -26
- package/ios/map/ExpoGaodeMapModule.swift +72 -21
- package/ios/map/ExpoGaodeMapOfflineModule.swift +61 -0
- package/ios/map/ExpoGaodeMapSearchModule.swift +773 -0
- package/ios/map/ExpoGaodeMapView.swift +23 -5
- package/ios/map/GaodeMapPrivacyManager.swift +26 -18
- package/ios/map/cpp/GeometryEngine.cpp +112 -0
- package/ios/map/cpp/GeometryEngine.hpp +21 -0
- package/ios/map/modules/LocationManager.swift +37 -5
- package/ios/map/overlays/MarkerView.swift +11 -11
- package/ios/map/overlays/MarkerViewModule.swift +4 -4
- package/ios/map/overlays/PolylineView.swift +6 -12
- package/ios/map/utils/ClusterNative.h +8 -0
- package/ios/map/utils/ClusterNative.mm +27 -0
- package/ios/map/utils/PermissionManager.swift +115 -6
- package/ios/routes/drive/DriveTruckRouteCalculator.swift +165 -77
- package/ios/routes/walkride/WalkRideRouteCalculator.swift +127 -1
- package/ios/services/IndependentRouteService.swift +198 -39
- package/ios/services/NavigationLiveActivityAttributes.swift +48 -0
- package/ios/services/NavigationLiveActivityManager.swift +359 -0
- package/package.json +22 -7
- package/plugin/build/withGaodeMap.d.ts +8 -0
- package/plugin/build/withGaodeMap.js +60 -4
- package/scripts/check-expo-modules.js +68 -0
- package/shared/cpp/GeometryEngine.cpp +112 -0
- package/shared/cpp/GeometryEngine.hpp +21 -0
- package/widget-template/README.md +46 -0
- package/widget-template/ios/NavigationLiveActivityWidget.swift +367 -0
- package/android/src/main/java/expo/modules/gaodemap/navigation/managers/RouteCalculator.kt +0 -173
package/android/src/main/java/expo/modules/gaodemap/navigation/ExpoGaodeMapNaviViewModule.kt
CHANGED
|
@@ -10,6 +10,18 @@ class ExpoGaodeMapNaviViewModule : Module() {
|
|
|
10
10
|
override fun definition() = ModuleDefinition {
|
|
11
11
|
Name("ExpoGaodeMapNaviView")
|
|
12
12
|
|
|
13
|
+
OnActivityEntersForeground {
|
|
14
|
+
ExpoGaodeMapNaviView.resumeActiveViews()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
OnActivityEntersBackground {
|
|
18
|
+
ExpoGaodeMapNaviView.pauseActiveViews()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
OnActivityDestroys {
|
|
22
|
+
ExpoGaodeMapNaviView.destroyActiveViews()
|
|
23
|
+
}
|
|
24
|
+
|
|
13
25
|
View(ExpoGaodeMapNaviView::class) {
|
|
14
26
|
Events(
|
|
15
27
|
"onNavigationReady",
|
|
@@ -24,7 +36,10 @@ class ExpoGaodeMapNaviViewModule : Module() {
|
|
|
24
36
|
"onWayPointArrived",
|
|
25
37
|
"onGpsStatusChanged",
|
|
26
38
|
"onNavigationInfoUpdate",
|
|
27
|
-
"onGpsSignalWeak"
|
|
39
|
+
"onGpsSignalWeak",
|
|
40
|
+
"onNavigationVisualStateUpdate",
|
|
41
|
+
"onLaneInfoUpdate",
|
|
42
|
+
"onTrafficStatusesUpdate"
|
|
28
43
|
)
|
|
29
44
|
|
|
30
45
|
OnViewDestroys { view: ExpoGaodeMapNaviView ->
|
|
@@ -39,6 +54,36 @@ class ExpoGaodeMapNaviViewModule : Module() {
|
|
|
39
54
|
Prop<Boolean>("enableVoice") { view, enabled ->
|
|
40
55
|
view.applyEnableVoice(enabled)
|
|
41
56
|
}
|
|
57
|
+
|
|
58
|
+
Prop<String?>("carImage") { view, uri ->
|
|
59
|
+
view.applyCarImage(uri)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
Prop<Map<String, Double>?>("carImageSize") { view, value ->
|
|
63
|
+
val width = value?.get("width")
|
|
64
|
+
val height = value?.get("height")
|
|
65
|
+
view.applyCarImageSize(width, height)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Prop<String?>("fourCornersImage") { view, uri ->
|
|
69
|
+
view.applyFourCornersImage(uri)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
Prop<String?>("startPointImage") { view, uri ->
|
|
73
|
+
view.applyStartPointImage(uri)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
Prop<String?>("wayPointImage") { view, uri ->
|
|
77
|
+
view.applyWayPointImage(uri)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
Prop<List<Map<String, Any?>>?>("customWaypointMarkers") { view, markers ->
|
|
81
|
+
view.applyCustomWaypointMarkers(markers)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
Prop<String?>("endPointImage") { view, uri ->
|
|
85
|
+
view.applyEndPointImage(uri)
|
|
86
|
+
}
|
|
42
87
|
|
|
43
88
|
Prop<Boolean>("autoLockCar") { view, enabled ->
|
|
44
89
|
view.applyAutoLockCar(enabled)
|
|
@@ -67,6 +112,10 @@ class ExpoGaodeMapNaviViewModule : Module() {
|
|
|
67
112
|
Prop<Boolean>("isNightMode") { view, enabled ->
|
|
68
113
|
view.applyNightMode(enabled)
|
|
69
114
|
}
|
|
115
|
+
|
|
116
|
+
Prop<Int>("mapViewModeType") { view, mode ->
|
|
117
|
+
view.applyMapViewModeType(mode)
|
|
118
|
+
}
|
|
70
119
|
|
|
71
120
|
Prop<Boolean>("carOverlayVisible") { view, visible ->
|
|
72
121
|
view.applyCarOverlayVisible(visible)
|
|
@@ -79,6 +128,10 @@ class ExpoGaodeMapNaviViewModule : Module() {
|
|
|
79
128
|
Prop<Boolean>("showCompassEnabled") {view, enabled ->
|
|
80
129
|
view.applyShowCompassEnabled(enabled)
|
|
81
130
|
}
|
|
131
|
+
|
|
132
|
+
Prop<Boolean>("naviStatusBarEnabled") { view, enabled ->
|
|
133
|
+
view.applyNaviStatusBarEnabled(enabled)
|
|
134
|
+
}
|
|
82
135
|
|
|
83
136
|
Prop<Map<String, Boolean>?>("routeMarkerVisible") { view, config ->
|
|
84
137
|
config?.let {
|
|
@@ -95,6 +148,26 @@ class ExpoGaodeMapNaviViewModule : Module() {
|
|
|
95
148
|
Prop<Boolean>("naviArrowVisible") { view, visible ->
|
|
96
149
|
view.applyNaviArrowVisible(visible)
|
|
97
150
|
}
|
|
151
|
+
|
|
152
|
+
Prop<Boolean>("laneInfoVisible") { view, visible ->
|
|
153
|
+
view.applyLaneInfoVisible(visible)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
Prop<Boolean>("modeCrossDisplay") { view, visible ->
|
|
157
|
+
view.applyModeCrossDisplay(visible)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
Prop<Boolean>("eyrieCrossDisplay") { view, visible ->
|
|
161
|
+
view.applyEyrieCrossDisplay(visible)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
Prop<Boolean>("secondActionVisible") { view, visible ->
|
|
165
|
+
view.applySecondActionVisible(visible)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
Prop<Boolean>("backupOverlayVisible") { view, visible ->
|
|
169
|
+
view.applyBackupOverlayVisible(visible)
|
|
170
|
+
}
|
|
98
171
|
|
|
99
172
|
// 是否显示拥堵气泡
|
|
100
173
|
Prop<Boolean>("showDriveCongestion") { view, show ->
|
|
@@ -115,6 +188,28 @@ class ExpoGaodeMapNaviViewModule : Module() {
|
|
|
115
188
|
view.applyAndroidStatusBarPaddingTop(topDp)
|
|
116
189
|
}
|
|
117
190
|
|
|
191
|
+
Prop<Int>("lockZoom") { view, level ->
|
|
192
|
+
view.applyLockZoom(level)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
Prop<Int>("lockTilt") { view, tilt ->
|
|
196
|
+
view.applyLockTilt(tilt)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
Prop<Boolean>("eagleMapVisible") { view, visible ->
|
|
200
|
+
view.applyEagleMapVisible(visible)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
Prop<Map<String, Double>?>("pointToCenter") { view, value ->
|
|
204
|
+
val x = value?.get("x") ?: 0.0
|
|
205
|
+
val y = value?.get("y") ?: 0.0
|
|
206
|
+
view.applyPointToCenter(x, y)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
Prop<Boolean>("hideNativeTopInfoLayout") { view, hidden ->
|
|
210
|
+
view.applyHideNativeTopInfoLayout(hidden)
|
|
211
|
+
}
|
|
212
|
+
|
|
118
213
|
Prop<Boolean>("showCamera") { view, enabled ->
|
|
119
214
|
view.applyShowCamera(enabled)
|
|
120
215
|
}
|
|
@@ -123,6 +218,14 @@ class ExpoGaodeMapNaviViewModule : Module() {
|
|
|
123
218
|
view.applyShowUIElements(visible)
|
|
124
219
|
}
|
|
125
220
|
|
|
221
|
+
Prop<Boolean>("androidBackgroundNavigationNotificationEnabled") { view, enabled ->
|
|
222
|
+
view.applyAndroidBackgroundNavigationNotificationEnabled(enabled)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// iOS-only prop, keep a no-op mapping on Android for cross-platform prop compatibility.
|
|
226
|
+
Prop<Boolean>("iosLiveActivityEnabled") { _: ExpoGaodeMapNaviView, _: Boolean ->
|
|
227
|
+
}
|
|
228
|
+
|
|
126
229
|
Prop<Boolean>("showTrafficBar") { view, enabled ->
|
|
127
230
|
view.applyAndroidTrafficBarEnabled(enabled)
|
|
128
231
|
}
|
|
@@ -147,10 +250,27 @@ class ExpoGaodeMapNaviViewModule : Module() {
|
|
|
147
250
|
AsyncFunction("startNavigation") { view: ExpoGaodeMapNaviView, startLat: Double, startLng: Double, endLat: Double, endLng: Double, promise: expo.modules.kotlin.Promise ->
|
|
148
251
|
view.startNavigation(startLat, startLng, endLat, endLng, promise)
|
|
149
252
|
}
|
|
253
|
+
|
|
254
|
+
AsyncFunction("startNavigationWithIndependentPath") { view: ExpoGaodeMapNaviView, token: Int, routeId: Int?, routeIndex: Int?, naviType: Int?, promise: expo.modules.kotlin.Promise ->
|
|
255
|
+
view.startNavigationWithIndependentPath(token, routeId, routeIndex, naviType, promise)
|
|
256
|
+
}
|
|
150
257
|
|
|
151
258
|
AsyncFunction("stopNavigation") { view: ExpoGaodeMapNaviView, promise: expo.modules.kotlin.Promise ->
|
|
152
259
|
view.stopNavigation(promise)
|
|
153
260
|
}
|
|
261
|
+
|
|
262
|
+
AsyncFunction("playCustomTTS") { view: ExpoGaodeMapNaviView, text: String, forcePlay: Boolean, promise: expo.modules.kotlin.Promise ->
|
|
263
|
+
val success = view.playCustomTTS(text, forcePlay)
|
|
264
|
+
if (success) {
|
|
265
|
+
promise.resolve(
|
|
266
|
+
mapOf(
|
|
267
|
+
"success" to true
|
|
268
|
+
)
|
|
269
|
+
)
|
|
270
|
+
} else {
|
|
271
|
+
promise.reject("PLAY_TTS_FAILED", "当前场景暂不支持或正在播报其他导航语音", null)
|
|
272
|
+
}
|
|
273
|
+
}
|
|
154
274
|
}
|
|
155
275
|
}
|
|
156
276
|
}
|
package/android/src/main/java/expo/modules/gaodemap/navigation/ExpoGaodeMapNavigationModule.kt
CHANGED
|
@@ -2,9 +2,9 @@ package expo.modules.gaodemap.navigation
|
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.content.Context
|
|
5
|
-
import com.amap.api.navi.AMapNavi
|
|
6
5
|
import com.amap.api.navi.model.AMapCarInfo
|
|
7
6
|
import com.amap.api.navi.model.AMapNaviPathGroup
|
|
7
|
+
import expo.modules.core.arguments.ReadableArguments
|
|
8
8
|
import expo.modules.kotlin.Promise
|
|
9
9
|
import expo.modules.kotlin.modules.Module
|
|
10
10
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
@@ -12,8 +12,7 @@ import expo.modules.gaodemap.map.modules.SDKInitializer
|
|
|
12
12
|
import expo.modules.gaodemap.navigation.routes.drive.DriveTruckRouteCalculator
|
|
13
13
|
import expo.modules.gaodemap.navigation.routes.walkride.WalkRideRouteCalculator
|
|
14
14
|
import expo.modules.gaodemap.navigation.routes.ebike.EbikeRouteCalculator
|
|
15
|
-
|
|
16
|
-
import expo.modules.gaodemap.navigation.utils.Converters
|
|
15
|
+
|
|
17
16
|
import expo.modules.gaodemap.navigation.managers.IndependentRouteManager
|
|
18
17
|
import expo.modules.gaodemap.navigation.services.IndependentRouteService
|
|
19
18
|
import java.util.Locale
|
|
@@ -43,7 +42,7 @@ class ExpoGaodeMapNavigationModule : Module() {
|
|
|
43
42
|
private var ebikeCalculator: EbikeRouteCalculator? = null
|
|
44
43
|
|
|
45
44
|
// 独立路径规划:在原生侧暂存路线组,委托独立管理器,避免 Module 膨胀
|
|
46
|
-
private val independentRouteManager = IndependentRouteManager
|
|
45
|
+
private val independentRouteManager = IndependentRouteManager.shared
|
|
47
46
|
private var independentRouteService: IndependentRouteService? = null
|
|
48
47
|
|
|
49
48
|
@SuppressLint("SuspiciousIndentation")
|
|
@@ -136,7 +135,7 @@ class ExpoGaodeMapNavigationModule : Module() {
|
|
|
136
135
|
// 使用 AMapNavi.independentCalculateRoute,不影响当前导航状态
|
|
137
136
|
// 委托给 IndependentRouteService 处理,避免 Module 文件臃肿
|
|
138
137
|
|
|
139
|
-
AsyncFunction("independentDriveRoute") { options:
|
|
138
|
+
AsyncFunction("independentDriveRoute") { options: ReadableArguments, promise: Promise ->
|
|
140
139
|
try {
|
|
141
140
|
ensureIndependentService().independentDriveRoute(options, promise)
|
|
142
141
|
} catch (e: Exception) {
|
|
@@ -144,7 +143,7 @@ class ExpoGaodeMapNavigationModule : Module() {
|
|
|
144
143
|
}
|
|
145
144
|
}
|
|
146
145
|
|
|
147
|
-
AsyncFunction("independentTruckRoute") { options:
|
|
146
|
+
AsyncFunction("independentTruckRoute") { options: ReadableArguments, promise: Promise ->
|
|
148
147
|
try {
|
|
149
148
|
ensureIndependentService().independentTruckRoute(options, promise)
|
|
150
149
|
} catch (e: Exception) {
|
|
@@ -152,7 +151,7 @@ class ExpoGaodeMapNavigationModule : Module() {
|
|
|
152
151
|
}
|
|
153
152
|
}
|
|
154
153
|
|
|
155
|
-
AsyncFunction("independentWalkRoute") { options:
|
|
154
|
+
AsyncFunction("independentWalkRoute") { options: ReadableArguments, promise: Promise ->
|
|
156
155
|
try {
|
|
157
156
|
ensureIndependentService().independentWalkRoute(options, promise)
|
|
158
157
|
} catch (e: Exception) {
|
|
@@ -160,7 +159,7 @@ class ExpoGaodeMapNavigationModule : Module() {
|
|
|
160
159
|
}
|
|
161
160
|
}
|
|
162
161
|
|
|
163
|
-
AsyncFunction("independentRideRoute") { options:
|
|
162
|
+
AsyncFunction("independentRideRoute") { options: ReadableArguments, promise: Promise ->
|
|
164
163
|
try {
|
|
165
164
|
ensureIndependentService().independentRideRoute(options, promise)
|
|
166
165
|
} catch (e: Exception) {
|
|
@@ -169,7 +168,7 @@ class ExpoGaodeMapNavigationModule : Module() {
|
|
|
169
168
|
}
|
|
170
169
|
|
|
171
170
|
// 独立摩托车 路线规划(与驾车一致,依赖车辆信息 carType=11)
|
|
172
|
-
AsyncFunction("independentMotorcycleRoute") { options:
|
|
171
|
+
AsyncFunction("independentMotorcycleRoute") { options: ReadableArguments, promise: Promise ->
|
|
173
172
|
try {
|
|
174
173
|
ensureIndependentService().independentMotorcycleRoute(options, promise)
|
|
175
174
|
} catch (e: Exception) {
|
|
@@ -213,8 +212,8 @@ class ExpoGaodeMapNavigationModule : Module() {
|
|
|
213
212
|
val routeId = (options["routeId"] as? Number)?.toInt()
|
|
214
213
|
val routeIndex = (options["routeIndex"] as? Number)?.toInt()
|
|
215
214
|
val naviType = (options["naviType"] as? Number)?.toInt() ?: 0
|
|
216
|
-
val
|
|
217
|
-
if (!
|
|
215
|
+
val result = independentRouteManager.start(context, token, naviType, routeId, routeIndex)
|
|
216
|
+
if (!result.success) throw Exception(result.message)
|
|
218
217
|
promise.resolve(true)
|
|
219
218
|
} catch (e: Exception) {
|
|
220
219
|
promise.reject("START_NAVI_ERROR", e.message, e)
|
|
@@ -263,26 +262,13 @@ class ExpoGaodeMapNavigationModule : Module() {
|
|
|
263
262
|
AsyncFunction("calculateMotorcycleRoute") { options: Map<String, Any?>, promise: Promise ->
|
|
264
263
|
try {
|
|
265
264
|
ensureNavigationPrivacyReady()
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
val motorcycleCC = (options["motorcycleCC"] as? Number)?.toInt()
|
|
270
|
-
val carInfo = AMapCarInfo().apply {
|
|
271
|
-
if (carNumber != null) setCarNumber(carNumber)
|
|
272
|
-
carType = "11" // 11 = 摩托车
|
|
273
|
-
if (motorcycleCC != null) {
|
|
274
|
-
try {
|
|
275
|
-
this.motorcycleCC = motorcycleCC
|
|
276
|
-
} catch (_: Exception) {}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
AMapNavi.getInstance(context).setCarInfo(carInfo)
|
|
280
|
-
} catch (_: Exception) {
|
|
281
|
-
// ignore
|
|
265
|
+
val motorcycleOptions = options.toMutableMap()
|
|
266
|
+
if (motorcycleOptions["carType"] == null) {
|
|
267
|
+
motorcycleOptions["carType"] = "11"
|
|
282
268
|
}
|
|
283
269
|
|
|
284
270
|
// 复用驾车算路逻辑(含 strategyConvert / 途经点等)
|
|
285
|
-
ensureDriveTruck().calculateDriveRoute(
|
|
271
|
+
ensureDriveTruck().calculateDriveRoute(motorcycleOptions, promise)
|
|
286
272
|
} catch (e: Exception) {
|
|
287
273
|
promise.reject("CALCULATE_ERROR", e.message, e)
|
|
288
274
|
}
|
package/android/src/main/java/expo/modules/gaodemap/navigation/listeners/IndependentRouteListener.kt
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package expo.modules.gaodemap.navigation.listeners
|
|
2
2
|
|
|
3
|
+
import android.util.Log
|
|
3
4
|
import com.amap.api.navi.AMapNaviIndependentRouteListener
|
|
4
5
|
import com.amap.api.navi.model.AMapCalcRouteResult
|
|
5
6
|
import com.amap.api.navi.model.AMapNaviPathGroup
|
|
@@ -17,6 +18,9 @@ class IndependentRouteListener(
|
|
|
17
18
|
private val module: ExpoGaodeMapNavigationModule,
|
|
18
19
|
private val promise: Promise
|
|
19
20
|
) : AMapNaviIndependentRouteListener {
|
|
21
|
+
companion object {
|
|
22
|
+
private const val TAG = "IndependentRouteListener"
|
|
23
|
+
}
|
|
20
24
|
|
|
21
25
|
override fun onIndependentCalculateSuccess(group: AMapNaviPathGroup?) {
|
|
22
26
|
try {
|
|
@@ -28,6 +32,7 @@ class IndependentRouteListener(
|
|
|
28
32
|
|
|
29
33
|
// 将路径组存储在模块内,返回一个可供后续操作(选路/启动导航/清理)的 token
|
|
30
34
|
val token = module.storeIndependentGroup(group)
|
|
35
|
+
logGroupSummary(group, token)
|
|
31
36
|
|
|
32
37
|
val result = convertGroupToResult(group).toMutableMap().apply {
|
|
33
38
|
put("token", token)
|
|
@@ -42,11 +47,30 @@ class IndependentRouteListener(
|
|
|
42
47
|
|
|
43
48
|
override fun onIndependentCalculateFail(routeResult: AMapCalcRouteResult?) {
|
|
44
49
|
val errorCode = routeResult?.errorCode ?: -1
|
|
50
|
+
Log.e(TAG, "independentCalculateRoute failed: errorCode=$errorCode result=$routeResult")
|
|
45
51
|
val errorMsg = "Independent route calculation failed with code: $errorCode"
|
|
46
52
|
promise.reject("INDEPENDENT_CALCULATE_ERROR", errorMsg, null)
|
|
47
53
|
module.sendEvent("onCalculateRouteFailure", mapOf("errorCode" to errorCode))
|
|
48
54
|
}
|
|
49
55
|
|
|
56
|
+
private fun logGroupSummary(group: AMapNaviPathGroup, token: Int) {
|
|
57
|
+
val count = try { group.pathCount } catch (_: Exception) { -1 }
|
|
58
|
+
val mainIndex = try { group.mainPathIndex } catch (_: Exception) { -1 }
|
|
59
|
+
Log.d(TAG, "independentCalculateRoute success: token=$token pathCount=$count mainPathIndex=$mainIndex")
|
|
60
|
+
|
|
61
|
+
for (index in 0 until maxOf(count, 0)) {
|
|
62
|
+
try {
|
|
63
|
+
val path = group.getPath(index)
|
|
64
|
+
Log.d(
|
|
65
|
+
TAG,
|
|
66
|
+
"path[$index]: routeId=${12 + index} length=${path.allLength} time=${path.allTime} toll=${path.tollCost} trafficLights=${path.trafficLightCount} coordCount=${path.coordList?.size ?: 0}"
|
|
67
|
+
)
|
|
68
|
+
} catch (error: Exception) {
|
|
69
|
+
Log.e(TAG, "failed to inspect path[$index]", error)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
50
74
|
/**
|
|
51
75
|
* 将 AMapNaviPathGroup 转换为轻量结构:
|
|
52
76
|
* {
|
|
@@ -67,10 +91,11 @@ class IndependentRouteListener(
|
|
|
67
91
|
for (i in 0 until count) {
|
|
68
92
|
try {
|
|
69
93
|
val path = group.getPath(i)
|
|
70
|
-
val
|
|
94
|
+
val routeId = 12 + i
|
|
95
|
+
val converted = Converters.convertNaviPath(path, routeId)
|
|
71
96
|
routes.add(converted)
|
|
72
97
|
// 文档说明:第一条为12,第二条为13,第三条为14
|
|
73
|
-
routeIds.add(
|
|
98
|
+
routeIds.add(routeId)
|
|
74
99
|
} catch (_: Exception) {
|
|
75
100
|
// 忽略单条路线转换失败,保持稳健性
|
|
76
101
|
}
|
|
@@ -84,4 +109,4 @@ class IndependentRouteListener(
|
|
|
84
109
|
"routes" to routes
|
|
85
110
|
)
|
|
86
111
|
}
|
|
87
|
-
}
|
|
112
|
+
}
|
package/android/src/main/java/expo/modules/gaodemap/navigation/listeners/RouteCalculateListener.kt
CHANGED
|
@@ -49,7 +49,7 @@ class RouteCalculateListener(
|
|
|
49
49
|
Converters.convertDriveRouteResult(navi.naviPaths)
|
|
50
50
|
} else {
|
|
51
51
|
val path = navi.naviPath
|
|
52
|
-
if (path != null) Converters.convertNaviPath(path) else mapOf<String, Any?>()
|
|
52
|
+
if (path != null) Converters.convertNaviPath(path, 12) else mapOf<String, Any?>()
|
|
53
53
|
}
|
|
54
54
|
} else {
|
|
55
55
|
Converters.convertDriveRouteResult(navi.naviPaths)
|
|
@@ -131,4 +131,4 @@ class RouteCalculateListener(
|
|
|
131
131
|
@Deprecated("Deprecated in Java")
|
|
132
132
|
override fun updateAimlessModeCongestionInfo(aimlessModeStatistics: AimLessModeCongestionInfo?) {}
|
|
133
133
|
override fun onPlayRing(ring: Int) {}
|
|
134
|
-
}
|
|
134
|
+
}
|
package/android/src/main/java/expo/modules/gaodemap/navigation/managers/IndependentRouteManager.kt
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
package expo.modules.gaodemap.navigation.managers
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
|
+
import android.util.Log
|
|
4
5
|
import com.amap.api.navi.AMapNavi
|
|
6
|
+
import com.amap.api.navi.enums.NaviType
|
|
5
7
|
import com.amap.api.navi.model.AMapNaviPathGroup
|
|
6
8
|
|
|
7
9
|
/**
|
|
@@ -11,6 +13,21 @@ import com.amap.api.navi.model.AMapNaviPathGroup
|
|
|
11
13
|
* - 提供线程安全的 token 管理
|
|
12
14
|
*/
|
|
13
15
|
class IndependentRouteManager {
|
|
16
|
+
companion object {
|
|
17
|
+
val shared: IndependentRouteManager by lazy { IndependentRouteManager() }
|
|
18
|
+
private const val TAG = "IndependentRouteManager"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
data class StartResult(
|
|
22
|
+
val success: Boolean,
|
|
23
|
+
val message: String,
|
|
24
|
+
val requestedNaviType: Int,
|
|
25
|
+
val sdkNaviType: Int,
|
|
26
|
+
val resolvedRouteId: Int?,
|
|
27
|
+
val pathCount: Int,
|
|
28
|
+
val mainPathIndex: Int
|
|
29
|
+
)
|
|
30
|
+
|
|
14
31
|
private val groups = mutableMapOf<Int, AMapNaviPathGroup>()
|
|
15
32
|
private var nextToken = 1
|
|
16
33
|
|
|
@@ -45,28 +62,110 @@ class IndependentRouteManager {
|
|
|
45
62
|
* 启动导航(可在启动前进行选路)
|
|
46
63
|
* - naviType: 0=GPS, 1=EMULATOR
|
|
47
64
|
*/
|
|
65
|
+
private fun resolveRouteId(group: AMapNaviPathGroup, routeId: Int?, routeIndex: Int?): Int? {
|
|
66
|
+
return when {
|
|
67
|
+
routeId != null -> routeId
|
|
68
|
+
routeIndex == null -> null
|
|
69
|
+
routeIndex < 0 || routeIndex >= group.pathCount -> Int.MIN_VALUE
|
|
70
|
+
else -> 12 + routeIndex
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private fun resolveSdkNaviType(requestedNaviType: Int): Int {
|
|
75
|
+
return when (requestedNaviType) {
|
|
76
|
+
1, NaviType.EMULATOR -> NaviType.EMULATOR
|
|
77
|
+
else -> NaviType.GPS
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private fun logGroupPathState(group: AMapNaviPathGroup, reason: String) {
|
|
82
|
+
val mainPath = group.mainPath
|
|
83
|
+
Log.d(
|
|
84
|
+
TAG,
|
|
85
|
+
"groupState[$reason]: pathCount=${group.pathCount} mainPathIndex=${group.mainPathIndex} mainLength=${mainPath?.allLength} mainTime=${mainPath?.allTime} labels=${mainPath?.labels} labelId=${mainPath?.labelId} waypointCount=${mainPath?.wayPoint?.size ?: 0} waypointIndexCount=${mainPath?.wayPointIndex?.size ?: 0}"
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
48
89
|
@Synchronized
|
|
49
|
-
fun start(context: Context, token: Int, naviType: Int, routeId: Int?, routeIndex: Int?):
|
|
90
|
+
fun start(context: Context, token: Int, naviType: Int, routeId: Int?, routeIndex: Int?): StartResult {
|
|
50
91
|
try {
|
|
51
92
|
val group = get(token)
|
|
52
93
|
val navi = AMapNavi.getInstance(context)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
94
|
+
logGroupPathState(group, "before-start")
|
|
95
|
+
|
|
96
|
+
val resolvedRouteId = resolveRouteId(group, routeId, routeIndex)
|
|
97
|
+
val sdkNaviType = resolveSdkNaviType(naviType)
|
|
98
|
+
Log.d(
|
|
99
|
+
TAG,
|
|
100
|
+
"startNaviWithPath request: token=$token requestedNaviType=$naviType sdkNaviType=$sdkNaviType routeId=$routeId routeIndex=$routeIndex resolvedRouteId=$resolvedRouteId pathCount=${group.pathCount} mainPathIndex=${group.mainPathIndex}"
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
if (resolvedRouteId == Int.MIN_VALUE) {
|
|
104
|
+
return StartResult(
|
|
105
|
+
success = false,
|
|
106
|
+
message = "独立路径导航启动失败:routeIndex 超出范围,当前仅有 ${group.pathCount} 条路线",
|
|
107
|
+
requestedNaviType = naviType,
|
|
108
|
+
sdkNaviType = sdkNaviType,
|
|
109
|
+
resolvedRouteId = null,
|
|
110
|
+
pathCount = group.pathCount,
|
|
111
|
+
mainPathIndex = group.mainPathIndex
|
|
112
|
+
)
|
|
59
113
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
114
|
+
|
|
115
|
+
if (resolvedRouteId != null) {
|
|
116
|
+
val selected = group.selectRouteWithIndex(resolvedRouteId)
|
|
117
|
+
Log.d(TAG, "selectRouteWithIndex($resolvedRouteId) => $selected")
|
|
118
|
+
logGroupPathState(group, "after-select")
|
|
119
|
+
if (!selected) {
|
|
120
|
+
return StartResult(
|
|
121
|
+
success = false,
|
|
122
|
+
message = "独立路径导航启动失败:路线选择失败 routeId=$resolvedRouteId",
|
|
123
|
+
requestedNaviType = naviType,
|
|
124
|
+
sdkNaviType = sdkNaviType,
|
|
125
|
+
resolvedRouteId = resolvedRouteId,
|
|
126
|
+
pathCount = group.pathCount,
|
|
127
|
+
mainPathIndex = group.mainPathIndex
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
val result = navi.startNaviWithPath(sdkNaviType, group)
|
|
63
133
|
if (!result) {
|
|
64
|
-
|
|
134
|
+
Log.e(
|
|
135
|
+
TAG,
|
|
136
|
+
"startNaviWithPath failed: token=$token requestedNaviType=$naviType sdkNaviType=$sdkNaviType routeId=$resolvedRouteId pathCount=${group.pathCount} mainPathIndex=${group.mainPathIndex}"
|
|
137
|
+
)
|
|
138
|
+
return StartResult(
|
|
139
|
+
success = false,
|
|
140
|
+
message = "独立路径导航启动失败:高德 SDK 未接受该路径组(requestedNaviType=$naviType, sdkNaviType=$sdkNaviType)",
|
|
141
|
+
requestedNaviType = naviType,
|
|
142
|
+
sdkNaviType = sdkNaviType,
|
|
143
|
+
resolvedRouteId = resolvedRouteId,
|
|
144
|
+
pathCount = group.pathCount,
|
|
145
|
+
mainPathIndex = group.mainPathIndex
|
|
146
|
+
)
|
|
65
147
|
}
|
|
66
|
-
|
|
148
|
+
|
|
149
|
+
return StartResult(
|
|
150
|
+
success = true,
|
|
151
|
+
message = "独立路径导航启动成功",
|
|
152
|
+
requestedNaviType = naviType,
|
|
153
|
+
sdkNaviType = sdkNaviType,
|
|
154
|
+
resolvedRouteId = resolvedRouteId,
|
|
155
|
+
pathCount = group.pathCount,
|
|
156
|
+
mainPathIndex = group.mainPathIndex
|
|
157
|
+
)
|
|
67
158
|
} catch (e: Exception) {
|
|
68
|
-
|
|
69
|
-
return
|
|
159
|
+
Log.e(TAG, "Start navigation failed", e)
|
|
160
|
+
return StartResult(
|
|
161
|
+
success = false,
|
|
162
|
+
message = "独立路径导航启动失败:${e.message ?: "unknown"}",
|
|
163
|
+
requestedNaviType = naviType,
|
|
164
|
+
sdkNaviType = resolveSdkNaviType(naviType),
|
|
165
|
+
resolvedRouteId = routeId,
|
|
166
|
+
pathCount = 0,
|
|
167
|
+
mainPathIndex = 0
|
|
168
|
+
)
|
|
70
169
|
}
|
|
71
170
|
}
|
|
72
171
|
|
|
@@ -80,4 +179,4 @@ class IndependentRouteManager {
|
|
|
80
179
|
groups.clear()
|
|
81
180
|
nextToken = 1
|
|
82
181
|
}
|
|
83
|
-
}
|
|
182
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package expo.modules.gaodemap.navigation.routes.drive
|
|
2
2
|
|
|
3
|
+
import android.annotation.SuppressLint
|
|
3
4
|
import android.content.Context
|
|
4
5
|
import com.amap.api.navi.AMapNavi
|
|
5
6
|
import com.amap.api.navi.model.AMapCarInfo
|
|
@@ -64,6 +65,7 @@ class DriveTruckRouteCalculator(
|
|
|
64
65
|
/**
|
|
65
66
|
* 驾车路径规划
|
|
66
67
|
*/
|
|
68
|
+
@SuppressLint("SuspiciousIndentation")
|
|
67
69
|
fun calculateDriveRoute(options: Map<String, Any?>, promise: Promise) {
|
|
68
70
|
android.util.Log.d("DriveTruckRouteCalculator", "开始计算驾车路线,初始化状态: $isInitialized")
|
|
69
71
|
|
|
@@ -121,20 +123,28 @@ class DriveTruckRouteCalculator(
|
|
|
121
123
|
}
|
|
122
124
|
}
|
|
123
125
|
|
|
124
|
-
|
|
126
|
+
val explicitCarType = when (val rawCarType = options["carType"]) {
|
|
127
|
+
is String -> rawCarType.trim().takeIf { it.isNotEmpty() }
|
|
128
|
+
is Number -> rawCarType.toInt().toString()
|
|
129
|
+
else -> null
|
|
130
|
+
}
|
|
125
131
|
val carNumber = options["carNumber"] as? String
|
|
126
132
|
val restriction = options["restriction"] as? Boolean
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
val motorcycleCC = (options["motorcycleCC"] as? Number)?.toInt()
|
|
134
|
+
try {
|
|
135
|
+
val carInfo = AMapCarInfo().apply {
|
|
136
|
+
carType = explicitCarType ?: "0"
|
|
137
|
+
if (carNumber != null) setCarNumber(carNumber)
|
|
138
|
+
if (restriction != null) isRestriction = restriction
|
|
139
|
+
if (motorcycleCC != null) {
|
|
140
|
+
try {
|
|
141
|
+
this.motorcycleCC = motorcycleCC
|
|
142
|
+
} catch (_: Exception) {}
|
|
133
143
|
}
|
|
134
|
-
aMapNavi?.setCarInfo(carInfo)
|
|
135
|
-
} catch (_: Exception) {
|
|
136
|
-
// ignore
|
|
137
144
|
}
|
|
145
|
+
aMapNavi?.setCarInfo(carInfo)
|
|
146
|
+
} catch (_: Exception) {
|
|
147
|
+
// ignore
|
|
138
148
|
}
|
|
139
149
|
|
|
140
150
|
// 标注场景与多路线期望(默认 drive;若上层已指定 scene 则尊重)
|
|
@@ -175,36 +185,15 @@ class DriveTruckRouteCalculator(
|
|
|
175
185
|
* 注意:该能力为收费接口;需要商务开通。未开通可能算路失败。
|
|
176
186
|
*/
|
|
177
187
|
fun calculateTruckRoute(options: Map<String, Any?>, promise: Promise) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
val restriction = options["restriction"] as? Boolean
|
|
182
|
-
|
|
183
|
-
val carInfo = AMapCarInfo().apply {
|
|
184
|
-
if (carNumber != null) setCarNumber(carNumber)
|
|
185
|
-
carType = "1" // 1/3/5 视为货车,这里取 1
|
|
186
|
-
if (restriction != null) isRestriction = restriction
|
|
187
|
-
|
|
188
|
-
// 可按需扩展更详细的货车参数(示例):
|
|
189
|
-
// setVehicleAxis("6")
|
|
190
|
-
// setVehicleHeight("3.5")
|
|
191
|
-
// setVehicleLength("7.3")
|
|
192
|
-
// setVehicleWidth("2.5")
|
|
193
|
-
// setVehicleSize("4")
|
|
194
|
-
// setVehicleLoad("25.99")
|
|
195
|
-
// setVehicleWeight("20")
|
|
196
|
-
// setVehicleLoadSwitch(true)
|
|
197
|
-
}
|
|
198
|
-
aMapNavi?.setCarInfo(carInfo)
|
|
199
|
-
} catch (_: Exception) {
|
|
200
|
-
// ignore
|
|
188
|
+
val truckOptions = options.toMutableMap()
|
|
189
|
+
if (truckOptions["carType"] == null) {
|
|
190
|
+
truckOptions["carType"] = "1"
|
|
201
191
|
}
|
|
202
192
|
|
|
203
|
-
// 标注场景(truck),并期望多路线
|
|
204
193
|
routeListener?.scene = "truck"
|
|
205
194
|
routeListener?.multiple = true
|
|
206
195
|
|
|
207
|
-
calculateDriveRoute(
|
|
196
|
+
calculateDriveRoute(truckOptions, promise)
|
|
208
197
|
}
|
|
209
198
|
|
|
210
199
|
fun destroy() {
|