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
@@ -1,7 +1,6 @@
1
1
  package expo.modules.gaodemap.map.modules
2
2
 
3
3
  import android.content.Context
4
- import android.content.SharedPreferences
5
4
  import com.amap.api.location.AMapLocationClient
6
5
  import com.amap.api.maps.MapsInitializer
7
6
 
@@ -17,75 +16,22 @@ import com.amap.api.maps.MapsInitializer
17
16
  object SDKInitializer {
18
17
 
19
18
  /** 隐私协议是否已同意(进程内缓存) */
20
- private var privacyAgreed = false
19
+ private var privacyAgreed = true
21
20
 
22
- private const val PREFS_NAME = "expo_gaode_map_prefs"
23
- private const val KEY_PRIVACY_AGREED = "privacy_agreed"
24
21
 
25
- private fun prefs(context: Context): SharedPreferences =
26
- context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
27
22
 
28
- /**
29
- * 更新隐私合规状态
30
- * 必须在用户同意隐私协议后调用
31
- *
32
- * @param context 应用上下文
33
- * @param hasAgreed 用户是否已同意隐私协议
34
- */
35
- fun updatePrivacyCompliance(context: Context, hasAgreed: Boolean) {
36
- privacyAgreed = hasAgreed
37
-
38
- // 先更新隐私信息显示状态
39
- MapsInitializer.updatePrivacyShow(context, true, true)
40
- AMapLocationClient.updatePrivacyShow(context, true, true)
41
-
42
- // 根据用户选择更新同意状态
43
- if (hasAgreed) {
44
- MapsInitializer.updatePrivacyAgree(context, true)
45
- AMapLocationClient.updatePrivacyAgree(context, true)
46
- android.util.Log.d("ExpoGaodeMap", "✅ 用户已同意隐私协议,可以使用 SDK")
47
- } else {
48
- MapsInitializer.updatePrivacyAgree(context, false)
49
- AMapLocationClient.updatePrivacyAgree(context, false)
50
- android.util.Log.w("ExpoGaodeMap", "⚠️ 用户未同意隐私协议,SDK 功能将受限")
51
- }
52
-
53
- // 持久化状态,供下次启动自动恢复
54
- try {
55
- prefs(context).edit().putBoolean(KEY_PRIVACY_AGREED, hasAgreed).apply()
56
- } catch (e: Exception) {
57
- android.util.Log.w("ExpoGaodeMap", "持久化隐私状态失败: ${e.message}")
58
- }
59
- }
60
-
61
- /**
62
- * 从本地存储恢复隐私合规状态(在应用启动或模块加载时调用)
63
- * 若无记录则保持默认 false,不抛出异常。
64
- */
65
23
  fun restorePrivacyState(context: Context) {
66
24
  try {
67
- val saved = prefs(context).getBoolean(KEY_PRIVACY_AGREED, false)
68
- privacyAgreed = saved
69
-
70
25
  // 同步到 SDK
71
26
  MapsInitializer.updatePrivacyShow(context, true, true)
72
27
  AMapLocationClient.updatePrivacyShow(context, true, true)
73
- MapsInitializer.updatePrivacyAgree(context, saved)
74
- AMapLocationClient.updatePrivacyAgree(context, saved)
75
-
76
- android.util.Log.d("ExpoGaodeMap", "🔁 已从缓存恢复隐私状态: $saved")
28
+ MapsInitializer.updatePrivacyAgree(context, privacyAgreed)
29
+ AMapLocationClient.updatePrivacyAgree(context, privacyAgreed)
77
30
  } catch (e: Exception) {
78
31
  android.util.Log.w("ExpoGaodeMap", "恢复隐私状态失败: ${e.message}")
79
32
  }
80
33
  }
81
34
 
82
- /**
83
- * 检查隐私协议是否已同意
84
- *
85
- * @return 是否已同意隐私协议
86
- */
87
- fun isPrivacyAgreed(): Boolean = privacyAgreed
88
-
89
35
  /**
90
36
  * 初始化高德地图和定位 SDK
91
37
  *
@@ -105,8 +51,7 @@ object SDKInitializer {
105
51
  MapsInitializer.setApiKey(androidKey)
106
52
  AMapLocationClient.setApiKey(androidKey)
107
53
 
108
- android.util.Log.d("ExpoGaodeMap", "✅ SDK 初始化成功")
109
-
54
+
110
55
  } catch (e: Exception) {
111
56
  throw Exception("SDK 初始化失败: ${e.message}")
112
57
  }
@@ -1,5 +1,6 @@
1
1
  package expo.modules.gaodemap.map.overlays
2
2
 
3
+ import expo.modules.gaodemap.map.utils.LatLngParser
3
4
  import android.content.Context
4
5
  import android.graphics.Color
5
6
  import com.amap.api.maps.AMap
@@ -36,19 +37,15 @@ class CircleView(context: Context, appContext: AppContext) : ExpoView(context, a
36
37
  post { createOrUpdateCircle() }
37
38
  }
38
39
 
40
+
41
+
39
42
  /**
40
43
  * 设置圆心
41
44
  */
42
- fun setCenter(centerMap: Map<String, Double>) {
43
- val lat = centerMap["latitude"]
44
- val lng = centerMap["longitude"]
45
- if (lat != null && lng != null) {
46
- // 坐标验证
47
- if (lat < -90 || lat > 90 || lng < -180 || lng > 180) {
48
- return
49
- }
50
- center = LatLng(lat, lng)
51
- circle?.center = center
45
+ fun setCenter(centerData: Map<String, Any>?) {
46
+ center = LatLngParser.parseLatLng(centerData)
47
+ center?.let {
48
+ circle?.center = it
52
49
  }
53
50
  }
54
51
 
@@ -67,7 +64,7 @@ class CircleView(context: Context, appContext: AppContext) : ExpoView(context, a
67
64
  /**
68
65
  * 设置填充颜色
69
66
  */
70
- fun setFillColor(color: Any) {
67
+ fun setFillColor(color: String?) {
71
68
  fillColor = ColorParser.parseColor(color)
72
69
  circle?.let {
73
70
  it.fillColor = fillColor
@@ -78,7 +75,7 @@ class CircleView(context: Context, appContext: AppContext) : ExpoView(context, a
78
75
  /**
79
76
  * 设置边框颜色
80
77
  */
81
- fun setStrokeColor(color: Any) {
78
+ fun setStrokeColor(color: String?) {
82
79
  strokeColor = ColorParser.parseColor(color)
83
80
  circle?.let {
84
81
  it.strokeColor = strokeColor
@@ -1,6 +1,5 @@
1
1
  package expo.modules.gaodemap.map.overlays
2
2
 
3
- import expo.modules.gaodemap.map.overlays.CircleView
4
3
  import expo.modules.kotlin.modules.Module
5
4
  import expo.modules.kotlin.modules.ModuleDefinition
6
5
 
@@ -9,24 +8,24 @@ import expo.modules.kotlin.modules.ModuleDefinition
9
8
  */
10
9
  class CircleViewModule : Module() {
11
10
  override fun definition() = ModuleDefinition {
12
- Name("NaviCircleView")
11
+ Name("CircleView")
13
12
 
14
13
  View(CircleView::class) {
15
14
  Events("onCirclePress")
16
15
 
17
- Prop<Map<String, Double>>("center") { view, center ->
16
+ Prop<Map<String, Any>?>("center") { view: CircleView, center ->
18
17
  view.setCenter(center)
19
18
  }
20
19
 
21
- Prop<Double>("radius") { view, radius ->
20
+ Prop<Double>("radius") { view: CircleView, radius ->
22
21
  view.setRadius(radius)
23
22
  }
24
23
 
25
- Prop<Any>("fillColor") { view, color ->
24
+ Prop<String?>("fillColor") { view: CircleView, color ->
26
25
  view.setFillColor(color)
27
26
  }
28
27
 
29
- Prop<Any>("strokeColor") { view, color ->
28
+ Prop<String?>("strokeColor") { view: CircleView, color ->
30
29
  view.setStrokeColor(color)
31
30
  }
32
31