expo-gaode-map-navigation 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +213 -73
- package/android/build.gradle +10 -0
- package/android/src/main/cpp/CMakeLists.txt +24 -0
- package/android/src/main/cpp/cluster_jni.cpp +848 -0
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapModule.kt +616 -92
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapOfflineModule.kt +493 -0
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapView.kt +230 -14
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapViewModule.kt +37 -27
- package/android/src/main/java/expo/modules/gaodemap/map/MapPreloadManager.kt +494 -0
- package/android/src/main/java/expo/modules/gaodemap/map/companion/BitmapDescriptorCache.kt +30 -0
- package/android/src/main/java/expo/modules/gaodemap/map/companion/IconBitmapCache.kt +37 -0
- package/android/src/main/java/expo/modules/gaodemap/map/managers/UIManager.kt +76 -0
- package/android/src/main/java/expo/modules/gaodemap/map/modules/LocationManager.kt +15 -3
- package/android/src/main/java/expo/modules/gaodemap/map/modules/SDKInitializer.kt +4 -59
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/CircleView.kt +9 -12
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/CircleViewModule.kt +5 -6
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/ClusterView.kt +539 -66
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/ClusterViewModule.kt +17 -1
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/HeatMapView.kt +165 -33
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/HeatMapViewModule.kt +15 -3
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/MarkerView.kt +1249 -672
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/MarkerViewModule.kt +40 -17
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/MultiPointView.kt +177 -22
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/MultiPointViewModule.kt +11 -3
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolygonView.kt +57 -14
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolygonViewModule.kt +9 -5
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolylineView.kt +90 -63
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/PolylineViewModule.kt +7 -3
- package/android/src/main/java/expo/modules/gaodemap/map/services/LocationForegroundService.kt +3 -2
- package/android/src/main/java/expo/modules/gaodemap/map/utils/BitmapDescriptorCache.kt +20 -0
- package/android/src/main/java/expo/modules/gaodemap/map/utils/ClusterNative.kt +13 -0
- package/android/src/main/java/expo/modules/gaodemap/map/utils/ColorParser.kt +20 -0
- package/android/src/main/java/expo/modules/gaodemap/map/utils/GeometryUtils.kt +515 -0
- package/android/src/main/java/expo/modules/gaodemap/map/utils/LatLngParser.kt +91 -0
- package/android/src/main/java/expo/modules/gaodemap/map/utils/PermissionHelper.kt +248 -0
- package/build/ExpoGaodeMapNaviView.d.ts +7 -7
- package/build/ExpoGaodeMapNaviView.js +10 -11
- package/build/ExpoGaodeMapNavigationModule.d.ts +2 -1
- package/build/index.d.ts +35 -33
- package/build/index.js +70 -106
- package/build/map/ExpoGaodeMapModule.d.ts +2 -201
- package/build/map/ExpoGaodeMapModule.js +586 -18
- package/build/map/ExpoGaodeMapOfflineModule.d.ts +139 -0
- package/build/map/ExpoGaodeMapOfflineModule.js +8 -0
- package/build/map/ExpoGaodeMapView.js +66 -58
- package/build/map/components/FoldableMapView.d.ts +38 -0
- package/build/map/components/FoldableMapView.js +209 -0
- package/build/map/components/MapContext.d.ts +12 -0
- package/build/map/components/MapContext.js +54 -0
- package/build/map/components/MapUI.d.ts +18 -0
- package/build/map/components/MapUI.js +29 -0
- package/build/map/components/overlays/Circle.js +34 -3
- package/build/map/components/overlays/Cluster.d.ts +3 -1
- package/build/map/components/overlays/Cluster.js +31 -2
- package/build/map/components/overlays/HeatMap.d.ts +3 -1
- package/build/map/components/overlays/HeatMap.js +33 -3
- package/build/map/components/overlays/Marker.d.ts +1 -1
- package/build/map/components/overlays/Marker.js +37 -32
- package/build/map/components/overlays/MultiPoint.js +1 -1
- package/build/map/components/overlays/Polygon.js +30 -3
- package/build/map/components/overlays/Polyline.js +36 -3
- package/build/map/index.d.ts +25 -5
- package/build/map/index.js +59 -18
- package/build/map/types/common.types.d.ts +40 -0
- package/build/map/types/common.types.js +0 -4
- package/build/map/types/index.d.ts +3 -2
- package/build/map/types/map-view.types.d.ts +108 -3
- package/build/map/types/native-module.types.d.ts +363 -0
- package/build/map/types/native-module.types.js +5 -0
- package/build/map/types/offline.types.d.ts +132 -0
- package/build/map/types/offline.types.js +5 -0
- package/build/map/types/overlays.types.d.ts +137 -24
- package/build/map/utils/ErrorHandler.d.ts +110 -0
- package/build/map/utils/ErrorHandler.js +421 -0
- package/build/map/utils/GeoUtils.d.ts +20 -0
- package/build/map/utils/GeoUtils.js +76 -0
- package/build/map/utils/OfflineMapManager.d.ts +148 -0
- package/build/map/utils/OfflineMapManager.js +217 -0
- package/build/map/utils/PermissionUtils.d.ts +91 -0
- package/build/map/utils/PermissionUtils.js +255 -0
- package/build/map/utils/PlatformDetector.d.ts +102 -0
- package/build/map/utils/PlatformDetector.js +186 -0
- package/build/types/index.d.ts +1 -0
- package/build/types/index.js +1 -0
- package/build/types/native-module.types.d.ts +69 -0
- package/build/types/native-module.types.js +2 -0
- package/build/types/naviview.types.d.ts +1 -1
- package/expo-module.config.json +12 -10
- package/ios/ExpoGaodeMapNavigation.podspec +9 -0
- package/ios/map/ExpoGaodeMapModule.swift +485 -75
- package/ios/map/ExpoGaodeMapOfflineModule.swift +479 -0
- package/ios/map/ExpoGaodeMapView.swift +611 -62
- package/ios/map/ExpoGaodeMapViewModule.swift +48 -26
- package/ios/map/MapPreloadManager.swift +348 -0
- package/ios/map/cpp/ClusterEngine.cpp +110 -0
- package/ios/map/cpp/ClusterEngine.hpp +20 -0
- package/ios/map/cpp/ColorParser.cpp +135 -0
- package/ios/map/cpp/ColorParser.hpp +14 -0
- package/ios/map/cpp/GeometryEngine.cpp +574 -0
- package/ios/map/cpp/GeometryEngine.hpp +159 -0
- package/ios/map/cpp/QuadTree.cpp +92 -0
- package/ios/map/cpp/QuadTree.hpp +42 -0
- package/ios/map/cpp/README.md +55 -0
- package/ios/map/managers/UIManager.swift +72 -1
- package/ios/map/modules/LocationManager.swift +123 -166
- package/ios/map/overlays/CircleView.swift +16 -32
- package/ios/map/overlays/CircleViewModule.swift +12 -12
- package/ios/map/overlays/ClusterAnnotation.swift +32 -0
- package/ios/map/overlays/ClusterView.swift +331 -45
- package/ios/map/overlays/ClusterViewModule.swift +20 -6
- package/ios/map/overlays/HeatMapView.swift +135 -32
- package/ios/map/overlays/HeatMapViewModule.swift +20 -8
- package/ios/map/overlays/MarkerView.swift +613 -130
- package/ios/map/overlays/MarkerViewModule.swift +38 -18
- package/ios/map/overlays/MultiPointView.swift +168 -10
- package/ios/map/overlays/MultiPointViewModule.swift +27 -5
- package/ios/map/overlays/PolygonView.swift +62 -23
- package/ios/map/overlays/PolygonViewModule.swift +18 -12
- package/ios/map/overlays/PolylineView.swift +21 -13
- package/ios/map/overlays/PolylineViewModule.swift +18 -12
- package/ios/map/utils/ClusterNative.h +96 -0
- package/ios/map/utils/ClusterNative.mm +377 -0
- package/ios/map/utils/ColorParser.swift +12 -1
- package/ios/map/utils/CppBridging.mm +13 -0
- package/ios/map/utils/GeometryUtils.swift +34 -0
- package/ios/map/utils/LatLngParser.swift +87 -0
- package/ios/map/utils/PermissionManager.swift +135 -6
- package/package.json +3 -2
- package/shared/cpp/ClusterEngine.cpp +110 -0
- package/shared/cpp/ClusterEngine.hpp +20 -0
- package/shared/cpp/ColorParser.cpp +135 -0
- package/shared/cpp/ColorParser.hpp +14 -0
- package/shared/cpp/GeometryEngine.cpp +574 -0
- package/shared/cpp/GeometryEngine.hpp +159 -0
- package/shared/cpp/QuadTree.cpp +92 -0
- package/shared/cpp/QuadTree.hpp +42 -0
- package/shared/cpp/README.md +55 -0
- package/shared/cpp/tests/benchmark_js.js +41 -0
- package/shared/cpp/tests/run.sh +17 -0
- package/shared/cpp/tests/test_main.cpp +276 -0
- package/build/map/ExpoGaodeMap.types.d.ts +0 -41
- package/build/map/ExpoGaodeMap.types.js +0 -24
- package/build/map/utils/EventManager.d.ts +0 -10
- package/build/map/utils/EventManager.js +0 -26
- package/build/map/utils/ModuleLoader.d.ts +0 -73
- 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 =
|
|
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,
|
|
74
|
-
AMapLocationClient.updatePrivacyAgree(context,
|
|
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
|
-
|
|
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(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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:
|
|
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:
|
|
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("
|
|
11
|
+
Name("CircleView")
|
|
13
12
|
|
|
14
13
|
View(CircleView::class) {
|
|
15
14
|
Events("onCirclePress")
|
|
16
15
|
|
|
17
|
-
Prop<Map<String,
|
|
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<
|
|
24
|
+
Prop<String?>("fillColor") { view: CircleView, color ->
|
|
26
25
|
view.setFillColor(color)
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
Prop<
|
|
28
|
+
Prop<String?>("strokeColor") { view: CircleView, color ->
|
|
30
29
|
view.setStrokeColor(color)
|
|
31
30
|
}
|
|
32
31
|
|