expo-gaode-map-navigation 2.0.8 → 2.0.9
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 +233 -3
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapModule.kt +4 -2
- package/android/src/main/java/expo/modules/gaodemap/navigation/ExpoGaodeMapNaviView.kt +931 -391
- package/android/src/main/java/expo/modules/gaodemap/navigation/ExpoGaodeMapNaviViewModule.kt +86 -1
- package/android/src/main/java/expo/modules/gaodemap/navigation/ExpoGaodeMapNavigationModule.kt +4 -5
- package/android/src/main/java/expo/modules/gaodemap/navigation/listeners/IndependentRouteListener.kt +4 -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 +96 -14
- package/android/src/main/java/expo/modules/gaodemap/navigation/routes/drive/DriveTruckRouteCalculator.kt +2 -0
- package/android/src/main/java/expo/modules/gaodemap/navigation/utils/Converters.kt +19 -10
- 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/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/build/ExpoGaodeMapNaviView.d.ts +8 -0
- package/build/ExpoGaodeMapNaviView.d.ts.map +1 -1
- package/build/ExpoGaodeMapNaviView.js +38 -1
- package/build/ExpoGaodeMapNaviView.js.map +1 -1
- package/build/index.d.ts +8 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +408 -4
- package/build/index.js.map +1 -1
- package/build/types/independent.types.d.ts +91 -0
- package/build/types/independent.types.d.ts.map +1 -1
- package/build/types/independent.types.js.map +1 -1
- package/build/types/naviview.types.d.ts +256 -12
- 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 +2 -0
- package/build/types/route.types.d.ts.map +1 -1
- package/build/types/route.types.js.map +1 -1
- package/ios/ExpoGaodeMapNaviView.swift +888 -66
- package/ios/ExpoGaodeMapNaviViewModule.swift +87 -1
- package/ios/ExpoGaodeMapNavigationModule.swift +1 -1
- package/ios/managers/IndependentRouteManager.swift +1 -0
- package/ios/map/ExpoGaodeMapModule.swift +9 -4
- package/ios/map/ExpoGaodeMapView.swift +13 -2
- package/ios/map/modules/LocationManager.swift +17 -0
- package/ios/map/utils/PermissionManager.swift +11 -6
- package/ios/routes/drive/DriveTruckRouteCalculator.swift +9 -0
- package/ios/routes/walkride/WalkRideRouteCalculator.swift +30 -0
- package/ios/services/IndependentRouteService.swift +25 -0
- package/package.json +5 -2
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,26 @@ 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<String?>("fourCornersImage") { view, uri ->
|
|
63
|
+
view.applyFourCornersImage(uri)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
Prop<String?>("startPointImage") { view, uri ->
|
|
67
|
+
view.applyStartPointImage(uri)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
Prop<String?>("wayPointImage") { view, uri ->
|
|
71
|
+
view.applyWayPointImage(uri)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
Prop<String?>("endPointImage") { view, uri ->
|
|
75
|
+
view.applyEndPointImage(uri)
|
|
76
|
+
}
|
|
42
77
|
|
|
43
78
|
Prop<Boolean>("autoLockCar") { view, enabled ->
|
|
44
79
|
view.applyAutoLockCar(enabled)
|
|
@@ -79,6 +114,10 @@ class ExpoGaodeMapNaviViewModule : Module() {
|
|
|
79
114
|
Prop<Boolean>("showCompassEnabled") {view, enabled ->
|
|
80
115
|
view.applyShowCompassEnabled(enabled)
|
|
81
116
|
}
|
|
117
|
+
|
|
118
|
+
Prop<Boolean>("naviStatusBarEnabled") { view, enabled ->
|
|
119
|
+
view.applyNaviStatusBarEnabled(enabled)
|
|
120
|
+
}
|
|
82
121
|
|
|
83
122
|
Prop<Map<String, Boolean>?>("routeMarkerVisible") { view, config ->
|
|
84
123
|
config?.let {
|
|
@@ -95,6 +134,26 @@ class ExpoGaodeMapNaviViewModule : Module() {
|
|
|
95
134
|
Prop<Boolean>("naviArrowVisible") { view, visible ->
|
|
96
135
|
view.applyNaviArrowVisible(visible)
|
|
97
136
|
}
|
|
137
|
+
|
|
138
|
+
Prop<Boolean>("laneInfoVisible") { view, visible ->
|
|
139
|
+
view.applyLaneInfoVisible(visible)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
Prop<Boolean>("modeCrossDisplay") { view, visible ->
|
|
143
|
+
view.applyModeCrossDisplay(visible)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
Prop<Boolean>("eyrieCrossDisplay") { view, visible ->
|
|
147
|
+
view.applyEyrieCrossDisplay(visible)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
Prop<Boolean>("secondActionVisible") { view, visible ->
|
|
151
|
+
view.applySecondActionVisible(visible)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
Prop<Boolean>("backupOverlayVisible") { view, visible ->
|
|
155
|
+
view.applyBackupOverlayVisible(visible)
|
|
156
|
+
}
|
|
98
157
|
|
|
99
158
|
// 是否显示拥堵气泡
|
|
100
159
|
Prop<Boolean>("showDriveCongestion") { view, show ->
|
|
@@ -115,6 +174,28 @@ class ExpoGaodeMapNaviViewModule : Module() {
|
|
|
115
174
|
view.applyAndroidStatusBarPaddingTop(topDp)
|
|
116
175
|
}
|
|
117
176
|
|
|
177
|
+
Prop<Int>("lockZoom") { view, level ->
|
|
178
|
+
view.applyLockZoom(level)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
Prop<Int>("lockTilt") { view, tilt ->
|
|
182
|
+
view.applyLockTilt(tilt)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
Prop<Boolean>("eagleMapVisible") { view, visible ->
|
|
186
|
+
view.applyEagleMapVisible(visible)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
Prop<Map<String, Double>?>("pointToCenter") { view, value ->
|
|
190
|
+
val x = value?.get("x") ?: 0.0
|
|
191
|
+
val y = value?.get("y") ?: 0.0
|
|
192
|
+
view.applyPointToCenter(x, y)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
Prop<Boolean>("hideNativeTopInfoLayout") { view, hidden ->
|
|
196
|
+
view.applyHideNativeTopInfoLayout(hidden)
|
|
197
|
+
}
|
|
198
|
+
|
|
118
199
|
Prop<Boolean>("showCamera") { view, enabled ->
|
|
119
200
|
view.applyShowCamera(enabled)
|
|
120
201
|
}
|
|
@@ -147,6 +228,10 @@ class ExpoGaodeMapNaviViewModule : Module() {
|
|
|
147
228
|
AsyncFunction("startNavigation") { view: ExpoGaodeMapNaviView, startLat: Double, startLng: Double, endLat: Double, endLng: Double, promise: expo.modules.kotlin.Promise ->
|
|
148
229
|
view.startNavigation(startLat, startLng, endLat, endLng, promise)
|
|
149
230
|
}
|
|
231
|
+
|
|
232
|
+
AsyncFunction("startNavigationWithIndependentPath") { view: ExpoGaodeMapNaviView, token: Int, routeId: Int?, routeIndex: Int?, naviType: Int?, promise: expo.modules.kotlin.Promise ->
|
|
233
|
+
view.startNavigationWithIndependentPath(token, routeId, routeIndex, naviType, promise)
|
|
234
|
+
}
|
|
150
235
|
|
|
151
236
|
AsyncFunction("stopNavigation") { view: ExpoGaodeMapNaviView, promise: expo.modules.kotlin.Promise ->
|
|
152
237
|
view.stopNavigation(promise)
|
package/android/src/main/java/expo/modules/gaodemap/navigation/ExpoGaodeMapNavigationModule.kt
CHANGED
|
@@ -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")
|
|
@@ -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)
|
package/android/src/main/java/expo/modules/gaodemap/navigation/listeners/IndependentRouteListener.kt
CHANGED
|
@@ -67,10 +67,11 @@ class IndependentRouteListener(
|
|
|
67
67
|
for (i in 0 until count) {
|
|
68
68
|
try {
|
|
69
69
|
val path = group.getPath(i)
|
|
70
|
-
val
|
|
70
|
+
val routeId = 12 + i
|
|
71
|
+
val converted = Converters.convertNaviPath(path, routeId)
|
|
71
72
|
routes.add(converted)
|
|
72
73
|
// 文档说明:第一条为12,第二条为13,第三条为14
|
|
73
|
-
routeIds.add(
|
|
74
|
+
routeIds.add(routeId)
|
|
74
75
|
} catch (_: Exception) {
|
|
75
76
|
// 忽略单条路线转换失败,保持稳健性
|
|
76
77
|
}
|
|
@@ -84,4 +85,4 @@ class IndependentRouteListener(
|
|
|
84
85
|
"routes" to routes
|
|
85
86
|
)
|
|
86
87
|
}
|
|
87
|
-
}
|
|
88
|
+
}
|
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
|
@@ -2,6 +2,7 @@ package expo.modules.gaodemap.navigation.managers
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import com.amap.api.navi.AMapNavi
|
|
5
|
+
import com.amap.api.navi.enums.NaviType
|
|
5
6
|
import com.amap.api.navi.model.AMapNaviPathGroup
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -11,6 +12,20 @@ import com.amap.api.navi.model.AMapNaviPathGroup
|
|
|
11
12
|
* - 提供线程安全的 token 管理
|
|
12
13
|
*/
|
|
13
14
|
class IndependentRouteManager {
|
|
15
|
+
data class StartResult(
|
|
16
|
+
val success: Boolean,
|
|
17
|
+
val message: String,
|
|
18
|
+
val requestedNaviType: Int,
|
|
19
|
+
val sdkNaviType: Int,
|
|
20
|
+
val resolvedRouteId: Int?,
|
|
21
|
+
val pathCount: Int,
|
|
22
|
+
val mainPathIndex: Int
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
companion object {
|
|
26
|
+
val shared: IndependentRouteManager by lazy { IndependentRouteManager() }
|
|
27
|
+
}
|
|
28
|
+
|
|
14
29
|
private val groups = mutableMapOf<Int, AMapNaviPathGroup>()
|
|
15
30
|
private var nextToken = 1
|
|
16
31
|
|
|
@@ -45,28 +60,95 @@ class IndependentRouteManager {
|
|
|
45
60
|
* 启动导航(可在启动前进行选路)
|
|
46
61
|
* - naviType: 0=GPS, 1=EMULATOR
|
|
47
62
|
*/
|
|
63
|
+
private fun resolveRouteId(group: AMapNaviPathGroup, routeId: Int?, routeIndex: Int?): Int? {
|
|
64
|
+
return when {
|
|
65
|
+
routeId != null -> routeId
|
|
66
|
+
routeIndex == null -> null
|
|
67
|
+
routeIndex < 0 || routeIndex >= group.pathCount -> Int.MIN_VALUE
|
|
68
|
+
else -> 12 + routeIndex
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private fun resolveSdkNaviType(requestedNaviType: Int): Int {
|
|
73
|
+
return when (requestedNaviType) {
|
|
74
|
+
1, NaviType.EMULATOR -> NaviType.EMULATOR
|
|
75
|
+
else -> NaviType.GPS
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
48
79
|
@Synchronized
|
|
49
|
-
fun start(context: Context, token: Int, naviType: Int, routeId: Int?, routeIndex: Int?):
|
|
80
|
+
fun start(context: Context, token: Int, naviType: Int, routeId: Int?, routeIndex: Int?): StartResult {
|
|
50
81
|
try {
|
|
51
82
|
val group = get(token)
|
|
52
83
|
val navi = AMapNavi.getInstance(context)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
84
|
+
|
|
85
|
+
val resolvedRouteId = resolveRouteId(group, routeId, routeIndex)
|
|
86
|
+
val sdkNaviType = resolveSdkNaviType(naviType)
|
|
87
|
+
|
|
88
|
+
if (resolvedRouteId == Int.MIN_VALUE) {
|
|
89
|
+
return StartResult(
|
|
90
|
+
success = false,
|
|
91
|
+
message = "独立路径导航启动失败:routeIndex 超出范围,当前仅有 ${group.pathCount} 条路线",
|
|
92
|
+
requestedNaviType = naviType,
|
|
93
|
+
sdkNaviType = sdkNaviType,
|
|
94
|
+
resolvedRouteId = null,
|
|
95
|
+
pathCount = group.pathCount,
|
|
96
|
+
mainPathIndex = group.mainPathIndex
|
|
97
|
+
)
|
|
59
98
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
99
|
+
|
|
100
|
+
if (resolvedRouteId != null) {
|
|
101
|
+
val selected = group.selectRouteWithIndex(resolvedRouteId)
|
|
102
|
+
if (!selected) {
|
|
103
|
+
return StartResult(
|
|
104
|
+
success = false,
|
|
105
|
+
message = "独立路径导航启动失败:路线选择失败 routeId=$resolvedRouteId",
|
|
106
|
+
requestedNaviType = naviType,
|
|
107
|
+
sdkNaviType = sdkNaviType,
|
|
108
|
+
resolvedRouteId = resolvedRouteId,
|
|
109
|
+
pathCount = group.pathCount,
|
|
110
|
+
mainPathIndex = group.mainPathIndex
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
val result = navi.startNaviWithPath(sdkNaviType, group)
|
|
63
116
|
if (!result) {
|
|
64
|
-
android.util.Log.e(
|
|
117
|
+
android.util.Log.e(
|
|
118
|
+
"IndependentRouteManager",
|
|
119
|
+
"startNaviWithPath failed: token=$token requestedNaviType=$naviType sdkNaviType=$sdkNaviType routeId=$resolvedRouteId pathCount=${group.pathCount} mainPathIndex=${group.mainPathIndex}"
|
|
120
|
+
)
|
|
121
|
+
return StartResult(
|
|
122
|
+
success = false,
|
|
123
|
+
message = "独立路径导航启动失败:高德 SDK 未接受该路径组(requestedNaviType=$naviType, sdkNaviType=$sdkNaviType)",
|
|
124
|
+
requestedNaviType = naviType,
|
|
125
|
+
sdkNaviType = sdkNaviType,
|
|
126
|
+
resolvedRouteId = resolvedRouteId,
|
|
127
|
+
pathCount = group.pathCount,
|
|
128
|
+
mainPathIndex = group.mainPathIndex
|
|
129
|
+
)
|
|
65
130
|
}
|
|
66
|
-
|
|
131
|
+
|
|
132
|
+
return StartResult(
|
|
133
|
+
success = true,
|
|
134
|
+
message = "独立路径导航启动成功",
|
|
135
|
+
requestedNaviType = naviType,
|
|
136
|
+
sdkNaviType = sdkNaviType,
|
|
137
|
+
resolvedRouteId = resolvedRouteId,
|
|
138
|
+
pathCount = group.pathCount,
|
|
139
|
+
mainPathIndex = group.mainPathIndex
|
|
140
|
+
)
|
|
67
141
|
} catch (e: Exception) {
|
|
68
142
|
android.util.Log.e("IndependentRouteManager", "Start navigation failed", e)
|
|
69
|
-
return
|
|
143
|
+
return StartResult(
|
|
144
|
+
success = false,
|
|
145
|
+
message = "独立路径导航启动失败:${e.message ?: "unknown"}",
|
|
146
|
+
requestedNaviType = naviType,
|
|
147
|
+
sdkNaviType = resolveSdkNaviType(naviType),
|
|
148
|
+
resolvedRouteId = routeId,
|
|
149
|
+
pathCount = 0,
|
|
150
|
+
mainPathIndex = 0
|
|
151
|
+
)
|
|
70
152
|
}
|
|
71
153
|
}
|
|
72
154
|
|
|
@@ -80,4 +162,4 @@ class IndependentRouteManager {
|
|
|
80
162
|
groups.clear()
|
|
81
163
|
nextToken = 1
|
|
82
164
|
}
|
|
83
|
-
}
|
|
165
|
+
}
|
|
@@ -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
|
|
|
@@ -78,19 +78,22 @@ object Converters {
|
|
|
78
78
|
*/
|
|
79
79
|
fun convertNaviPathInfo(path: AMapNaviPath): Map<String, Any?> {
|
|
80
80
|
return mapOf(
|
|
81
|
+
"naviMode" to 0,
|
|
81
82
|
"currentRoadName" to "",
|
|
82
83
|
"nextRoadName" to "",
|
|
83
|
-
"
|
|
84
|
-
"
|
|
84
|
+
"curStepRetainDistance" to 0,
|
|
85
|
+
"curStepRetainTime" to 0,
|
|
85
86
|
"pathRetainDistance" to path.allLength,
|
|
86
87
|
"pathRetainTime" to path.allTime,
|
|
87
88
|
"currentSpeed" to 0,
|
|
88
|
-
"iconSpeed" to 0,
|
|
89
89
|
"iconType" to 0,
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
90
|
+
"iconDirection" to 0,
|
|
91
|
+
"currentSegmentIndex" to 0,
|
|
92
|
+
"currentLinkIndex" to 0,
|
|
93
|
+
"currentPointIndex" to 0,
|
|
94
|
+
"routeRemainTrafficLightCount" to 0,
|
|
95
|
+
"driveDistance" to 0,
|
|
96
|
+
"driveTime" to 0
|
|
94
97
|
)
|
|
95
98
|
}
|
|
96
99
|
|
|
@@ -126,8 +129,8 @@ object Converters {
|
|
|
126
129
|
/**
|
|
127
130
|
* 转换路径结果(只使用确实存在的属性)
|
|
128
131
|
*/
|
|
129
|
-
fun convertNaviPath(path: AMapNaviPath): Map<String, Any?> {
|
|
130
|
-
|
|
132
|
+
fun convertNaviPath(path: AMapNaviPath, routeId: Int? = null): Map<String, Any?> {
|
|
133
|
+
val payload = mutableMapOf<String, Any?>(
|
|
131
134
|
"distance" to path.allLength,
|
|
132
135
|
"duration" to path.allTime,
|
|
133
136
|
"tollDistance" to 0,
|
|
@@ -136,13 +139,18 @@ object Converters {
|
|
|
136
139
|
"steps" to convertSteps(path.steps),
|
|
137
140
|
"polyline" to convertCoords(path.coordList)
|
|
138
141
|
)
|
|
142
|
+
if (routeId != null) {
|
|
143
|
+
payload["id"] = routeId
|
|
144
|
+
payload["routeId"] = routeId
|
|
145
|
+
}
|
|
146
|
+
return payload
|
|
139
147
|
}
|
|
140
148
|
|
|
141
149
|
/**
|
|
142
150
|
* 转换驾车路径结果
|
|
143
151
|
*/
|
|
144
152
|
fun convertDriveRouteResult(paths: Map<Int, AMapNaviPath>?): Map<String, Any?> {
|
|
145
|
-
val routes = paths?.
|
|
153
|
+
val routes = paths?.entries?.map { (id, path) -> convertNaviPath(path, id) } ?: emptyList()
|
|
146
154
|
|
|
147
155
|
return mapOf(
|
|
148
156
|
"routes" to routes,
|
|
@@ -156,6 +164,7 @@ object Converters {
|
|
|
156
164
|
fun convertMultiRouteInfo(paths: Map<Int, AMapNaviPath>?): List<Map<String, Any?>> {
|
|
157
165
|
return paths?.entries?.map { (id, path) ->
|
|
158
166
|
mapOf(
|
|
167
|
+
"id" to id,
|
|
159
168
|
"routeId" to id,
|
|
160
169
|
"distance" to path.allLength,
|
|
161
170
|
"duration" to path.allTime,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|