expo-gaode-map-navigation 2.0.4-next.0 → 2.1.0-next.0

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.
Files changed (39) hide show
  1. package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapModule.kt +14 -0
  2. package/android/src/main/java/expo/modules/gaodemap/map/modules/SDKInitializer.kt +107 -5
  3. package/build/ExpoGaodeMapNaviView.d.ts.map +1 -1
  4. package/build/ExpoGaodeMapNaviView.js.map +1 -1
  5. package/build/ExpoGaodeMapNavigationModule.d.ts.map +1 -1
  6. package/build/ExpoGaodeMapNavigationModule.js +8 -1
  7. package/build/ExpoGaodeMapNavigationModule.js.map +1 -1
  8. package/build/index.d.ts.map +1 -1
  9. package/build/index.js +8 -2
  10. package/build/index.js.map +1 -1
  11. package/build/map/ExpoGaodeMapModule.d.ts +231 -4
  12. package/build/map/ExpoGaodeMapModule.d.ts.map +1 -1
  13. package/build/map/ExpoGaodeMapModule.js +28 -3
  14. package/build/map/ExpoGaodeMapModule.js.map +1 -1
  15. package/build/map/ExpoGaodeMapOfflineModule.d.ts.map +1 -1
  16. package/build/map/ExpoGaodeMapOfflineModule.js +8 -1
  17. package/build/map/ExpoGaodeMapOfflineModule.js.map +1 -1
  18. package/build/map/components/overlays/HeatMap.d.ts.map +1 -1
  19. package/build/map/components/overlays/HeatMap.js.map +1 -1
  20. package/build/map/components/overlays/Marker.d.ts.map +1 -1
  21. package/build/map/components/overlays/Marker.js.map +1 -1
  22. package/build/map/types/common.types.d.ts +3 -0
  23. package/build/map/types/common.types.d.ts.map +1 -1
  24. package/build/map/types/common.types.js.map +1 -1
  25. package/build/map/types/native-module.types.d.ts +2 -0
  26. package/build/map/types/native-module.types.d.ts.map +1 -1
  27. package/build/map/types/native-module.types.js.map +1 -1
  28. package/build/map/utils/ErrorHandler.d.ts.map +1 -1
  29. package/build/map/utils/ErrorHandler.js +8 -0
  30. package/build/map/utils/ErrorHandler.js.map +1 -1
  31. package/build/map/utils/GeoUtils.d.ts.map +1 -1
  32. package/build/map/utils/GeoUtils.js +6 -2
  33. package/build/map/utils/GeoUtils.js.map +1 -1
  34. package/build/map/utils/lazyNativeViewManager.d.ts +1 -1
  35. package/build/map/utils/lazyNativeViewManager.d.ts.map +1 -1
  36. package/build/map/utils/lazyNativeViewManager.js.map +1 -1
  37. package/ios/map/ExpoGaodeMapModule.swift +10 -1
  38. package/ios/map/GaodeMapPrivacyManager.swift +92 -2
  39. package/package.json +1 -1
@@ -30,6 +30,12 @@ class ExpoGaodeMapModule : Module() {
30
30
  override fun definition() = ModuleDefinition {
31
31
  Name("ExpoGaodeMap")
32
32
 
33
+ OnCreate {
34
+ appContext.reactContext?.let { context ->
35
+ SDKInitializer.restorePersistedState(context)
36
+ }
37
+ }
38
+
33
39
  // ==================== SDK 初始化 ====================
34
40
 
35
41
  /**
@@ -70,6 +76,14 @@ class ExpoGaodeMapModule : Module() {
70
76
  SDKInitializer.setPrivacyAgree(appContext.reactContext!!, hasAgree)
71
77
  }
72
78
 
79
+ Function("setPrivacyVersion") { version: String ->
80
+ SDKInitializer.setPrivacyVersion(appContext.reactContext!!, version)
81
+ }
82
+
83
+ Function("resetPrivacyConsent") {
84
+ SDKInitializer.resetPrivacyConsent(appContext.reactContext!!)
85
+ }
86
+
73
87
  Function("getPrivacyStatus") {
74
88
  SDKInitializer.getPrivacyStatus()
75
89
  }
@@ -14,23 +14,85 @@ import com.amap.api.maps.MapsInitializer
14
14
  * - 获取 SDK 版本信息
15
15
  */
16
16
  object SDKInitializer {
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"
23
+
17
24
  private var privacyAgreed = false
18
25
  private var privacyShown = false
19
26
  private var privacyContains = false
27
+ private var privacyVersion: String? = null
28
+ private var agreedPrivacyVersion: String? = null
29
+ private var restoredFromStorage = false
20
30
 
21
31
  private fun resolveContext(context: Context): Context {
22
32
  return context.applicationContext ?: context
23
33
  }
24
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
+
25
59
  fun setPrivacyShow(context: Context, hasShow: Boolean, hasContainsPrivacy: Boolean) {
26
60
  privacyShown = hasShow
27
61
  privacyContains = hasContainsPrivacy
28
- applyPrivacyState(resolveContext(context))
62
+ val appContext = resolveContext(context)
63
+ persistState(appContext)
64
+ applyPrivacyState(appContext)
29
65
  }
30
66
 
31
67
  fun setPrivacyAgree(context: Context, hasAgree: Boolean) {
32
68
  privacyAgreed = hasAgree
33
- applyPrivacyState(resolveContext(context))
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)
34
96
  }
35
97
 
36
98
  fun applyPrivacyState(context: Context) {
@@ -49,12 +111,15 @@ object SDKInitializer {
49
111
  return privacyShown && privacyContains && privacyAgreed
50
112
  }
51
113
 
52
- fun getPrivacyStatus(): Map<String, Boolean> {
114
+ fun getPrivacyStatus(): Map<String, Any?> {
53
115
  return mapOf(
54
116
  "hasShow" to privacyShown,
55
117
  "hasContainsPrivacy" to privacyContains,
56
118
  "hasAgree" to privacyAgreed,
57
- "isReady" to isPrivacyReady()
119
+ "isReady" to isPrivacyReady(),
120
+ "privacyVersion" to privacyVersion,
121
+ "agreedPrivacyVersion" to agreedPrivacyVersion,
122
+ "restoredFromStorage" to restoredFromStorage,
58
123
  )
59
124
  }
60
125
 
@@ -67,9 +132,14 @@ object SDKInitializer {
67
132
  */
68
133
  fun initSDK(context: Context, androidKey: String) {
69
134
  val appContext = resolveContext(context)
135
+ restorePersistedState(appContext)
70
136
  // 检查隐私协议状态
71
137
  if (!isPrivacyReady()) {
72
- throw expo.modules.kotlin.exception.CodedException("隐私协议未完成确认,请先调用 setPrivacyShow/setPrivacyAgree")
138
+ throw expo.modules.kotlin.exception.CodedException(
139
+ "PRIVACY_NOT_AGREED",
140
+ "隐私协议未完成确认,请先调用 setPrivacyShow/setPrivacyAgree",
141
+ null
142
+ )
73
143
  }
74
144
 
75
145
  try {
@@ -92,4 +162,36 @@ object SDKInitializer {
92
162
  fun getVersion(): String {
93
163
  return MapsInitializer.getVersion()
94
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
+ }
95
197
  }
@@ -1 +1 @@
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;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,oBAAoB,2GAyB/B,CAAC;AAIH,eAAe,oBAAoB,CAAC"}
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 +1 @@
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;AAkBhF,MAAM,aAAa,GAAG,2BAA2B,CAAuD,sBAAsB,CAAC,CAAC;AAEhI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC,UAAU,CAAqD,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACt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AAC;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\n\nconst getNativeView = createLazyNativeViewManager<ExpoGaodeMapNaviViewProps & { ref?: React.Ref<any> }>('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<any>(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
+ {"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 +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;;AAe/G,wBAIG"}
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"}
@@ -11,9 +11,16 @@ function getNativeModule() {
11
11
  }
12
12
  return nativeModuleCache;
13
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
+ }
14
21
  export default new Proxy({}, {
15
22
  get(_target, prop) {
16
- return Reflect.get(getNativeModule(), prop);
23
+ return getBoundNativeValue(getNativeModule(), prop);
17
24
  },
18
25
  });
19
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,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,eAAe,IAAI,KAAK,CAAC,EAAsC,EAAE;IAC/D,GAAG,CAAC,OAAO,EAAE,IAAI;QACf,OAAO,OAAO,CAAC,GAAG,CAAC,eAAe,EAAY,EAAE,IAAI,CAAC,CAAC;IACxD,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\nexport default new Proxy({} as ExpoGaodeMapNavigationModuleType, {\n get(_target, prop) {\n return Reflect.get(getNativeModule() as object, prop);\n },\n});\n"]}
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"]}
@@ -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,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,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oCACd,CAAC;AAE9D,eAAO,MAAM,oBAAoB,GAAI,SAAS,2BAA2B,oCACb,CAAC;AAE7D,eAAO,MAAM,oBAAoB,GAAI,SAAS,2BAA2B,oCACb,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,0BAA0B,GAAI,SAAS,iCAAiC,oCACnB,CAAC;AAEnE;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAI,SAAS,6BAA6B,qBACf,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,4BAA4B,GAAI,SAAS,mCAAmC,qBACrB,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,4BAA4B,qBACd,CAAC;AAG9D,YAAY,EACV,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,EAC3B,6BAA6B,EAC7B,mCAAmC,EACnC,4BAA4B,EAC5B,sBAAsB,EACtB,iCAAiC,GAClC,CAAC;AAEF,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 ('motorcycleCC' in options || options.carType === 11) {
45
+ if (isMotorcycleRouteOptions(options)) {
40
46
  return calculateMotorcycleRoute(options);
41
47
  }
42
48
  // 4. 默认驾车
@@ -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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AErE;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,OAAqC,EAAE,EAAE,CAC7E,4BAA4B,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAyB9D,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,cAAc,GACf,CAAC;AAEF,WAAW;AACX,eAAe;IACb,MAAM;IACN,cAAc;IACd,qBAAqB;IAErB,OAAO;IACP,cAAc;IACd,mBAAmB;IACnB,kBAAkB;IAClB,kBAAkB;IAClB,mBAAmB;IACnB,mBAAmB;IACnB,wBAAwB;IAExB,SAAS;IACT,qBAAqB;IACrB,qBAAqB;IACrB,oBAAoB;IACpB,oBAAoB;IACpB,0BAA0B;IAE1B,UAAU;IACV,sBAAsB;IACtB,4BAA4B;IAC5B,qBAAqB;CACtB,CAAC;AAEF,OAAO,EACL,4BAA4B,GAC7B,CAAA","sourcesContent":["import ExpoGaodeMapNavigationModule from './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\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 = (options as any).strategy;\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 ('motorcycleCC' in options || (options as any).carType === 11) {\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}"]}
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,SAAS,iBAAiB,CACxB,OAAqB;IAErB,OAAO,UAAU,IAAI,OAAO,CAAC;AAC/B,CAAC;AAED,SAAS,wBAAwB,CAC/B,OAA8C;IAE9C,OAAO,cAAc,IAAI,OAAO,CAAC;AACnC,CAAC;AAED,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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C3F,4BAA4B,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC;AAErE;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,OAAqC,EAAE,EAAE,CAC7E,4BAA4B,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAyB9D,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,cAAc,GACf,CAAC;AAEF,WAAW;AACX,eAAe;IACb,MAAM;IACN,cAAc;IACd,qBAAqB;IAErB,OAAO;IACP,cAAc;IACd,mBAAmB;IACnB,kBAAkB;IAClB,kBAAkB;IAClB,mBAAmB;IACnB,mBAAmB;IACnB,wBAAwB;IAExB,SAAS;IACT,qBAAqB;IACrB,qBAAqB;IACrB,oBAAoB;IACpB,oBAAoB;IACpB,0BAA0B;IAE1B,UAAU;IACV,sBAAsB;IACtB,4BAA4B;IAC5B,qBAAqB;CACtB,CAAC;AAEF,OAAO,EACL,4BAA4B,GAC7B,CAAA","sourcesContent":["import ExpoGaodeMapNavigationModule from './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"]}
@@ -1,13 +1,240 @@
1
- import type { ExpoGaodeMapModule } from './types/native-module.types';
2
- import { SDKConfig } from './types/common.types';
1
+ import { LatLng, Coordinates, ReGeocode, LocationListener, LatLngPoint, CoordinateType } from './types';
2
+ import type { ExpoGaodeMapModule as NativeExpoGaodeMapModule } from './types/native-module.types';
3
+ import { PrivacyStatus, SDKConfig, PermissionStatus } from './types/common.types';
4
+ declare const helperMethods: {
5
+ /**
6
+ * 初始化 SDK,并缓存配置(包含 webKey)
7
+ * 注意:允许不提供任何 API Key,因为原生端可能已通过 Config Plugin 配置
8
+ */
9
+ initSDK(config: SDKConfig): void;
10
+ isSDKInitialized(): boolean;
11
+ setPrivacyShow(hasShow: boolean, hasContainsPrivacy: boolean): void;
12
+ setPrivacyAgree(hasAgree: boolean): void;
13
+ setPrivacyVersion(version: string): void;
14
+ resetPrivacyConsent(): void;
15
+ setPrivacyConfig(config: {
16
+ hasShow: boolean;
17
+ hasContainsPrivacy: boolean;
18
+ hasAgree: boolean;
19
+ privacyVersion?: string;
20
+ }): void;
21
+ getPrivacyStatus(): PrivacyStatus;
22
+ calculateDistanceBetweenPoints(p1: LatLngPoint, p2: LatLngPoint): number;
23
+ calculateDistance(lat1: number, lon1: number, lat2: number, lon2: number): number;
24
+ setLoadWorldVectorMap(enabled: boolean): void;
25
+ getVersion(): string;
26
+ start(): void;
27
+ stop(): void;
28
+ isStarted(): Promise<boolean>;
29
+ getCurrentLocation(): Promise<Coordinates | ReGeocode>;
30
+ coordinateConvert(coordinate: LatLngPoint, type: CoordinateType): Promise<LatLng>;
31
+ setLocatingWithReGeocode(isReGeocode: boolean): void;
32
+ readonly isBackgroundLocationEnabled: boolean;
33
+ /**
34
+ * 检查位置权限状态
35
+ */
36
+ checkLocationPermission(): Promise<PermissionStatus>;
37
+ /**
38
+ * 请求前台位置权限(增强版)
39
+ */
40
+ requestLocationPermission(): Promise<PermissionStatus>;
41
+ /**
42
+ * 请求后台位置权限
43
+ * 注意:必须在前台权限已授予后才能请求
44
+ */
45
+ requestBackgroundLocationPermission(): Promise<PermissionStatus>;
46
+ /**
47
+ * 打开应用设置页面
48
+ * 引导用户手动授予权限
49
+ */
50
+ openAppSettings(): void;
51
+ setAllowsBackgroundLocationUpdates(allows: boolean): void;
52
+ /**
53
+ * 添加定位监听器(便捷方法)
54
+ * 自动订阅 onLocationUpdate 事件,提供容错处理
55
+ * @param listener 定位回调函数
56
+ * @returns 订阅对象,调用 remove() 取消监听
57
+ * 注意:如果使用 Config Plugin 配置了 API Key,无需调用 initSDK()
58
+ */
59
+ addLocationListener(listener: LocationListener): {
60
+ remove: () => void;
61
+ };
62
+ /**
63
+ * 计算两个坐标点之间的距离
64
+ * @param coordinate1 第一个坐标点
65
+ * @param coordinate2 第二个坐标点
66
+ * @returns 两点之间的距离(单位:米)
67
+ */
68
+ distanceBetweenCoordinates(coordinate1: LatLngPoint, coordinate2: LatLngPoint): number;
69
+ /**
70
+ * 判断点是否在圆内
71
+ * @param point 要判断的点
72
+ * @param center 圆心坐标
73
+ * @param radius 圆半径(单位:米)
74
+ * @returns 是否在圆内
75
+ */
76
+ isPointInCircle(point: LatLngPoint, center: LatLngPoint, radius: number): boolean;
77
+ /**
78
+ * 判断点是否在多边形内
79
+ * @param point 要判断的点
80
+ * @param polygon 多边形的顶点坐标数组
81
+ * @returns 是否在多边形内
82
+ */
83
+ isPointInPolygon(point: LatLngPoint, polygon: LatLngPoint[]): boolean;
84
+ /**
85
+ * 计算多边形面积
86
+ * @param polygon 多边形的顶点坐标数组
87
+ * @returns 面积(单位:平方米)
88
+ */
89
+ calculatePolygonArea(polygon: LatLngPoint[]): number;
90
+ /**
91
+ * 计算矩形面积
92
+ * @param southWest 西南角坐标
93
+ * @param northEast 东北角坐标
94
+ * @returns 面积(单位:平方米)
95
+ */
96
+ calculateRectangleArea(southWest: LatLngPoint, northEast: LatLngPoint): number;
97
+ /**
98
+ * 获取路径上距离目标点最近的点
99
+ * @param path 路径点集合
100
+ * @param target 目标点
101
+ * @returns 最近点信息,包含坐标、索引和距离
102
+ */
103
+ getNearestPointOnPath(path: LatLngPoint[], target: LatLngPoint): {
104
+ latitude: number;
105
+ longitude: number;
106
+ index: number;
107
+ distanceMeters: number;
108
+ } | null;
109
+ /**
110
+ * 计算多边形质心
111
+ * @param polygon 多边形顶点坐标数组
112
+ * @returns 质心坐标
113
+ */
114
+ calculateCentroid(polygon: LatLngPoint[]): LatLng | null;
115
+ /**
116
+ * 计算路径边界和中心点
117
+ * @param points 路径点集合
118
+ * @returns 边界信息,包含 north, south, east, west 和 center
119
+ */
120
+ calculatePathBounds(points: LatLngPoint[]): {
121
+ north: number;
122
+ south: number;
123
+ east: number;
124
+ west: number;
125
+ center: LatLngPoint;
126
+ } | null;
127
+ /**
128
+ * GeoHash 编码
129
+ * @param coordinate 坐标点
130
+ * @param precision 精度 (1-12)
131
+ * @returns GeoHash 字符串
132
+ */
133
+ encodeGeoHash(coordinate: LatLngPoint, precision: number): string;
134
+ /**
135
+ * 轨迹抽稀 (RDP 算法)
136
+ * @param points 原始轨迹点
137
+ * @param tolerance 允许误差(米)
138
+ * @returns 简化后的轨迹点
139
+ */
140
+ simplifyPolyline(points: LatLngPoint[], tolerance: number): LatLng[];
141
+ /**
142
+ * 计算路径总长度
143
+ * @param points 路径点
144
+ * @returns 长度(米)
145
+ */
146
+ calculatePathLength(points: LatLngPoint[]): number;
147
+ /**
148
+ * 解析高德地图 API 返回的 Polyline 字符串
149
+ * 格式: "lng,lat;lng,lat;..."
150
+ * @param polylineStr 高德原始 polyline 字符串,或包含 polyline 属性的对象
151
+ * @returns 解析后的点集
152
+ */
153
+ parsePolyline(polylineStr: string | {
154
+ polyline: string;
155
+ }): LatLng[];
156
+ /**
157
+ * 获取路径上指定距离的点
158
+ * @param points 路径点
159
+ * @param distance 距离起点的米数
160
+ * @returns 点信息(坐标+角度)
161
+ */
162
+ getPointAtDistance(points: LatLngPoint[], distance: number): {
163
+ latitude: number;
164
+ longitude: number;
165
+ angle: number;
166
+ } | null;
167
+ /**
168
+ * 经纬度转换为地图瓦片坐标
169
+ * @param coordinate 经纬度点
170
+ * @param zoom 缩放级别
171
+ * @returns 瓦片坐标(x, y, z)
172
+ */
173
+ latLngToTile(coordinate: LatLngPoint, zoom: number): {
174
+ x: number;
175
+ y: number;
176
+ z: number;
177
+ } | null;
178
+ /**
179
+ * 地图瓦片坐标转换为经纬度
180
+ * @param tile 瓦片坐标(x, y, z)
181
+ * @returns 经纬度点
182
+ */
183
+ tileToLatLng(tile: {
184
+ x: number;
185
+ y: number;
186
+ z: number;
187
+ }): LatLng | null;
188
+ /**
189
+ * 经纬度转换为地图像素坐标
190
+ * @param coordinate 经纬度点
191
+ * @param zoom 缩放级别
192
+ * @returns 像素坐标(x, y)
193
+ */
194
+ latLngToPixel(coordinate: LatLngPoint, zoom: number): {
195
+ x: number;
196
+ y: number;
197
+ } | null;
198
+ /**
199
+ * 地图像素坐标转换为经纬度
200
+ * @param pixel 像素坐标(x, y)
201
+ * @param zoom 缩放级别
202
+ * @returns 经纬度点
203
+ */
204
+ pixelToLatLng(pixel: {
205
+ x: number;
206
+ y: number;
207
+ }, zoom: number): LatLng | null;
208
+ /**
209
+ * 批量地理围栏检测
210
+ * @param point 待检查的点
211
+ * @param polygons 多边形数组,格式为 LatLngPoint[][] 或 LatLngPoint[][][]
212
+ * @returns 包含点索引的数组(-1 表示不在任何多边形内)
213
+ */
214
+ findPointInPolygons(point: LatLngPoint, polygons: LatLngPoint[][] | LatLngPoint[][][]): number;
215
+ /**
216
+ * 生成网格聚合数据 (常用于展示网格聚合图或大规模点数据处理)
217
+ * @param points 包含经纬度和权重的点数组
218
+ * @param gridSizeMeters 网格大小(米)
219
+ * @returns 包含经纬度和强度的网格点数组
220
+ */
221
+ generateHeatmapGrid(points: Array<LatLngPoint & {
222
+ weight?: number;
223
+ }>, gridSizeMeters: number): Array<{
224
+ latitude: number;
225
+ longitude: number;
226
+ intensity: number;
227
+ }>;
228
+ };
3
229
  /**
4
230
  * 获取最近一次 initSDK 的配置
5
231
  */
6
232
  export declare function getSDKConfig(): SDKConfig | null;
233
+ export type ExpoGaodeMapModule = typeof helperMethods & NativeExpoGaodeMapModule;
234
+ declare const ExpoGaodeMapModuleWithHelpers: ExpoGaodeMapModule;
7
235
  /**
8
236
  * 获取用于 Web API 的 webKey(若未初始化或未提供则返回 undefined)
9
237
  */
10
238
  export declare function getWebKey(): string | undefined;
11
- declare const _default: ExpoGaodeMapModule;
12
- export default _default;
239
+ export default ExpoGaodeMapModuleWithHelpers;
13
240
  //# sourceMappingURL=ExpoGaodeMapModule.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoGaodeMapModule.d.ts","sourceRoot":"","sources":["../../src/map/ExpoGaodeMapModule.ts"],"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