expo-gaode-map-navigation 1.1.5-next.1 → 1.1.5-next.3

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 (136) hide show
  1. package/android/build.gradle +10 -0
  2. package/android/src/main/cpp/CMakeLists.txt +24 -0
  3. package/android/src/main/cpp/cluster_jni.cpp +848 -0
  4. package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapModule.kt +616 -92
  5. package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapOfflineModule.kt +493 -0
  6. package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapView.kt +230 -14
  7. package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapViewModule.kt +37 -27
  8. package/android/src/main/java/expo/modules/gaodemap/map/MapPreloadManager.kt +494 -0
  9. package/android/src/main/java/expo/modules/gaodemap/map/companion/BitmapDescriptorCache.kt +30 -0
  10. package/android/src/main/java/expo/modules/gaodemap/map/companion/IconBitmapCache.kt +37 -0
  11. package/android/src/main/java/expo/modules/gaodemap/map/managers/UIManager.kt +76 -0
  12. package/android/src/main/java/expo/modules/gaodemap/map/modules/LocationManager.kt +15 -3
  13. package/android/src/main/java/expo/modules/gaodemap/map/modules/SDKInitializer.kt +4 -59
  14. package/android/src/main/java/expo/modules/gaodemap/map/overlays/CircleView.kt +9 -12
  15. package/android/src/main/java/expo/modules/gaodemap/map/overlays/CircleViewModule.kt +5 -6
  16. package/android/src/main/java/expo/modules/gaodemap/map/overlays/ClusterView.kt +539 -66
  17. package/android/src/main/java/expo/modules/gaodemap/map/overlays/ClusterViewModule.kt +17 -1
  18. package/android/src/main/java/expo/modules/gaodemap/map/overlays/HeatMapView.kt +165 -33
  19. package/android/src/main/java/expo/modules/gaodemap/map/overlays/HeatMapViewModule.kt +15 -3
  20. package/android/src/main/java/expo/modules/gaodemap/map/overlays/MarkerView.kt +1249 -672
  21. package/android/src/main/java/expo/modules/gaodemap/map/overlays/MarkerViewModule.kt +40 -17
  22. package/android/src/main/java/expo/modules/gaodemap/map/overlays/MultiPointView.kt +177 -22
  23. package/android/src/main/java/expo/modules/gaodemap/map/overlays/MultiPointViewModule.kt +11 -3
  24. package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolygonView.kt +57 -14
  25. package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolygonViewModule.kt +9 -5
  26. package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolylineView.kt +90 -63
  27. package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolylineViewModule.kt +7 -3
  28. package/android/src/main/java/expo/modules/gaodemap/map/services/LocationForegroundService.kt +3 -2
  29. package/android/src/main/java/expo/modules/gaodemap/map/utils/BitmapDescriptorCache.kt +20 -0
  30. package/android/src/main/java/expo/modules/gaodemap/map/utils/ClusterNative.kt +13 -0
  31. package/android/src/main/java/expo/modules/gaodemap/map/utils/ColorParser.kt +20 -0
  32. package/android/src/main/java/expo/modules/gaodemap/map/utils/GeometryUtils.kt +515 -0
  33. package/android/src/main/java/expo/modules/gaodemap/map/utils/LatLngParser.kt +91 -0
  34. package/android/src/main/java/expo/modules/gaodemap/map/utils/PermissionHelper.kt +248 -0
  35. package/build/ExpoGaodeMapNaviView.d.ts +7 -7
  36. package/build/ExpoGaodeMapNaviView.js +8 -8
  37. package/build/ExpoGaodeMapNavigationModule.d.ts +2 -1
  38. package/build/index.d.ts +35 -33
  39. package/build/index.js +70 -106
  40. package/build/map/ExpoGaodeMapModule.d.ts +2 -201
  41. package/build/map/ExpoGaodeMapModule.js +584 -14
  42. package/build/map/ExpoGaodeMapOfflineModule.d.ts +139 -0
  43. package/build/map/ExpoGaodeMapOfflineModule.js +8 -0
  44. package/build/map/ExpoGaodeMapView.js +66 -58
  45. package/build/map/components/FoldableMapView.d.ts +38 -0
  46. package/build/map/components/FoldableMapView.js +209 -0
  47. package/build/map/components/MapContext.d.ts +12 -0
  48. package/build/map/components/MapContext.js +54 -0
  49. package/build/map/components/MapUI.d.ts +18 -0
  50. package/build/map/components/MapUI.js +29 -0
  51. package/build/map/components/overlays/Circle.js +34 -3
  52. package/build/map/components/overlays/Cluster.d.ts +3 -1
  53. package/build/map/components/overlays/Cluster.js +31 -2
  54. package/build/map/components/overlays/HeatMap.d.ts +3 -1
  55. package/build/map/components/overlays/HeatMap.js +33 -3
  56. package/build/map/components/overlays/Marker.d.ts +1 -1
  57. package/build/map/components/overlays/Marker.js +37 -32
  58. package/build/map/components/overlays/MultiPoint.js +1 -1
  59. package/build/map/components/overlays/Polygon.js +30 -3
  60. package/build/map/components/overlays/Polyline.js +36 -3
  61. package/build/map/index.d.ts +25 -5
  62. package/build/map/index.js +59 -18
  63. package/build/map/types/common.types.d.ts +40 -0
  64. package/build/map/types/common.types.js +0 -4
  65. package/build/map/types/index.d.ts +3 -2
  66. package/build/map/types/map-view.types.d.ts +108 -3
  67. package/build/map/types/native-module.types.d.ts +363 -0
  68. package/build/map/types/native-module.types.js +5 -0
  69. package/build/map/types/offline.types.d.ts +132 -0
  70. package/build/map/types/offline.types.js +5 -0
  71. package/build/map/types/overlays.types.d.ts +137 -24
  72. package/build/map/utils/ErrorHandler.d.ts +110 -0
  73. package/build/map/utils/ErrorHandler.js +421 -0
  74. package/build/map/utils/GeoUtils.d.ts +20 -0
  75. package/build/map/utils/GeoUtils.js +76 -0
  76. package/build/map/utils/OfflineMapManager.d.ts +148 -0
  77. package/build/map/utils/OfflineMapManager.js +217 -0
  78. package/build/map/utils/PermissionUtils.d.ts +91 -0
  79. package/build/map/utils/PermissionUtils.js +255 -0
  80. package/build/map/utils/PlatformDetector.d.ts +102 -0
  81. package/build/map/utils/PlatformDetector.js +186 -0
  82. package/build/types/index.d.ts +1 -0
  83. package/build/types/index.js +1 -0
  84. package/build/types/native-module.types.d.ts +69 -0
  85. package/build/types/native-module.types.js +2 -0
  86. package/build/types/naviview.types.d.ts +1 -1
  87. package/expo-module.config.json +12 -10
  88. package/ios/ExpoGaodeMapNavigation.podspec +9 -0
  89. package/ios/map/ExpoGaodeMapModule.swift +485 -75
  90. package/ios/map/ExpoGaodeMapOfflineModule.swift +479 -0
  91. package/ios/map/ExpoGaodeMapView.swift +611 -62
  92. package/ios/map/ExpoGaodeMapViewModule.swift +48 -26
  93. package/ios/map/MapPreloadManager.swift +348 -0
  94. package/ios/map/cpp/ClusterEngine.cpp +110 -0
  95. package/ios/map/cpp/ClusterEngine.hpp +20 -0
  96. package/ios/map/cpp/ColorParser.cpp +135 -0
  97. package/ios/map/cpp/ColorParser.hpp +14 -0
  98. package/ios/map/cpp/GeometryEngine.cpp +574 -0
  99. package/ios/map/cpp/GeometryEngine.hpp +159 -0
  100. package/ios/map/cpp/QuadTree.cpp +92 -0
  101. package/ios/map/cpp/QuadTree.hpp +42 -0
  102. package/ios/map/cpp/README.md +55 -0
  103. package/ios/map/cpp/tests/benchmark_js.js +41 -0
  104. package/ios/map/cpp/tests/run.sh +17 -0
  105. package/ios/map/cpp/tests/test_main.cpp +276 -0
  106. package/ios/map/managers/UIManager.swift +72 -1
  107. package/ios/map/modules/LocationManager.swift +114 -165
  108. package/ios/map/overlays/CircleView.swift +16 -32
  109. package/ios/map/overlays/CircleViewModule.swift +12 -12
  110. package/ios/map/overlays/ClusterAnnotation.swift +32 -0
  111. package/ios/map/overlays/ClusterView.swift +331 -45
  112. package/ios/map/overlays/ClusterViewModule.swift +20 -6
  113. package/ios/map/overlays/HeatMapView.swift +135 -32
  114. package/ios/map/overlays/HeatMapViewModule.swift +20 -8
  115. package/ios/map/overlays/MarkerView.swift +613 -130
  116. package/ios/map/overlays/MarkerViewModule.swift +38 -18
  117. package/ios/map/overlays/MultiPointView.swift +168 -10
  118. package/ios/map/overlays/MultiPointViewModule.swift +27 -5
  119. package/ios/map/overlays/PolygonView.swift +62 -23
  120. package/ios/map/overlays/PolygonViewModule.swift +18 -12
  121. package/ios/map/overlays/PolylineView.swift +21 -13
  122. package/ios/map/overlays/PolylineViewModule.swift +18 -12
  123. package/ios/map/utils/ClusterNative.h +96 -0
  124. package/ios/map/utils/ClusterNative.mm +377 -0
  125. package/ios/map/utils/ColorParser.swift +12 -1
  126. package/ios/map/utils/CppBridging.mm +13 -0
  127. package/ios/map/utils/GeometryUtils.swift +34 -0
  128. package/ios/map/utils/LatLngParser.swift +87 -0
  129. package/ios/map/utils/PermissionManager.swift +135 -6
  130. package/package.json +1 -1
  131. package/build/map/ExpoGaodeMap.types.d.ts +0 -41
  132. package/build/map/ExpoGaodeMap.types.js +0 -24
  133. package/build/map/utils/EventManager.d.ts +0 -10
  134. package/build/map/utils/EventManager.js +0 -26
  135. package/build/map/utils/ModuleLoader.d.ts +0 -73
  136. package/build/map/utils/ModuleLoader.js +0 -112
@@ -9,21 +9,41 @@ import AMapNaviKit
9
9
  * - 管理热力图数据和样式
10
10
  * - 支持半径和透明度配置
11
11
  */
12
- class NaviHeatMapView: ExpoView {
12
+ class HeatMapView: ExpoView {
13
13
  /// 热力图数据点数组
14
- var data: [[String: Any]] = []
14
+ var dataPoints: [[String: Any]] = []
15
15
  /// 热力图半径
16
16
  var radius: Int = 50
17
17
  /// 透明度
18
18
  var opacity: Double = 0.6
19
+ /// 渐变配置
20
+ var gradient: [String: Any]?
21
+ /// 是否开启高清适配
22
+ var allowRetinaAdapting: Bool = false
23
+
24
+ private var visible: Bool = true
19
25
 
20
26
  /// 地图视图弱引用
21
27
  private var mapView: MAMapView?
22
28
  /// 热力图图层
23
- private var heatmapOverlay: MAHeatMapTileOverlay?
29
+ var heatmapOverlay: MAHeatMapTileOverlay?
30
+ /// 渲染器
31
+ private var renderer: MATileOverlayRenderer?
32
+
33
+ private func reloadRenderer() {
34
+ guard let mapView = mapView, let overlay = heatmapOverlay else { return }
35
+ if let existing = mapView.renderer(for: overlay) as? MATileOverlayRenderer {
36
+ existing.reloadData()
37
+ mapView.setNeedsDisplay()
38
+ return
39
+ }
40
+ renderer?.reloadData()
41
+ mapView.setNeedsDisplay()
42
+ }
24
43
 
25
44
  required init(appContext: AppContext? = nil) {
26
45
  super.init(appContext: appContext)
46
+ self.backgroundColor = UIColor.clear
27
47
  }
28
48
 
29
49
  /**
@@ -32,15 +52,31 @@ class NaviHeatMapView: ExpoView {
32
52
  */
33
53
  func setMap(_ map: MAMapView) {
34
54
  self.mapView = map
55
+
35
56
  createOrUpdateHeatMap()
36
57
  }
37
58
 
59
+ /**
60
+ * 获取渲染器
61
+ */
62
+ func getRenderer() -> MAOverlayRenderer {
63
+ if let overlay = heatmapOverlay {
64
+ if renderer == nil || renderer?.overlay !== overlay {
65
+ renderer = MATileOverlayRenderer(tileOverlay: overlay)
66
+ renderer?.reloadData()
67
+ }
68
+ return renderer!
69
+ }
70
+ return MAOverlayRenderer()
71
+ }
72
+
38
73
  /**
39
74
  * 设置热力图数据
40
- * @param data 数据点数组,每个点包含 latitude、longitude
75
+ * @param data 数据点数组
41
76
  */
42
77
  func setData(_ data: [[String: Any]]) {
43
- self.data = data
78
+ self.dataPoints = data
79
+
44
80
  createOrUpdateHeatMap()
45
81
  }
46
82
 
@@ -50,6 +86,7 @@ class NaviHeatMapView: ExpoView {
50
86
  */
51
87
  func setRadius(_ radius: Int) {
52
88
  self.radius = radius
89
+
53
90
  createOrUpdateHeatMap()
54
91
  }
55
92
 
@@ -59,6 +96,30 @@ class NaviHeatMapView: ExpoView {
59
96
  */
60
97
  func setOpacity(_ opacity: Double) {
61
98
  self.opacity = opacity
99
+
100
+ createOrUpdateHeatMap()
101
+ }
102
+
103
+ /**
104
+ * 设置渐变配置
105
+ */
106
+ func setGradient(_ gradient: [String: Any]?) {
107
+ self.gradient = gradient
108
+
109
+ createOrUpdateHeatMap()
110
+ }
111
+
112
+ /**
113
+ * 设置是否开启高清适配
114
+ */
115
+ func setAllowRetinaAdapting(_ allow: Bool) {
116
+ self.allowRetinaAdapting = allow
117
+
118
+ createOrUpdateHeatMap()
119
+ }
120
+
121
+ func setVisible(_ visible: Bool) {
122
+ self.visible = visible
62
123
  createOrUpdateHeatMap()
63
124
  }
64
125
 
@@ -66,57 +127,99 @@ class NaviHeatMapView: ExpoView {
66
127
  * 创建或更新热力图
67
128
  */
68
129
  private func createOrUpdateHeatMap() {
130
+ if !Thread.isMainThread {
131
+ DispatchQueue.main.async { [weak self] in
132
+ self?.createOrUpdateHeatMap()
133
+ }
134
+ return
135
+ }
136
+
69
137
  guard let mapView = mapView else { return }
70
-
71
- // 移除旧的热力图
72
- if let oldHeatmap = heatmapOverlay {
73
- mapView.remove(oldHeatmap)
74
- heatmapOverlay = nil
138
+
139
+ if !visible {
140
+ if let overlay = heatmapOverlay {
141
+ overlay.opacity = 0
142
+ reloadRenderer()
143
+ }
144
+ return
75
145
  }
76
146
 
77
- // 验证数据有效性
78
- guard !data.isEmpty else { return }
147
+ // 🔑 使用统一的坐标解析器
148
+ let coords = LatLngParser.parseLatLngList(dataPoints)
79
149
 
80
- // 创建热力图数据
81
- var heatmapData: [MAHeatMapNode] = []
82
- for point in data {
83
- guard let latitude = point["latitude"] as? Double,
84
- let longitude = point["longitude"] as? Double,
85
- latitude >= -90 && latitude <= 90,
86
- longitude >= -180 && longitude <= 180 else {
87
- continue
150
+ guard !coords.isEmpty else {
151
+ if let old = heatmapOverlay {
152
+ mapView.remove(old)
153
+ heatmapOverlay = nil
154
+ renderer = nil
88
155
  }
89
-
156
+ return
157
+ }
158
+
159
+ // 转换为 MAHeatMapNode
160
+ let heatmapData = coords.map { coord -> MAHeatMapNode in
90
161
  let node = MAHeatMapNode()
91
- node.coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
92
- // 支持自定义强度,默认为 1.0
93
- if let intensity = point["intensity"] as? Double {
94
- node.intensity = Float(max(0, min(1, intensity)))
95
- } else {
96
- node.intensity = 1.0
97
- }
98
- heatmapData.append(node)
162
+ node.coordinate = coord
163
+ node.intensity = 1.0 // 默认强度为 1.0
164
+ return node
165
+ }
166
+
167
+ // 移除旧的热力图
168
+ if let oldHeatmap = heatmapOverlay {
169
+ mapView.remove(oldHeatmap)
170
+ heatmapOverlay = nil
171
+ renderer = nil
99
172
  }
100
173
 
101
- guard !heatmapData.isEmpty else { return }
174
+
102
175
 
103
176
  // 创建热力图图层
104
177
  let heatmap = MAHeatMapTileOverlay()
105
178
  heatmap.data = heatmapData
106
- heatmap.radius = max(1, radius) // 确保半径至少为 1
179
+ heatmap.radius = min(200, max(10, radius))
107
180
  heatmap.opacity = CGFloat(max(0, min(1, opacity))) // 限制透明度范围
181
+ heatmap.allowRetinaAdapting = allowRetinaAdapting
108
182
 
109
- mapView.add(heatmap)
183
+ // 配置渐变
184
+ if let gradientConfig = gradient,
185
+ let colorsArray = gradientConfig["colors"] as? [Any],
186
+ let startPointsArray = gradientConfig["startPoints"] as? [NSNumber] {
187
+
188
+ var colors: [UIColor] = []
189
+ for colorValue in colorsArray {
190
+ if let color = ColorParser.parseColor(colorValue) {
191
+ colors.append(color)
192
+ }
193
+ }
194
+
195
+ if !colors.isEmpty && colors.count == startPointsArray.count {
196
+ let gradient = MAHeatMapGradient(color: colors, andWithStartPoints: startPointsArray)
197
+ heatmap.gradient = gradient
198
+ }
199
+ }
200
+
110
201
  heatmapOverlay = heatmap
202
+ renderer = MATileOverlayRenderer(tileOverlay: heatmap)
203
+ renderer?.reloadData()
204
+
205
+ mapView.add(heatmap)
206
+ reloadRenderer()
111
207
  }
112
208
 
113
209
  /**
114
210
  * 移除热力图
115
211
  */
116
212
  func removeHeatMap() {
213
+ if !Thread.isMainThread {
214
+ DispatchQueue.main.async { [weak self] in
215
+ self?.removeHeatMap()
216
+ }
217
+ return
218
+ }
117
219
  guard let mapView = mapView, let heatmap = heatmapOverlay else { return }
118
220
  mapView.remove(heatmap)
119
221
  heatmapOverlay = nil
222
+ renderer = nil
120
223
  }
121
224
 
122
225
  /**
@@ -1,21 +1,33 @@
1
1
  import ExpoModulesCore
2
2
 
3
- public class NaviHeatMapViewModule: Module {
3
+ public class HeatMapViewModule: Module {
4
4
  public func definition() -> ModuleDefinition {
5
- Name("NaviHeatMapView")
5
+ Name("HeatMapView")
6
6
 
7
- View(NaviHeatMapView.self) {
8
- Prop("data") { (view: NaviHeatMapView, data: [[String: Any]]) in
9
- view.setData(data)
7
+ View(HeatMapView.self) {
8
+ Prop("data") { (view: HeatMapView, data: [[String: Any]]) in
9
+ view.setData(data)
10
+ }
11
+
12
+ Prop("visible") { (view: HeatMapView, visible: Bool) in
13
+ view.setVisible(visible)
10
14
  }
11
15
 
12
- Prop("radius") { (view: NaviHeatMapView, radius: Int) in
16
+ Prop("radius") { (view: HeatMapView, radius: Int) in
13
17
  view.setRadius(radius)
14
18
  }
15
19
 
16
- Prop("opacity") { (view: NaviHeatMapView, opacity: Double) in
20
+ Prop("opacity") { (view: HeatMapView, opacity: Double) in
17
21
  view.setOpacity(opacity)
18
22
  }
23
+
24
+ Prop("gradient") { (view: HeatMapView, gradient: [String: Any]?) in
25
+ view.setGradient(gradient)
26
+ }
27
+
28
+ Prop("allowRetinaAdapting") { (view: HeatMapView, allow: Bool) in
29
+ view.setAllowRetinaAdapting(allow)
30
+ }
19
31
  }
20
32
  }
21
- }
33
+ }