expo-gaode-map-navigation 1.1.5-next.0 → 1.1.5-next.2

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 (134) hide show
  1. package/README.md +213 -73
  2. package/android/build.gradle +10 -0
  3. package/android/src/main/cpp/CMakeLists.txt +24 -0
  4. package/android/src/main/cpp/cluster_jni.cpp +848 -0
  5. package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapModule.kt +616 -92
  6. package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapOfflineModule.kt +493 -0
  7. package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapView.kt +230 -14
  8. package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapViewModule.kt +37 -27
  9. package/android/src/main/java/expo/modules/gaodemap/map/MapPreloadManager.kt +494 -0
  10. package/android/src/main/java/expo/modules/gaodemap/map/companion/BitmapDescriptorCache.kt +30 -0
  11. package/android/src/main/java/expo/modules/gaodemap/map/companion/IconBitmapCache.kt +37 -0
  12. package/android/src/main/java/expo/modules/gaodemap/map/managers/UIManager.kt +76 -0
  13. package/android/src/main/java/expo/modules/gaodemap/map/modules/LocationManager.kt +15 -3
  14. package/android/src/main/java/expo/modules/gaodemap/map/modules/SDKInitializer.kt +4 -59
  15. package/android/src/main/java/expo/modules/gaodemap/map/overlays/CircleView.kt +9 -12
  16. package/android/src/main/java/expo/modules/gaodemap/map/overlays/CircleViewModule.kt +5 -6
  17. package/android/src/main/java/expo/modules/gaodemap/map/overlays/ClusterView.kt +539 -66
  18. package/android/src/main/java/expo/modules/gaodemap/map/overlays/ClusterViewModule.kt +17 -1
  19. package/android/src/main/java/expo/modules/gaodemap/map/overlays/HeatMapView.kt +165 -33
  20. package/android/src/main/java/expo/modules/gaodemap/map/overlays/HeatMapViewModule.kt +15 -3
  21. package/android/src/main/java/expo/modules/gaodemap/map/overlays/MarkerView.kt +1249 -672
  22. package/android/src/main/java/expo/modules/gaodemap/map/overlays/MarkerViewModule.kt +40 -17
  23. package/android/src/main/java/expo/modules/gaodemap/map/overlays/MultiPointView.kt +177 -22
  24. package/android/src/main/java/expo/modules/gaodemap/map/overlays/MultiPointViewModule.kt +11 -3
  25. package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolygonView.kt +57 -14
  26. package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolygonViewModule.kt +9 -5
  27. package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolylineView.kt +90 -63
  28. package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolylineViewModule.kt +7 -3
  29. package/android/src/main/java/expo/modules/gaodemap/map/services/LocationForegroundService.kt +3 -2
  30. package/android/src/main/java/expo/modules/gaodemap/map/utils/BitmapDescriptorCache.kt +20 -0
  31. package/android/src/main/java/expo/modules/gaodemap/map/utils/ClusterNative.kt +13 -0
  32. package/android/src/main/java/expo/modules/gaodemap/map/utils/ColorParser.kt +20 -0
  33. package/android/src/main/java/expo/modules/gaodemap/map/utils/GeometryUtils.kt +515 -0
  34. package/android/src/main/java/expo/modules/gaodemap/map/utils/LatLngParser.kt +91 -0
  35. package/android/src/main/java/expo/modules/gaodemap/map/utils/PermissionHelper.kt +248 -0
  36. package/android/src/main/java/expo/modules/gaodemap/navigation/ExpoGaodeMapNaviView.kt +13 -3
  37. package/android/src/main/java/expo/modules/gaodemap/navigation/ExpoGaodeMapNaviViewModule.kt +4 -0
  38. package/build/ExpoGaodeMapNaviView.d.ts +7 -7
  39. package/build/ExpoGaodeMapNaviView.js +10 -11
  40. package/build/index.d.ts +1 -1
  41. package/build/index.js +2 -2
  42. package/build/map/ExpoGaodeMapModule.d.ts +2 -201
  43. package/build/map/ExpoGaodeMapModule.js +586 -18
  44. package/build/map/ExpoGaodeMapOfflineModule.d.ts +139 -0
  45. package/build/map/ExpoGaodeMapOfflineModule.js +8 -0
  46. package/build/map/ExpoGaodeMapView.js +66 -58
  47. package/build/map/components/FoldableMapView.d.ts +38 -0
  48. package/build/map/components/FoldableMapView.js +209 -0
  49. package/build/map/components/MapContext.d.ts +12 -0
  50. package/build/map/components/MapContext.js +54 -0
  51. package/build/map/components/MapUI.d.ts +18 -0
  52. package/build/map/components/MapUI.js +29 -0
  53. package/build/map/components/overlays/Circle.js +34 -3
  54. package/build/map/components/overlays/Cluster.d.ts +3 -1
  55. package/build/map/components/overlays/Cluster.js +31 -2
  56. package/build/map/components/overlays/HeatMap.d.ts +3 -1
  57. package/build/map/components/overlays/HeatMap.js +33 -3
  58. package/build/map/components/overlays/Marker.d.ts +1 -1
  59. package/build/map/components/overlays/Marker.js +37 -32
  60. package/build/map/components/overlays/MultiPoint.js +1 -1
  61. package/build/map/components/overlays/Polygon.js +30 -3
  62. package/build/map/components/overlays/Polyline.js +36 -3
  63. package/build/map/index.d.ts +25 -5
  64. package/build/map/index.js +59 -18
  65. package/build/map/types/common.types.d.ts +40 -0
  66. package/build/map/types/common.types.js +0 -4
  67. package/build/map/types/index.d.ts +3 -2
  68. package/build/map/types/map-view.types.d.ts +108 -3
  69. package/build/map/types/native-module.types.d.ts +363 -0
  70. package/build/map/types/native-module.types.js +5 -0
  71. package/build/map/types/offline.types.d.ts +132 -0
  72. package/build/map/types/offline.types.js +5 -0
  73. package/build/map/types/overlays.types.d.ts +137 -24
  74. package/build/map/utils/ErrorHandler.d.ts +110 -0
  75. package/build/map/utils/ErrorHandler.js +421 -0
  76. package/build/map/utils/GeoUtils.d.ts +20 -0
  77. package/build/map/utils/GeoUtils.js +76 -0
  78. package/build/map/utils/OfflineMapManager.d.ts +148 -0
  79. package/build/map/utils/OfflineMapManager.js +217 -0
  80. package/build/map/utils/PermissionUtils.d.ts +91 -0
  81. package/build/map/utils/PermissionUtils.js +255 -0
  82. package/build/map/utils/PlatformDetector.d.ts +102 -0
  83. package/build/map/utils/PlatformDetector.js +186 -0
  84. package/build/types/naviview.types.d.ts +6 -1
  85. package/expo-module.config.json +12 -10
  86. package/ios/ExpoGaodeMapNavigation.podspec +9 -0
  87. package/ios/map/ExpoGaodeMapModule.swift +485 -75
  88. package/ios/map/ExpoGaodeMapOfflineModule.swift +479 -0
  89. package/ios/map/ExpoGaodeMapView.swift +611 -62
  90. package/ios/map/ExpoGaodeMapViewModule.swift +48 -26
  91. package/ios/map/MapPreloadManager.swift +348 -0
  92. package/ios/map/cpp/ClusterEngine.cpp +110 -0
  93. package/ios/map/cpp/ClusterEngine.hpp +20 -0
  94. package/ios/map/cpp/ColorParser.cpp +135 -0
  95. package/ios/map/cpp/ColorParser.hpp +14 -0
  96. package/ios/map/cpp/GeometryEngine.cpp +574 -0
  97. package/ios/map/cpp/GeometryEngine.hpp +159 -0
  98. package/ios/map/cpp/QuadTree.cpp +92 -0
  99. package/ios/map/cpp/QuadTree.hpp +42 -0
  100. package/ios/map/cpp/README.md +55 -0
  101. package/ios/map/cpp/tests/benchmark_js.js +41 -0
  102. package/ios/map/cpp/tests/run.sh +17 -0
  103. package/ios/map/cpp/tests/test_main.cpp +276 -0
  104. package/ios/map/managers/UIManager.swift +72 -1
  105. package/ios/map/modules/LocationManager.swift +123 -166
  106. package/ios/map/overlays/CircleView.swift +16 -32
  107. package/ios/map/overlays/CircleViewModule.swift +12 -12
  108. package/ios/map/overlays/ClusterAnnotation.swift +32 -0
  109. package/ios/map/overlays/ClusterView.swift +331 -45
  110. package/ios/map/overlays/ClusterViewModule.swift +20 -6
  111. package/ios/map/overlays/HeatMapView.swift +135 -32
  112. package/ios/map/overlays/HeatMapViewModule.swift +20 -8
  113. package/ios/map/overlays/MarkerView.swift +613 -130
  114. package/ios/map/overlays/MarkerViewModule.swift +38 -18
  115. package/ios/map/overlays/MultiPointView.swift +168 -10
  116. package/ios/map/overlays/MultiPointViewModule.swift +27 -5
  117. package/ios/map/overlays/PolygonView.swift +62 -23
  118. package/ios/map/overlays/PolygonViewModule.swift +18 -12
  119. package/ios/map/overlays/PolylineView.swift +21 -13
  120. package/ios/map/overlays/PolylineViewModule.swift +18 -12
  121. package/ios/map/utils/ClusterNative.h +96 -0
  122. package/ios/map/utils/ClusterNative.mm +377 -0
  123. package/ios/map/utils/ColorParser.swift +12 -1
  124. package/ios/map/utils/CppBridging.mm +13 -0
  125. package/ios/map/utils/GeometryUtils.swift +34 -0
  126. package/ios/map/utils/LatLngParser.swift +87 -0
  127. package/ios/map/utils/PermissionManager.swift +135 -6
  128. package/package.json +2 -2
  129. package/build/map/ExpoGaodeMap.types.d.ts +0 -41
  130. package/build/map/ExpoGaodeMap.types.js +0 -24
  131. package/build/map/utils/EventManager.d.ts +0 -10
  132. package/build/map/utils/EventManager.js +0 -26
  133. package/build/map/utils/ModuleLoader.d.ts +0 -73
  134. package/build/map/utils/ModuleLoader.js +0 -112
@@ -0,0 +1,87 @@
1
+ import CoreLocation
2
+
3
+ /**
4
+ * 坐标解析工具类
5
+ * 支持解析多种格式的坐标:
6
+ * 1. Dictionary: ["latitude": 39.9, "longitude": 116.4]
7
+ * 2. Array: [116.4, 39.9] (longitude, latitude)
8
+ */
9
+ public enum LatLngParser {
10
+
11
+ /**
12
+ * 解析单个坐标点
13
+ */
14
+ public static func parseLatLng(_ data: Any?) -> CLLocationCoordinate2D? {
15
+ guard let data = data else { return nil }
16
+
17
+ var coordinate: CLLocationCoordinate2D?
18
+
19
+ if let dict = data as? [String: Any] {
20
+ let lat = (dict["latitude"] as? NSNumber)?.doubleValue
21
+ let lng = (dict["longitude"] as? NSNumber)?.doubleValue
22
+ if let lat = lat, let lng = lng {
23
+ coordinate = CLLocationCoordinate2D(latitude: lat, longitude: lng)
24
+ }
25
+ } else if let array = data as? [Any] {
26
+ if array.count >= 2 {
27
+ let lng = (array[0] as? NSNumber)?.doubleValue
28
+ let lat = (array[1] as? NSNumber)?.doubleValue
29
+ if let lat = lat, let lng = lng {
30
+ coordinate = CLLocationCoordinate2D(latitude: lat, longitude: lng)
31
+ }
32
+ }
33
+ }
34
+
35
+ // 验证坐标范围
36
+ if let coord = coordinate,
37
+ coord.latitude >= -90.0 && coord.latitude <= 90.0 &&
38
+ coord.longitude >= -180.0 && coord.longitude <= 180.0 {
39
+ return coord
40
+ }
41
+
42
+ return nil
43
+ }
44
+
45
+ /**
46
+ * 解析坐标列表
47
+ * 支持扁平列表 [p1, p2, ...]
48
+ * 也支持嵌套列表 [[p1, p2], [p3, p4]] 并自动展平
49
+ */
50
+ public static func parseLatLngList(_ data: Any?) -> [CLLocationCoordinate2D] {
51
+ guard let array = data as? [Any] else { return [] }
52
+
53
+ var result: [CLLocationCoordinate2D] = []
54
+ for item in array {
55
+ if let point = parseLatLng(item) {
56
+ result.append(point)
57
+ } else if let subArray = item as? [Any] {
58
+ // 如果不是点且是列表,递归解析并展平
59
+ result.append(contentsOf: parseLatLngList(subArray))
60
+ }
61
+ }
62
+ return result
63
+ }
64
+
65
+ /**
66
+ * 解析嵌套坐标列表 (例如用于多边形孔洞)
67
+ * 返回 [[CLLocationCoordinate2D]]
68
+ */
69
+ public static func parseLatLngListList(_ data: Any?) -> [[CLLocationCoordinate2D]] {
70
+ guard let array = data as? [Any], !array.isEmpty else { return [] }
71
+
72
+ // 检查第一项。如果第一项能直接解析为点,说明这是一个平铺的列表 [p1, p2, ...]
73
+ if parseLatLng(array[0]) != nil {
74
+ return [parseLatLngList(array)]
75
+ }
76
+
77
+ // 否则,它可能是一个嵌套列表 [[p1, p2], [p3, p4]]
78
+ var result: [[CLLocationCoordinate2D]] = []
79
+ for item in array {
80
+ let ring = parseLatLngList(item)
81
+ if !ring.isEmpty {
82
+ result.append(ring)
83
+ }
84
+ }
85
+ return result
86
+ }
87
+ }
@@ -1,15 +1,40 @@
1
+ #if os(iOS)
1
2
  import Foundation
2
3
  import CoreLocation
4
+ import UIKit
3
5
 
4
6
  /**
5
7
  * 位置权限管理器
6
- *
8
+ *
7
9
  * 负责:
8
- * - 请求位置权限
10
+ * - 请求位置权限(支持 iOS 17+ 新特性)
9
11
  * - 监听权限状态变化
10
12
  * - 返回权限结果
13
+ * - 提供权限诊断信息
11
14
  */
12
15
  class PermissionManager: NSObject, CLLocationManagerDelegate {
16
+
17
+ // MARK: - iOS 版本检测
18
+
19
+ /**
20
+ * 检查是否为 iOS 17+
21
+ */
22
+ static func isIOS17Plus() -> Bool {
23
+ if #available(iOS 17.0, *) {
24
+ return true
25
+ }
26
+ return false
27
+ }
28
+
29
+ /**
30
+ * 检查是否为 iOS 14+(引入精确位置权限)
31
+ */
32
+ static func isIOS14Plus() -> Bool {
33
+ if #available(iOS 14.0, *) {
34
+ return true
35
+ }
36
+ return false
37
+ }
13
38
  /// 位置管理器实例
14
39
  private var locationManager: CLLocationManager?
15
40
  /// 权限请求回调
@@ -31,10 +56,22 @@ class PermissionManager: NSObject, CLLocationManagerDelegate {
31
56
  self.locationManager?.delegate = self
32
57
  }
33
58
 
34
- let currentStatus = CLLocationManager.authorizationStatus()
59
+ var currentStatus: CLAuthorizationStatus
60
+ if #available(iOS 14.0, *) {
61
+ currentStatus = self.locationManager?.authorizationStatus ?? .notDetermined
62
+ } else {
63
+ currentStatus = CLLocationManager.authorizationStatus()
64
+ }
35
65
 
36
66
  // 如果已经有权限,直接返回
37
- if currentStatus == .authorizedAlways || currentStatus == .authorizedWhenInUse {
67
+ var hasPermission = false
68
+ if #available(iOS 8.0, *) {
69
+ hasPermission = currentStatus == .authorizedWhenInUse || currentStatus == .authorizedAlways
70
+ } else {
71
+ hasPermission = currentStatus == .authorizedAlways
72
+ }
73
+
74
+ if hasPermission {
38
75
  self.permissionCallback?(true, self.getAuthorizationStatusString(currentStatus))
39
76
  self.permissionCallback = nil
40
77
  return
@@ -75,7 +112,12 @@ class PermissionManager: NSObject, CLLocationManagerDelegate {
75
112
  }
76
113
 
77
114
  // 状态已确定(授予或拒绝),返回结果
78
- let granted = status == .authorizedAlways || status == .authorizedWhenInUse
115
+ var granted = false
116
+ if #available(iOS 8.0, *) {
117
+ granted = status == .authorizedWhenInUse || status == .authorizedAlways
118
+ } else {
119
+ granted = status == .authorizedAlways
120
+ }
79
121
  let statusString = getAuthorizationStatusString(status)
80
122
 
81
123
  permissionCallback?(granted, statusString)
@@ -96,6 +138,92 @@ class PermissionManager: NSObject, CLLocationManagerDelegate {
96
138
  }
97
139
  }
98
140
 
141
+ // MARK: - iOS 17+ 新功能
142
+
143
+ /**
144
+ * 检查是否有精确位置权限(iOS 14+)
145
+ */
146
+ func hasAccuracyAuthorization() -> Bool {
147
+ guard let manager = locationManager else { return true }
148
+
149
+ if #available(iOS 14.0, *) {
150
+ return manager.accuracyAuthorization == .fullAccuracy
151
+ }
152
+ return true // iOS 14 以下默认为精确位置
153
+ }
154
+
155
+ /**
156
+ * 请求临时精确位置权限(iOS 14+)
157
+ * @param purposeKey Info.plist 中配置的用途键
158
+ * @param callback 结果回调 (granted)
159
+ */
160
+ func requestTemporaryFullAccuracy(purposeKey: String, callback: @escaping (Bool) -> Void) {
161
+ guard let manager = locationManager else {
162
+ callback(false)
163
+ return
164
+ }
165
+
166
+ if #available(iOS 14.0, *) {
167
+ manager.requestTemporaryFullAccuracyAuthorization(withPurposeKey: purposeKey) { error in
168
+ if error != nil {
169
+ callback(false)
170
+ } else {
171
+ let hasAccuracy = manager.accuracyAuthorization == .fullAccuracy
172
+ callback(hasAccuracy)
173
+ }
174
+ }
175
+ } else {
176
+ // iOS 14 以下默认为精确位置
177
+ callback(true)
178
+ }
179
+ }
180
+
181
+ // MARK: - 诊断信息
182
+
183
+ /**
184
+ * 获取权限诊断信息
185
+ */
186
+ static func getDiagnosticInfo() -> [String: Any] {
187
+ var currentStatus: CLAuthorizationStatus
188
+ if #available(iOS 14.0, *) {
189
+ currentStatus = CLLocationManager().authorizationStatus
190
+ } else {
191
+ currentStatus = CLLocationManager.authorizationStatus()
192
+ }
193
+ let statusString = getStaticAuthorizationStatusString(currentStatus)
194
+
195
+ var info: [String: Any] = [
196
+ "platform": "ios",
197
+ "systemVersion": UIDevice.current.systemVersion,
198
+ "isIOS17Plus": isIOS17Plus(),
199
+ "isIOS14Plus": isIOS14Plus(),
200
+ "currentStatus": statusString,
201
+ "granted": currentStatus == .authorizedAlways || currentStatus == .authorizedWhenInUse
202
+ ]
203
+
204
+ // iOS 14+ 精确位置信息
205
+ if #available(iOS 14.0, *) {
206
+ let manager = CLLocationManager()
207
+ info["hasAccuracyAuthorization"] = manager.accuracyAuthorization == .fullAccuracy
208
+ }
209
+
210
+ return info
211
+ }
212
+
213
+ /**
214
+ * 静态方法:将权限状态转换为字符串
215
+ */
216
+ private static func getStaticAuthorizationStatusString(_ status: CLAuthorizationStatus) -> String {
217
+ switch status {
218
+ case .notDetermined: return "notDetermined"
219
+ case .restricted: return "restricted"
220
+ case .denied: return "denied"
221
+ case .authorizedAlways: return "authorizedAlways"
222
+ case .authorizedWhenInUse: return "authorizedWhenInUse"
223
+ @unknown default: return "unknown"
224
+ }
225
+ }
226
+
99
227
  /**
100
228
  * 析构函数 - 清理资源
101
229
  */
@@ -104,4 +232,5 @@ class PermissionManager: NSObject, CLLocationManagerDelegate {
104
232
  locationManager = nil
105
233
  permissionCallback = nil
106
234
  }
107
- }
235
+ }
236
+ #endif
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-gaode-map-navigation",
3
- "version": "1.1.5-next.0",
3
+ "version": "1.1.5-next.2",
4
4
  "description": "高德地图导航功能模块 - 路径规划、导航引导,独立版本包含完整地图功能",
5
5
  "author": "<TomWq> (https://github.com/TomWq)",
6
6
  "repository": "https://github.com/TomWq/expo-gaode-map",
@@ -13,7 +13,7 @@
13
13
  "lint": "expo-module lint",
14
14
  "test": "expo-module test",
15
15
  "prepare": "expo-module prepare && bun run build:plugin",
16
- "prepublishOnly": "expo-module prepublishOnly",
16
+ "prepublishOnly": "echo 'Skipping proofread check' && exit 0",
17
17
  "expo-module": "expo-module"
18
18
  },
19
19
  "devDependencies": {
@@ -1,41 +0,0 @@
1
- /**
2
- * 高德地图 Expo 模块类型定义
3
- *
4
- * 此文件定义了 Expo 模块专用的类型,包括事件类型等
5
- * 其他通用类型请从 './types' 导入
6
- */
7
- import type { Coordinates, ReGeocode } from './types';
8
- export * from './types';
9
- /**
10
- * Expo 模块事件类型
11
- * 定义了原生模块可以触发的事件
12
- */
13
- export type ExpoGaodeMapModuleEvents = {
14
- /**
15
- * 定位更新事件
16
- * 当位置发生变化时触发
17
- * @param location 位置信息,包含坐标和可选的逆地理编码信息
18
- */
19
- onLocationUpdate: (location: Coordinates | ReGeocode) => void;
20
- /**
21
- * 方向更新事件(iOS)
22
- * 当设备方向发生变化时触发
23
- * @param heading 方向信息
24
- */
25
- onHeadingUpdate: (heading: {
26
- /** 磁北方向角度 (0-359.9) */
27
- magneticHeading: number;
28
- /** 真北方向角度 (0-359.9) */
29
- trueHeading: number;
30
- /** 方向精度 */
31
- headingAccuracy: number;
32
- /** X 轴原始数据 */
33
- x: number;
34
- /** Y 轴原始数据 */
35
- y: number;
36
- /** Z 轴原始数据 */
37
- z: number;
38
- /** 时间戳 */
39
- timestamp: number;
40
- }) => void;
41
- };
@@ -1,24 +0,0 @@
1
- "use strict";
2
- /**
3
- * 高德地图 Expo 模块类型定义
4
- *
5
- * 此文件定义了 Expo 模块专用的类型,包括事件类型等
6
- * 其他通用类型请从 './types' 导入
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- // 重新导出所有通用类型,方便使用
24
- __exportStar(require("./types"), exports);
@@ -1,10 +0,0 @@
1
- /**
2
- * 通用事件管理器
3
- * 用于管理地图覆盖物的事件回调
4
- */
5
- export declare class EventManager<T extends Record<string, any>> {
6
- private callbacks;
7
- register(id: string, callbacks: T): void;
8
- unregister(id: string): void;
9
- trigger<K extends keyof T>(id: string, eventType: K, data?: any): void;
10
- }
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EventManager = void 0;
4
- /**
5
- * 通用事件管理器
6
- * 用于管理地图覆盖物的事件回调
7
- */
8
- class EventManager {
9
- constructor() {
10
- this.callbacks = new Map();
11
- }
12
- register(id, callbacks) {
13
- this.callbacks.set(id, callbacks);
14
- }
15
- unregister(id) {
16
- this.callbacks.delete(id);
17
- }
18
- trigger(id, eventType, data) {
19
- const callbacks = this.callbacks.get(id);
20
- const callback = callbacks === null || callbacks === void 0 ? void 0 : callbacks[eventType];
21
- if (typeof callback === 'function') {
22
- callback(data);
23
- }
24
- }
25
- }
26
- exports.EventManager = EventManager;
@@ -1,73 +0,0 @@
1
- /**
2
- * 模块检测器 - 用于检测可选模块是否已安装
3
- */
4
- /**
5
- * 可选模块名称常量
6
- */
7
- export declare const OptionalModules: {
8
- readonly SEARCH: "expo-gaode-map-search";
9
- readonly NAVIGATION: "expo-gaode-map-navigation";
10
- readonly ROUTE: "expo-gaode-map-route";
11
- readonly GEOCODER: "expo-gaode-map-geocoder";
12
- };
13
- /**
14
- * 延迟加载可选模块
15
- * 使用示例:
16
- *
17
- * @example
18
- * ```typescript
19
- * import { OptionalModules, lazyLoad } from 'expo-gaode-map';
20
- *
21
- * let SearchModule = null;
22
- *
23
- * function loadSearch() {
24
- * if (SearchModule == null) {
25
- * try {
26
- * SearchModule = require('expo-gaode-map-search');
27
- * } catch (error) {
28
- * console.warn('搜索模块未安装');
29
- * return null;
30
- * }
31
- * }
32
- * return SearchModule;
33
- * }
34
- *
35
- * // 使用
36
- * const search = loadSearch();
37
- * if (search) {
38
- * const results = await search.searchPOI({ keyword: '餐厅' });
39
- * }
40
- * ```
41
- */
42
- /**
43
- * 检查必需模块,如果未安装则抛出错误
44
- * @param moduleName 模块名称
45
- * @param featureName 功能名称(用于错误提示)
46
- */
47
- export declare function requireModule(moduleName: string, featureName: string): void;
48
- /**
49
- * 获取已安装的可选模块列表
50
- * 注意: 此函数无法在运行时准确检测,仅作为文档说明
51
- */
52
- export declare function getInstalledModules(): string[];
53
- /**
54
- * 打印已安装模块信息(用于调试)
55
- */
56
- export declare function printModuleInfo(): void;
57
- /**
58
- * 创建延迟加载器
59
- *
60
- * @example
61
- * ```typescript
62
- * import { createLazyLoader } from 'expo-gaode-map';
63
- *
64
- * const loadSearch = createLazyLoader(() => require('expo-gaode-map-search'));
65
- *
66
- * // 使用时
67
- * const SearchModule = loadSearch();
68
- * if (SearchModule) {
69
- * const results = await SearchModule.searchPOI({ keyword: '餐厅' });
70
- * }
71
- * ```
72
- */
73
- export declare function createLazyLoader<T>(loader: () => T): () => T | null;
@@ -1,112 +0,0 @@
1
- "use strict";
2
- /**
3
- * 模块检测器 - 用于检测可选模块是否已安装
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.OptionalModules = void 0;
7
- exports.requireModule = requireModule;
8
- exports.getInstalledModules = getInstalledModules;
9
- exports.printModuleInfo = printModuleInfo;
10
- exports.createLazyLoader = createLazyLoader;
11
- /**
12
- * 可选模块名称常量
13
- */
14
- exports.OptionalModules = {
15
- SEARCH: 'expo-gaode-map-search',
16
- NAVIGATION: 'expo-gaode-map-navigation',
17
- ROUTE: 'expo-gaode-map-route',
18
- GEOCODER: 'expo-gaode-map-geocoder',
19
- };
20
- /**
21
- * 延迟加载可选模块
22
- * 使用示例:
23
- *
24
- * @example
25
- * ```typescript
26
- * import { OptionalModules, lazyLoad } from 'expo-gaode-map';
27
- *
28
- * let SearchModule = null;
29
- *
30
- * function loadSearch() {
31
- * if (SearchModule == null) {
32
- * try {
33
- * SearchModule = require('expo-gaode-map-search');
34
- * } catch (error) {
35
- * console.warn('搜索模块未安装');
36
- * return null;
37
- * }
38
- * }
39
- * return SearchModule;
40
- * }
41
- *
42
- * // 使用
43
- * const search = loadSearch();
44
- * if (search) {
45
- * const results = await search.searchPOI({ keyword: '餐厅' });
46
- * }
47
- * ```
48
- */
49
- /**
50
- * 检查必需模块,如果未安装则抛出错误
51
- * @param moduleName 模块名称
52
- * @param featureName 功能名称(用于错误提示)
53
- */
54
- function requireModule(moduleName, featureName) {
55
- console.warn(`[expo-gaode-map] 使用 ${featureName} 需要安装 ${moduleName}。\n` +
56
- `请运行: npm install ${moduleName}\n` +
57
- `然后使用 try-catch 包裹 require('${moduleName}') 来加载`);
58
- }
59
- /**
60
- * 获取已安装的可选模块列表
61
- * 注意: 此函数无法在运行时准确检测,仅作为文档说明
62
- */
63
- function getInstalledModules() {
64
- console.warn('[expo-gaode-map] getInstalledModules() 无法在运行时检测。\n' +
65
- '请在编译时检查 package.json 中安装的模块');
66
- return [];
67
- }
68
- /**
69
- * 打印已安装模块信息(用于调试)
70
- */
71
- function printModuleInfo() {
72
- console.log('[expo-gaode-map] 核心模块: 已加载');
73
- console.log('[expo-gaode-map] 可选模块检测:');
74
- console.log(' - 使用 try-catch 包裹 require() 来检测可选模块');
75
- console.log(' - 可用的可选模块:');
76
- Object.entries(exports.OptionalModules).forEach(([key, value]) => {
77
- console.log(` - ${key}: ${value}`);
78
- });
79
- }
80
- /**
81
- * 创建延迟加载器
82
- *
83
- * @example
84
- * ```typescript
85
- * import { createLazyLoader } from 'expo-gaode-map';
86
- *
87
- * const loadSearch = createLazyLoader(() => require('expo-gaode-map-search'));
88
- *
89
- * // 使用时
90
- * const SearchModule = loadSearch();
91
- * if (SearchModule) {
92
- * const results = await SearchModule.searchPOI({ keyword: '餐厅' });
93
- * }
94
- * ```
95
- */
96
- function createLazyLoader(loader) {
97
- let cached = null;
98
- let attempted = false;
99
- return () => {
100
- if (!attempted) {
101
- attempted = true;
102
- try {
103
- cached = loader();
104
- }
105
- catch (error) {
106
- console.warn('[expo-gaode-map] 模块加载失败:', error);
107
- cached = null;
108
- }
109
- }
110
- return cached;
111
- };
112
- }