expo-gaode-map-navigation 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +3 -0
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapModule.kt +45 -49
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapView.kt +5 -15
- package/android/src/main/java/expo/modules/gaodemap/map/modules/SDKInitializer.kt +143 -14
- package/build/ExpoGaodeMapNaviView.d.ts.map +1 -1
- package/build/ExpoGaodeMapNaviView.js +3 -2
- package/build/ExpoGaodeMapNaviView.js.map +1 -1
- package/build/ExpoGaodeMapNavigationModule.d.ts +2 -7
- package/build/ExpoGaodeMapNavigationModule.d.ts.map +1 -1
- package/build/ExpoGaodeMapNavigationModule.js +19 -2
- package/build/ExpoGaodeMapNavigationModule.js.map +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +8 -2
- package/build/index.js.map +1 -1
- package/build/map/ExpoGaodeMapModule.d.ts +245 -4
- package/build/map/ExpoGaodeMapModule.d.ts.map +1 -1
- package/build/map/ExpoGaodeMapModule.js +197 -15
- package/build/map/ExpoGaodeMapModule.js.map +1 -1
- package/build/map/ExpoGaodeMapOfflineModule.d.ts.map +1 -1
- package/build/map/ExpoGaodeMapOfflineModule.js +19 -2
- package/build/map/ExpoGaodeMapOfflineModule.js.map +1 -1
- package/build/map/ExpoGaodeMapView.d.ts.map +1 -1
- package/build/map/ExpoGaodeMapView.js +8 -2
- package/build/map/ExpoGaodeMapView.js.map +1 -1
- package/build/map/components/overlays/Circle.d.ts.map +1 -1
- package/build/map/components/overlays/Circle.js +3 -2
- package/build/map/components/overlays/Circle.js.map +1 -1
- package/build/map/components/overlays/Cluster.d.ts.map +1 -1
- package/build/map/components/overlays/Cluster.js +3 -2
- package/build/map/components/overlays/Cluster.js.map +1 -1
- package/build/map/components/overlays/HeatMap.d.ts.map +1 -1
- package/build/map/components/overlays/HeatMap.js +3 -2
- package/build/map/components/overlays/HeatMap.js.map +1 -1
- package/build/map/components/overlays/Marker.d.ts.map +1 -1
- package/build/map/components/overlays/Marker.js +3 -2
- package/build/map/components/overlays/Marker.js.map +1 -1
- package/build/map/components/overlays/MultiPoint.d.ts.map +1 -1
- package/build/map/components/overlays/MultiPoint.js +3 -2
- package/build/map/components/overlays/MultiPoint.js.map +1 -1
- package/build/map/components/overlays/Polygon.d.ts.map +1 -1
- package/build/map/components/overlays/Polygon.js +3 -2
- package/build/map/components/overlays/Polygon.js.map +1 -1
- package/build/map/components/overlays/Polyline.d.ts.map +1 -1
- package/build/map/components/overlays/Polyline.js +3 -2
- package/build/map/components/overlays/Polyline.js.map +1 -1
- package/build/map/types/common.types.d.ts +26 -0
- package/build/map/types/common.types.d.ts.map +1 -1
- package/build/map/types/common.types.js.map +1 -1
- package/build/map/types/native-module.types.d.ts +28 -1
- package/build/map/types/native-module.types.d.ts.map +1 -1
- package/build/map/types/native-module.types.js.map +1 -1
- package/build/map/utils/ErrorHandler.d.ts +6 -0
- package/build/map/utils/ErrorHandler.d.ts.map +1 -1
- package/build/map/utils/ErrorHandler.js +42 -0
- package/build/map/utils/ErrorHandler.js.map +1 -1
- package/build/map/utils/GeoUtils.d.ts.map +1 -1
- package/build/map/utils/GeoUtils.js +6 -2
- package/build/map/utils/GeoUtils.js.map +1 -1
- package/build/map/utils/lazyNativeViewManager.d.ts +3 -0
- package/build/map/utils/lazyNativeViewManager.d.ts.map +1 -0
- package/build/map/utils/lazyNativeViewManager.js +11 -0
- package/build/map/utils/lazyNativeViewManager.js.map +1 -0
- package/ios/ExpoGaodeMapNavigation.podspec +5 -0
- package/ios/map/ExpoGaodeMapModule.swift +27 -40
- package/ios/map/ExpoGaodeMapView.swift +160 -77
- package/ios/map/GaodeMapPrivacyManager.swift +155 -0
- package/ios/map/modules/LocationManager.swift +43 -24
- package/package.json +1 -1
- package/android/src/main/java/expo/modules/gaodemap/map/MapPreloadManager.kt +0 -494
- package/ios/map/MapPreloadManager.swift +0 -348
package/android/build.gradle
CHANGED
|
@@ -27,6 +27,9 @@ if (useManagedAndroidSdkVersions) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
logger.warn("[expo-gaode-map-navigation] Thank you for using expo-gaode-map-navigation ❤️")
|
|
31
|
+
logger.warn("[expo-gaode-map-navigation] If you enjoy using expo-gaode-map-navigation, please consider sponsoring this project: https://github.com/TomWq")
|
|
32
|
+
|
|
30
33
|
android {
|
|
31
34
|
namespace "expo.modules.gaodemap.navigation"
|
|
32
35
|
defaultConfig {
|
|
@@ -30,42 +30,12 @@ class ExpoGaodeMapModule : Module() {
|
|
|
30
30
|
override fun definition() = ModuleDefinition {
|
|
31
31
|
Name("ExpoGaodeMap")
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// 初始化预加载管理器(注册内存监听)
|
|
39
|
-
MapPreloadManager.initialize(context)
|
|
40
|
-
|
|
41
|
-
// 尝试从 AndroidManifest.xml 读取并设置 API Key
|
|
42
|
-
val apiKey = context.packageManager
|
|
43
|
-
.getApplicationInfo(context.packageName, android.content.pm.PackageManager.GET_META_DATA)
|
|
44
|
-
.metaData?.getString("com.amap.api.v2.apikey")
|
|
45
|
-
|
|
46
|
-
if (!apiKey.isNullOrEmpty()) {
|
|
47
|
-
try {
|
|
48
|
-
MapsInitializer.setApiKey(apiKey)
|
|
49
|
-
com.amap.api.location.AMapLocationClient.setApiKey(apiKey)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// 只有在 API Key 已设置的情况下才启动预加载
|
|
53
|
-
android.os.Handler(android.os.Looper.getMainLooper()).postDelayed({
|
|
54
|
-
android.util.Log.i("ExpoGaodeMap", "🚀 自动启动地图预加载")
|
|
55
|
-
MapPreloadManager.startPreload(context, poolSize = 1)
|
|
56
|
-
}, 2000)
|
|
57
|
-
} catch (e: Exception) {
|
|
58
|
-
android.util.Log.w("ExpoGaodeMap", "设置 API Key 失败: ${e.message}")
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
android.util.Log.w("ExpoGaodeMap", "⚠️ AndroidManifest.xml 未找到 API Key,跳过自动预加载")
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
} catch (e: Exception) {
|
|
65
|
-
android.util.Log.w("ExpoGaodeMap", "恢复隐私状态时出现问题: ${e.message}")
|
|
33
|
+
OnCreate {
|
|
34
|
+
appContext.reactContext?.let { context ->
|
|
35
|
+
SDKInitializer.restorePersistedState(context)
|
|
36
|
+
}
|
|
66
37
|
}
|
|
67
|
-
|
|
68
|
-
|
|
38
|
+
|
|
69
39
|
// ==================== SDK 初始化 ====================
|
|
70
40
|
|
|
71
41
|
/**
|
|
@@ -74,23 +44,50 @@ class ExpoGaodeMapModule : Module() {
|
|
|
74
44
|
*/
|
|
75
45
|
Function("initSDK") { config: Map<String, String> ->
|
|
76
46
|
val androidKey = config["androidKey"]
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
throw expo.modules.kotlin.exception.CodedException("INIT_FAILED", e.message ?: "SDK 初始化失败", e)
|
|
47
|
+
try {
|
|
48
|
+
val context = appContext.reactContext!!
|
|
49
|
+
if (androidKey != null) {
|
|
50
|
+
SDKInitializer.initSDK(context, androidKey)
|
|
51
|
+
} else if (!SDKInitializer.isPrivacyReady()) {
|
|
52
|
+
throw expo.modules.kotlin.exception.CodedException(
|
|
53
|
+
"PRIVACY_NOT_AGREED",
|
|
54
|
+
"隐私协议未完成确认,请先调用 setPrivacyShow/setPrivacyAgree",
|
|
55
|
+
null
|
|
56
|
+
)
|
|
57
|
+
} else {
|
|
58
|
+
SDKInitializer.applyPrivacyState(context)
|
|
90
59
|
}
|
|
60
|
+
|
|
61
|
+
getLocationManager()
|
|
62
|
+
} catch (e: SecurityException) {
|
|
63
|
+
android.util.Log.e("ExpoGaodeMap", "隐私协议未同意: ${e.message}")
|
|
64
|
+
throw expo.modules.kotlin.exception.CodedException("PRIVACY_NOT_AGREED", e.message ?: "用户未同意隐私协议", e)
|
|
65
|
+
} catch (e: Exception) {
|
|
66
|
+
android.util.Log.e("ExpoGaodeMap", "SDK 初始化失败: ${e.message}")
|
|
67
|
+
throw expo.modules.kotlin.exception.CodedException("INIT_FAILED", e.message ?: "SDK 初始化失败", e)
|
|
91
68
|
}
|
|
92
69
|
}
|
|
93
70
|
|
|
71
|
+
Function("setPrivacyShow") { hasShow: Boolean, hasContainsPrivacy: Boolean ->
|
|
72
|
+
SDKInitializer.setPrivacyShow(appContext.reactContext!!, hasShow, hasContainsPrivacy)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Function("setPrivacyAgree") { hasAgree: Boolean ->
|
|
76
|
+
SDKInitializer.setPrivacyAgree(appContext.reactContext!!, hasAgree)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
Function("setPrivacyVersion") { version: String ->
|
|
80
|
+
SDKInitializer.setPrivacyVersion(appContext.reactContext!!, version)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
Function("resetPrivacyConsent") {
|
|
84
|
+
SDKInitializer.resetPrivacyConsent(appContext.reactContext!!)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
Function("getPrivacyStatus") {
|
|
88
|
+
SDKInitializer.getPrivacyStatus()
|
|
89
|
+
}
|
|
90
|
+
|
|
94
91
|
/**
|
|
95
92
|
* 设置是否加载世界向量地图
|
|
96
93
|
* @param enable 是否开启
|
|
@@ -890,7 +887,6 @@ class ExpoGaodeMapModule : Module() {
|
|
|
890
887
|
OnDestroy {
|
|
891
888
|
locationManager?.destroy()
|
|
892
889
|
locationManager = null
|
|
893
|
-
MapPreloadManager.cleanup()
|
|
894
890
|
}
|
|
895
891
|
}
|
|
896
892
|
|
|
@@ -13,6 +13,7 @@ import expo.modules.kotlin.viewevent.EventDispatcher
|
|
|
13
13
|
import expo.modules.kotlin.views.ExpoView
|
|
14
14
|
import expo.modules.gaodemap.map.managers.CameraManager
|
|
15
15
|
import expo.modules.gaodemap.map.managers.UIManager
|
|
16
|
+
import expo.modules.gaodemap.map.modules.SDKInitializer
|
|
16
17
|
import expo.modules.gaodemap.map.overlays.*
|
|
17
18
|
import androidx.core.graphics.createBitmap
|
|
18
19
|
import androidx.core.view.isVisible
|
|
@@ -93,22 +94,11 @@ class ExpoGaodeMapView(context: Context, appContext: AppContext) : ExpoView(cont
|
|
|
93
94
|
|
|
94
95
|
init {
|
|
95
96
|
try {
|
|
96
|
-
|
|
97
|
-
MapsInitializer.updatePrivacyShow(context, true, true)
|
|
98
|
-
MapsInitializer.updatePrivacyAgree(context, true)
|
|
97
|
+
SDKInitializer.applyPrivacyState(context)
|
|
99
98
|
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (preloadedMapView != null) {
|
|
104
|
-
mapView = preloadedMapView
|
|
105
|
-
android.util.Log.i("ExpoGaodeMapView", "🚀 使用预加载的 MapView 实例")
|
|
106
|
-
} else {
|
|
107
|
-
// 创建地图视图
|
|
108
|
-
mapView = MapView(context)
|
|
109
|
-
mapView.onCreate(null)
|
|
110
|
-
android.util.Log.i("ExpoGaodeMapView", "⚠️ 创建新的 MapView 实例 (未命中预加载池)")
|
|
111
|
-
}
|
|
99
|
+
// 直接创建地图视图
|
|
100
|
+
mapView = MapView(context)
|
|
101
|
+
mapView.onCreate(null)
|
|
112
102
|
|
|
113
103
|
aMap = mapView.map
|
|
114
104
|
|
|
@@ -14,24 +14,115 @@ import com.amap.api.maps.MapsInitializer
|
|
|
14
14
|
* - 获取 SDK 版本信息
|
|
15
15
|
*/
|
|
16
16
|
object SDKInitializer {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
private
|
|
17
|
+
private const val PREFS_NAME = "expo_gaodemap_privacy"
|
|
18
|
+
private const val KEY_PRIVACY_SHOWN = "privacy_shown"
|
|
19
|
+
private const val KEY_PRIVACY_CONTAINS = "privacy_contains"
|
|
20
|
+
private const val KEY_PRIVACY_AGREED = "privacy_agreed"
|
|
21
|
+
private const val KEY_PRIVACY_VERSION = "privacy_version"
|
|
22
|
+
private const val KEY_AGREED_PRIVACY_VERSION = "agreed_privacy_version"
|
|
20
23
|
|
|
24
|
+
private var privacyAgreed = false
|
|
25
|
+
private var privacyShown = false
|
|
26
|
+
private var privacyContains = false
|
|
27
|
+
private var privacyVersion: String? = null
|
|
28
|
+
private var agreedPrivacyVersion: String? = null
|
|
29
|
+
private var restoredFromStorage = false
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
|
|
31
|
+
private fun resolveContext(context: Context): Context {
|
|
32
|
+
return context.applicationContext ?: context
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private fun prefs(context: Context) =
|
|
36
|
+
resolveContext(context).getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
|
37
|
+
|
|
38
|
+
fun restorePersistedState(context: Context) {
|
|
39
|
+
val appContext = resolveContext(context)
|
|
40
|
+
val preferences = prefs(appContext)
|
|
41
|
+
|
|
42
|
+
privacyShown = preferences.getBoolean(KEY_PRIVACY_SHOWN, false)
|
|
43
|
+
privacyContains = preferences.getBoolean(KEY_PRIVACY_CONTAINS, false)
|
|
44
|
+
privacyAgreed = preferences.getBoolean(KEY_PRIVACY_AGREED, false)
|
|
45
|
+
privacyVersion = preferences.getString(KEY_PRIVACY_VERSION, null)
|
|
46
|
+
agreedPrivacyVersion = preferences.getString(KEY_AGREED_PRIVACY_VERSION, null)
|
|
47
|
+
restoredFromStorage = true
|
|
48
|
+
|
|
49
|
+
if (!privacyVersion.isNullOrEmpty() &&
|
|
50
|
+
!agreedPrivacyVersion.isNullOrEmpty() &&
|
|
51
|
+
privacyVersion != agreedPrivacyVersion
|
|
52
|
+
) {
|
|
53
|
+
clearConsentPersistedState(appContext, keepCurrentVersion = true)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
applyPrivacyState(appContext)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
fun setPrivacyShow(context: Context, hasShow: Boolean, hasContainsPrivacy: Boolean) {
|
|
60
|
+
privacyShown = hasShow
|
|
61
|
+
privacyContains = hasContainsPrivacy
|
|
62
|
+
val appContext = resolveContext(context)
|
|
63
|
+
persistState(appContext)
|
|
64
|
+
applyPrivacyState(appContext)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
fun setPrivacyAgree(context: Context, hasAgree: Boolean) {
|
|
68
|
+
privacyAgreed = hasAgree
|
|
69
|
+
agreedPrivacyVersion = if (hasAgree) privacyVersion else null
|
|
70
|
+
val appContext = resolveContext(context)
|
|
71
|
+
persistState(appContext)
|
|
72
|
+
applyPrivacyState(appContext)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
fun setPrivacyVersion(context: Context, version: String) {
|
|
76
|
+
val sanitizedVersion = version.trim().takeIf { it.isNotEmpty() }
|
|
77
|
+
privacyVersion = sanitizedVersion
|
|
78
|
+
|
|
79
|
+
val appContext = resolveContext(context)
|
|
80
|
+
if (!privacyVersion.isNullOrEmpty() &&
|
|
81
|
+
!agreedPrivacyVersion.isNullOrEmpty() &&
|
|
82
|
+
privacyVersion != agreedPrivacyVersion
|
|
83
|
+
) {
|
|
84
|
+
clearConsentPersistedState(appContext, keepCurrentVersion = true)
|
|
85
|
+
} else {
|
|
86
|
+
persistState(appContext)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
applyPrivacyState(appContext)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
fun resetPrivacyConsent(context: Context) {
|
|
93
|
+
val appContext = resolveContext(context)
|
|
94
|
+
clearConsentPersistedState(appContext, keepCurrentVersion = false)
|
|
95
|
+
applyPrivacyState(appContext)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
fun applyPrivacyState(context: Context) {
|
|
99
|
+
val appContext = resolveContext(context)
|
|
24
100
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
AMapLocationClient.updatePrivacyAgree(context, privacyAgreed)
|
|
101
|
+
MapsInitializer.updatePrivacyShow(appContext, privacyShown, privacyContains)
|
|
102
|
+
AMapLocationClient.updatePrivacyShow(appContext, privacyShown, privacyContains)
|
|
103
|
+
MapsInitializer.updatePrivacyAgree(appContext, privacyAgreed)
|
|
104
|
+
AMapLocationClient.updatePrivacyAgree(appContext, privacyAgreed)
|
|
30
105
|
} catch (e: Exception) {
|
|
31
|
-
android.util.Log.w("ExpoGaodeMap", "
|
|
106
|
+
android.util.Log.w("ExpoGaodeMap", "同步隐私状态失败: ${e.message}")
|
|
32
107
|
}
|
|
33
108
|
}
|
|
34
109
|
|
|
110
|
+
fun isPrivacyReady(): Boolean {
|
|
111
|
+
return privacyShown && privacyContains && privacyAgreed
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
fun getPrivacyStatus(): Map<String, Any?> {
|
|
115
|
+
return mapOf(
|
|
116
|
+
"hasShow" to privacyShown,
|
|
117
|
+
"hasContainsPrivacy" to privacyContains,
|
|
118
|
+
"hasAgree" to privacyAgreed,
|
|
119
|
+
"isReady" to isPrivacyReady(),
|
|
120
|
+
"privacyVersion" to privacyVersion,
|
|
121
|
+
"agreedPrivacyVersion" to agreedPrivacyVersion,
|
|
122
|
+
"restoredFromStorage" to restoredFromStorage,
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
|
|
35
126
|
/**
|
|
36
127
|
* 初始化高德地图和定位 SDK
|
|
37
128
|
*
|
|
@@ -40,13 +131,19 @@ object SDKInitializer {
|
|
|
40
131
|
* @throws Exception 初始化失败时抛出异常
|
|
41
132
|
*/
|
|
42
133
|
fun initSDK(context: Context, androidKey: String) {
|
|
134
|
+
val appContext = resolveContext(context)
|
|
135
|
+
restorePersistedState(appContext)
|
|
43
136
|
// 检查隐私协议状态
|
|
44
|
-
if (!
|
|
45
|
-
|
|
46
|
-
|
|
137
|
+
if (!isPrivacyReady()) {
|
|
138
|
+
throw expo.modules.kotlin.exception.CodedException(
|
|
139
|
+
"PRIVACY_NOT_AGREED",
|
|
140
|
+
"隐私协议未完成确认,请先调用 setPrivacyShow/setPrivacyAgree",
|
|
141
|
+
null
|
|
142
|
+
)
|
|
47
143
|
}
|
|
48
144
|
|
|
49
145
|
try {
|
|
146
|
+
applyPrivacyState(appContext)
|
|
50
147
|
// 设置 API Key
|
|
51
148
|
MapsInitializer.setApiKey(androidKey)
|
|
52
149
|
AMapLocationClient.setApiKey(androidKey)
|
|
@@ -65,4 +162,36 @@ object SDKInitializer {
|
|
|
65
162
|
fun getVersion(): String {
|
|
66
163
|
return MapsInitializer.getVersion()
|
|
67
164
|
}
|
|
165
|
+
|
|
166
|
+
private fun persistState(context: Context) {
|
|
167
|
+
prefs(context).edit()
|
|
168
|
+
.putBoolean(KEY_PRIVACY_SHOWN, privacyShown)
|
|
169
|
+
.putBoolean(KEY_PRIVACY_CONTAINS, privacyContains)
|
|
170
|
+
.putBoolean(KEY_PRIVACY_AGREED, privacyAgreed)
|
|
171
|
+
.putString(KEY_PRIVACY_VERSION, privacyVersion)
|
|
172
|
+
.putString(KEY_AGREED_PRIVACY_VERSION, agreedPrivacyVersion)
|
|
173
|
+
.apply()
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
private fun clearConsentPersistedState(context: Context, keepCurrentVersion: Boolean) {
|
|
177
|
+
privacyShown = false
|
|
178
|
+
privacyContains = false
|
|
179
|
+
privacyAgreed = false
|
|
180
|
+
agreedPrivacyVersion = null
|
|
181
|
+
|
|
182
|
+
val editor = prefs(context).edit()
|
|
183
|
+
.putBoolean(KEY_PRIVACY_SHOWN, false)
|
|
184
|
+
.putBoolean(KEY_PRIVACY_CONTAINS, false)
|
|
185
|
+
.putBoolean(KEY_PRIVACY_AGREED, false)
|
|
186
|
+
.remove(KEY_AGREED_PRIVACY_VERSION)
|
|
187
|
+
|
|
188
|
+
if (keepCurrentVersion) {
|
|
189
|
+
editor.putString(KEY_PRIVACY_VERSION, privacyVersion)
|
|
190
|
+
} else {
|
|
191
|
+
privacyVersion = null
|
|
192
|
+
editor.remove(KEY_PRIVACY_VERSION)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
editor.apply()
|
|
196
|
+
}
|
|
68
197
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoGaodeMapNaviView.d.ts","sourceRoot":"","sources":["../src/ExpoGaodeMapNaviView.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExpoGaodeMapNaviView.d.ts","sourceRoot":"","sources":["../src/ExpoGaodeMapNaviView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAGtE;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,eAAe,EAAE,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9F;;OAEG;IACH,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC;AAgBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,oBAAoB,2GAyB/B,CAAC;AAIH,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { requireNativeViewManager } from 'expo-modules-core';
|
|
2
1
|
import * as React from 'react';
|
|
3
|
-
|
|
2
|
+
import { createLazyNativeViewManager } from './map/utils/lazyNativeViewManager';
|
|
3
|
+
const getNativeView = createLazyNativeViewManager('ExpoGaodeMapNaviView');
|
|
4
4
|
/**
|
|
5
5
|
* 高德导航视图组件
|
|
6
6
|
*
|
|
@@ -36,6 +36,7 @@ const NativeView = requireNativeViewManager('ExpoGaodeMapNaviView');
|
|
|
36
36
|
*/
|
|
37
37
|
export const ExpoGaodeMapNaviView = React.forwardRef((props, ref) => {
|
|
38
38
|
const nativeRef = React.useRef(null);
|
|
39
|
+
const NativeView = React.useMemo(() => getNativeView(), []);
|
|
39
40
|
// 创建 API 引用
|
|
40
41
|
const apiRef = React.useMemo(() => ({
|
|
41
42
|
startNavigation: async (start, end, type) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoGaodeMapNaviView.js","sourceRoot":"","sources":["../src/ExpoGaodeMapNaviView.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExpoGaodeMapNaviView.js","sourceRoot":"","sources":["../src/ExpoGaodeMapNaviView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AA2BhF,MAAM,aAAa,GAAG,2BAA2B,CAE/C,sBAAsB,CAAC,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC,UAAU,CAAqD,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACtH,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAuC,IAAI,CAAC,CAAC;IAC3E,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC;IAE5D,YAAY;IACZ,MAAM,MAAM,GAA4B,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC3D,eAAe,EAAE,KAAK,EAAE,KAAyB,EAAE,GAAgB,EAAE,IAAY,EAAE,EAAE;YACnF,IAAI,CAAC,SAAS,CAAC,OAAO;gBAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;YAChF,oBAAoB;YACpB,MAAM,QAAQ,GAAG,KAAK,EAAE,QAAQ,IAAI,CAAC,CAAC;YACtC,MAAM,QAAQ,GAAG,KAAK,EAAE,SAAS,IAAI,CAAC,CAAC;YACvC,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC;YAC5B,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,CAAC;YAC7B,OAAO,SAAS,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/E,CAAC;QACD,cAAc,EAAE,KAAK,IAAI,EAAE;YACzB,IAAI,CAAC,SAAS,CAAC,OAAO;gBAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;YAChF,OAAO,SAAS,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAC5C,CAAC;KACF,CAAC,EAAE,EAAE,CAAC,CAAC;IAER,iBAAiB;IACjB,KAAK,CAAC,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEvD,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AACnD,CAAC,CAAC,CAAC;AAEH,oBAAoB,CAAC,WAAW,GAAG,sBAAsB,CAAC;AAE1D,eAAe,oBAAoB,CAAC","sourcesContent":["import * as React from 'react';\nimport type { Coordinates, ExpoGaodeMapNaviViewProps } from './types';\nimport { createLazyNativeViewManager } from './map/utils/lazyNativeViewManager';\n\n/**\n * ExpoGaodeMapNaviView Ref 类型\n */\nexport interface ExpoGaodeMapNaviViewRef {\n /**\n * 开始导航\n */\n startNavigation: (start: Coordinates | null, end: Coordinates, type: number) => Promise<void>;\n \n /**\n * 停止导航\n */\n stopNavigation: () => Promise<void>;\n}\n\ninterface NativeExpoGaodeMapNaviViewRef {\n startNavigation: (\n startLatitude: number,\n startLongitude: number,\n endLatitude: number,\n endLongitude: number\n ) => Promise<void>;\n stopNavigation: () => Promise<void>;\n}\n\nconst getNativeView = createLazyNativeViewManager<\n ExpoGaodeMapNaviViewProps & { ref?: React.Ref<NativeExpoGaodeMapNaviViewRef> }\n>('ExpoGaodeMapNaviView');\n\n/**\n * 高德导航视图组件\n *\n * 使用高德官方的导航界面,提供完整的导航体验,包括:\n * - 路线规划和显示\n * - 实时导航信息(距离、时间、道路名称)\n * - 转向箭头和提示\n * - 路况信息\n * - 摄像头提示\n * - 语音播报\n *\n * @example\n * ```tsx\n * import { ExpoGaodeMapNaviView } from 'expo-gaode-map-navigation';\n *\n * function NavigationScreen() {\n * return (\n * <ExpoGaodeMapNaviView\n * style={{ flex: 1 }}\n * naviType={0} // GPS 导航\n * showCamera={true}\n * enableVoice={true}\n * onNaviInfoUpdate={(e) => {\n * console.log('剩余距离:', e.nativeEvent.pathRetainDistance);\n * }}\n * onArrive={() => {\n * console.log('到达目的地!');\n * }}\n * />\n * );\n * }\n * ```\n */\nexport const ExpoGaodeMapNaviView = React.forwardRef<ExpoGaodeMapNaviViewRef, ExpoGaodeMapNaviViewProps>((props, ref) => {\n const nativeRef = React.useRef<NativeExpoGaodeMapNaviViewRef | null>(null);\n const NativeView = React.useMemo(() => getNativeView(), []);\n \n // 创建 API 引用\n const apiRef: ExpoGaodeMapNaviViewRef = React.useMemo(() => ({\n startNavigation: async (start: Coordinates | null, end: Coordinates, type: number) => {\n if (!nativeRef.current) throw new Error('ExpoGaodeMapNaviView not initialized');\n // 将对象解构为单独的参数传递给原生层\n const startLat = start?.latitude ?? 0;\n const startLng = start?.longitude ?? 0;\n const endLat = end.latitude;\n const endLng = end.longitude;\n return nativeRef.current.startNavigation(startLat, startLng, endLat, endLng);\n },\n stopNavigation: async () => {\n if (!nativeRef.current) throw new Error('ExpoGaodeMapNaviView not initialized');\n return nativeRef.current.stopNavigation();\n },\n }), []);\n \n // 暴露 API 给外部 ref\n React.useImperativeHandle(ref, () => apiRef, [apiRef]);\n \n return <NativeView ref={nativeRef} {...props} />;\n});\n\nExpoGaodeMapNaviView.displayName = 'ExpoGaodeMapNaviView';\n\nexport default ExpoGaodeMapNaviView;\n"]}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { ExpoGaodeMapNavigationModule as ExpoGaodeMapNavigationModuleType } from './types/native-module.types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* 提供路径规划功能,包括驾车、步行、骑行、公交、货车等多种出行方式
|
|
6
|
-
*/
|
|
7
|
-
declare const ExpoGaodeMapNavigationModule: ExpoGaodeMapNavigationModuleType;
|
|
8
|
-
export default ExpoGaodeMapNavigationModule;
|
|
2
|
+
declare const _default: ExpoGaodeMapNavigationModuleType;
|
|
3
|
+
export default _default;
|
|
9
4
|
//# sourceMappingURL=ExpoGaodeMapNavigationModule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoGaodeMapNavigationModule.d.ts","sourceRoot":"","sources":["../src/ExpoGaodeMapNavigationModule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,IAAI,gCAAgC,EAAE,MAAM,6BAA6B,CAAC
|
|
1
|
+
{"version":3,"file":"ExpoGaodeMapNavigationModule.d.ts","sourceRoot":"","sources":["../src/ExpoGaodeMapNavigationModule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,IAAI,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;;AA2B/G,wBAIG"}
|
|
@@ -4,6 +4,23 @@ import { requireNativeModule } from 'expo-modules-core';
|
|
|
4
4
|
*
|
|
5
5
|
* 提供路径规划功能,包括驾车、步行、骑行、公交、货车等多种出行方式
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
let nativeModuleCache = null;
|
|
8
|
+
function getNativeModule() {
|
|
9
|
+
if (!nativeModuleCache) {
|
|
10
|
+
nativeModuleCache = requireNativeModule('ExpoGaodeMapNavigation');
|
|
11
|
+
}
|
|
12
|
+
return nativeModuleCache;
|
|
13
|
+
}
|
|
14
|
+
function getBoundNativeValue(module, prop) {
|
|
15
|
+
const value = Reflect.get(module, prop, module);
|
|
16
|
+
if (typeof value === 'function') {
|
|
17
|
+
return (...args) => value.apply(module, args);
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
export default new Proxy({}, {
|
|
22
|
+
get(_target, prop) {
|
|
23
|
+
return getBoundNativeValue(getNativeModule(), prop);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
9
26
|
//# sourceMappingURL=ExpoGaodeMapNavigationModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoGaodeMapNavigationModule.js","sourceRoot":"","sources":["../src/ExpoGaodeMapNavigationModule.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;GAIG;AACH,
|
|
1
|
+
{"version":3,"file":"ExpoGaodeMapNavigationModule.js","sourceRoot":"","sources":["../src/ExpoGaodeMapNavigationModule.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;GAIG;AACH,IAAI,iBAAiB,GAA4C,IAAI,CAAC;AAEtE,SAAS,eAAe;IACtB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,iBAAiB,GAAG,mBAAmB,CAAmC,wBAAwB,CAAC,CAAC;IACtG,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,SAAS,mBAAmB,CAC1B,MAAwC,EACxC,IAAiB;IAEjB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAgB,EAAE,IAAI,EAAE,MAAgB,CAAC,CAAC;IACpE,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,IAAe,EAAE,EAAE,CAC3B,KAA2C,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,eAAe,IAAI,KAAK,CAAC,EAAsC,EAAE;IAC/D,GAAG,CAAC,OAAO,EAAE,IAAI;QACf,OAAO,mBAAmB,CAAC,eAAe,EAAE,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;CACF,CAAC,CAAC","sourcesContent":["\nimport { requireNativeModule } from 'expo-modules-core';\nimport { ExpoGaodeMapNavigationModule as ExpoGaodeMapNavigationModuleType } from './types/native-module.types';\n/**\n * 高德地图导航模块\n * \n * 提供路径规划功能,包括驾车、步行、骑行、公交、货车等多种出行方式\n */\nlet nativeModuleCache: ExpoGaodeMapNavigationModuleType | null = null;\n\nfunction getNativeModule(): ExpoGaodeMapNavigationModuleType {\n if (!nativeModuleCache) {\n nativeModuleCache = requireNativeModule<ExpoGaodeMapNavigationModuleType>('ExpoGaodeMapNavigation');\n }\n return nativeModuleCache;\n}\n\nfunction getBoundNativeValue(\n module: ExpoGaodeMapNavigationModuleType,\n prop: PropertyKey\n): unknown {\n const value = Reflect.get(module as object, prop, module as object);\n if (typeof value === 'function') {\n return (...args: unknown[]) =>\n (value as (...fnArgs: unknown[]) => unknown).apply(module, args);\n }\n return value;\n}\n\nexport default new Proxy({} as ExpoGaodeMapNavigationModuleType, {\n get(_target, prop) {\n return getBoundNativeValue(getNativeModule(), prop);\n },\n});\n"]}
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,MAAM,gCAAgC,CAAC;AAG1E,cAAc,OAAO,CAAC;AACtB,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,cAAc,EACf,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACV,SA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EF,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,cAAc,GACf,CAAC;;;;;mCAtG2C,iBAAiB;kCAMlB,gBAAgB;kCAMhB,gBAAgB;mCAMf,iBAAiB;mCAMjB,iBAAiB;wCAMZ,sBAAsB;qCAMzB,4BAA4B;qCAG5B,4BAA4B;oCAG7B,2BAA2B;oCAG3B,2BAA2B;0CAMrB,iCAAiC;sCAMrC,6BAA6B;4CAMvB,mCAAmC;qCAM1C,4BAA4B;;AAoC3E,wBAyBE;AAEF,OAAO,EACL,4BAA4B,GAC7B,CAAA"}
|
package/build/index.js
CHANGED
|
@@ -2,6 +2,12 @@ import ExpoGaodeMapNavigationModule from './ExpoGaodeMapNavigationModule';
|
|
|
2
2
|
// 重新导出地图模块的所有内容
|
|
3
3
|
export * from './map';
|
|
4
4
|
import { RouteType, DriveStrategy, WalkStrategy, RideStrategy, TruckSize, TravelStrategy, } from './types';
|
|
5
|
+
function hasStrategyOption(options) {
|
|
6
|
+
return 'strategy' in options;
|
|
7
|
+
}
|
|
8
|
+
function isMotorcycleRouteOptions(options) {
|
|
9
|
+
return 'motorcycleCC' in options;
|
|
10
|
+
}
|
|
5
11
|
// 导出官方导航界面组件
|
|
6
12
|
export { ExpoGaodeMapNaviView,
|
|
7
13
|
// 兼容旧版本名称
|
|
@@ -29,14 +35,14 @@ export async function calculateRoute(options) {
|
|
|
29
35
|
if ('usePoi' in options)
|
|
30
36
|
return calculateEBikeRoute(options);
|
|
31
37
|
// 策略判断:0 或 1 通常为骑行策略,其余默认步行
|
|
32
|
-
const strategy = options.strategy;
|
|
38
|
+
const strategy = hasStrategyOption(options) ? options.strategy : undefined;
|
|
33
39
|
if (strategy === 0 || strategy === 1) {
|
|
34
40
|
return calculateRideRoute(options);
|
|
35
41
|
}
|
|
36
42
|
return calculateWalkRoute(options);
|
|
37
43
|
}
|
|
38
44
|
// 3. 摩托车 (通过 carType 或 motorcycleCC 判断)
|
|
39
|
-
if (
|
|
45
|
+
if (isMotorcycleRouteOptions(options)) {
|
|
40
46
|
return calculateMotorcycleRoute(options);
|
|
41
47
|
}
|
|
42
48
|
// 4. 默认驾车
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,MAAM,gCAAgC,CAAC;AAE1E,gBAAgB;AAChB,cAAc,OAAO,CAAC;AACtB,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,cAAc,GACf,MAAM,SAAS,CAAC;AAuBjB,aAAa;AACb,OAAO,EACL,oBAAoB;AAEpB,UAAU;AACV,oBAAoB,IAAI,QAAQ,EAEjC,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,4BAA4B,CAAC,cAAc,EAAE,CAAC;AAElF;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE,CAAC,4BAA4B,CAAC,qBAAqB,EAAE,CAAC;AAEhG;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAqB;IAErB,QAAQ;IACR,IAAI,MAAM,IAAI,OAAO,EAAE,CAAC;QACtB,OAAO,mBAAmB,CAAC,OAA4B,CAAC,CAAC;IAC3D,CAAC;IAED,eAAe;IACf,IAAI,UAAU,IAAI,OAAO,IAAI,gBAAgB,IAAI,OAAO,EAAE,CAAC;QACzD,IAAI,QAAQ,IAAI,OAAO;YAAE,OAAO,mBAAmB,CAAC,OAA4B,CAAC,CAAC;QAElF,4BAA4B;QAC5B,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,MAAM,gCAAgC,CAAC;AAE1E,gBAAgB;AAChB,cAAc,OAAO,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'./ExpoGaodeMapNavigationModule';\n\n// 重新导出地图模块的所有内容\nexport * from './map';\nimport {\n RouteType,\n DriveStrategy,\n WalkStrategy,\n RideStrategy,\n TruckSize,\n TravelStrategy,\n} from './types';\nimport type {\n NaviPoint,\n RouteOptions,\n DriveRouteOptions,\n WalkRouteOptions,\n RideRouteOptions,\n EBikeRouteOptions,\n TruckRouteOptions,\n RouteResult,\n DriveRouteResult,\n IndependentRouteResult,\n IndependentDriveRouteOptions,\n IndependentTruckRouteOptions,\n IndependentWalkRouteOptions,\n IndependentRideRouteOptions,\n SelectIndependentRouteOptions,\n StartNaviWithIndependentPathOptions,\n ClearIndependentRouteOptions,\n MotorcycleRouteOptions,\n IndependentMotorcycleRouteOptions,\n} from './types';\n\nfunction hasStrategyOption(\n options: RouteOptions\n): options is WalkRouteOptions | RideRouteOptions {\n return 'strategy' in options;\n}\n\nfunction isMotorcycleRouteOptions(\n options: RouteOptions | MotorcycleRouteOptions\n): options is MotorcycleRouteOptions {\n return 'motorcycleCC' in options;\n}\n\n// 导出官方导航界面组件\nexport { \n ExpoGaodeMapNaviView, \n type ExpoGaodeMapNaviViewRef,\n // 兼容旧版本名称\n ExpoGaodeMapNaviView as NaviView,\n type ExpoGaodeMapNaviViewRef as NaviViewRef \n} from './ExpoGaodeMapNaviView';\n\n/**\n * 初始化导航模块(可选)\n */\nexport const initNavigation = () => ExpoGaodeMapNavigationModule.initNavigation();\n\n/**\n * 销毁所有路径计算器实例\n * 用于页面切换时释放资源,避免\"Another route calculation is in progress\"错误\n */\nexport const destroyAllCalculators = () => ExpoGaodeMapNavigationModule.destroyAllCalculators();\n\n/**\n * 路径规划(通用方法)\n * 注意:公交路径规划暂未实现\n */\nexport async function calculateRoute(\n options: RouteOptions\n): Promise<RouteResult | DriveRouteResult> {\n // 1. 货车\n if ('size' in options) {\n return calculateTruckRoute(options as TruckRouteOptions);\n }\n \n // 2. 步行、骑行、电动车\n if ('multiple' in options || 'travelStrategy' in options) {\n if ('usePoi' in options) return calculateEBikeRoute(options as EBikeRouteOptions);\n \n // 策略判断:0 或 1 通常为骑行策略,其余默认步行\n const strategy = hasStrategyOption(options) ? options.strategy : undefined;\n if (strategy === 0 || strategy === 1) {\n return calculateRideRoute(options as RideRouteOptions);\n }\n return calculateWalkRoute(options as WalkRouteOptions);\n }\n\n // 3. 摩托车 (通过 carType 或 motorcycleCC 判断)\n if (isMotorcycleRouteOptions(options)) {\n return calculateMotorcycleRoute(options as MotorcycleRouteOptions);\n }\n\n // 4. 默认驾车\n return calculateDriveRoute(options as DriveRouteOptions);\n}\n\n/**\n * 驾车路径规划\n */\nexport const calculateDriveRoute = (options: DriveRouteOptions) => \n ExpoGaodeMapNavigationModule.calculateDriveRoute(options);\n\n/**\n * 步行路径规划\n */\nexport const calculateWalkRoute = (options: WalkRouteOptions) => \n ExpoGaodeMapNavigationModule.calculateWalkRoute(options);\n\n/**\n * 骑行路径规划\n */\nexport const calculateRideRoute = (options: RideRouteOptions) => \n ExpoGaodeMapNavigationModule.calculateRideRoute(options);\n\n/**\n * 骑行电动车路径规划\n */\nexport const calculateEBikeRoute = (options: EBikeRouteOptions) => \n ExpoGaodeMapNavigationModule.calculateEBikeRoute(options);\n\n/**\n * 货车路径规划\n */\nexport const calculateTruckRoute = (options: TruckRouteOptions) => \n ExpoGaodeMapNavigationModule.calculateTruckRoute(options);\n\n/**\n * 摩托车路径规划(车类型为 11,支持传入排量)\n */\nexport const calculateMotorcycleRoute = (options: MotorcycleRouteOptions) => \n ExpoGaodeMapNavigationModule.calculateMotorcycleRoute(options);\n\n/**\n* 独立路径规划(不会影响当前导航;适合路线预览/行前选路)\n*/\nexport const independentDriveRoute = (options: IndependentDriveRouteOptions) => \n ExpoGaodeMapNavigationModule.independentDriveRoute(options);\n\nexport const independentTruckRoute = (options: IndependentTruckRouteOptions) => \n ExpoGaodeMapNavigationModule.independentTruckRoute(options);\n\nexport const independentWalkRoute = (options: IndependentWalkRouteOptions) => \n ExpoGaodeMapNavigationModule.independentWalkRoute(options);\n\nexport const independentRideRoute = (options: IndependentRideRouteOptions) => \n ExpoGaodeMapNavigationModule.independentRideRoute(options);\n\n/**\n * 独立摩托车路径规划(不干扰当前导航)\n */\nexport const independentMotorcycleRoute = (options: IndependentMotorcycleRouteOptions) => \n ExpoGaodeMapNavigationModule.independentMotorcycleRoute(options);\n\n/**\n * 独立路径组:选主路线\n */\nexport const selectIndependentRoute = (options: SelectIndependentRouteOptions) => \n ExpoGaodeMapNavigationModule.selectIndependentRoute(options);\n\n/**\n * 独立路径组:使用指定路线启动导航\n */\nexport const startNaviWithIndependentPath = (options: StartNaviWithIndependentPathOptions) => \n ExpoGaodeMapNavigationModule.startNaviWithIndependentPath(options);\n\n/**\n * 独立路径组:清理\n */\nexport const clearIndependentRoute = (options: ClearIndependentRouteOptions) => \n ExpoGaodeMapNavigationModule.clearIndependentRoute(options);\n\n// 导出导航相关类型与枚举(Coordinates 从 map 模块导出)\nexport type {\n NaviPoint,\n RouteOptions,\n DriveRouteOptions,\n WalkRouteOptions,\n RideRouteOptions,\n EBikeRouteOptions,\n TruckRouteOptions,\n RouteResult,\n DriveRouteResult,\n IndependentRouteResult,\n IndependentDriveRouteOptions,\n IndependentTruckRouteOptions,\n IndependentWalkRouteOptions,\n IndependentRideRouteOptions,\n SelectIndependentRouteOptions,\n StartNaviWithIndependentPathOptions,\n ClearIndependentRouteOptions,\n MotorcycleRouteOptions,\n IndependentMotorcycleRouteOptions,\n};\n\nexport {\n RouteType,\n DriveStrategy,\n WalkStrategy,\n RideStrategy,\n TruckSize,\n TravelStrategy,\n};\n\n// 精简后的默认导出\nexport default {\n // 初始化\n initNavigation,\n destroyAllCalculators,\n\n // 路径规划\n calculateRoute,\n calculateDriveRoute,\n calculateWalkRoute,\n calculateRideRoute,\n calculateEBikeRoute,\n calculateTruckRoute,\n calculateMotorcycleRoute,\n\n // 独立路径规划\n independentDriveRoute,\n independentTruckRoute,\n independentWalkRoute,\n independentRideRoute,\n independentMotorcycleRoute,\n\n // 独立路径组操作\n selectIndependentRoute,\n startNaviWithIndependentPath,\n clearIndependentRoute,\n};\n\nexport {\n ExpoGaodeMapNavigationModule,\n}\n"]}
|