expo-gaode-map 2.2.38 → 2.2.39
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/android/build.gradle +6 -31
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapView.kt +35 -12
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapViewModule.kt +2 -0
- package/android/src/main/java/expo/modules/gaodemap/managers/UIManager.kt +8 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerView.kt +48 -7
- package/build/ExpoGaodeMapOfflineModule.js +1 -1
- package/build/ExpoGaodeMapOfflineModule.js.map +1 -1
- package/build/ExpoGaodeMapView.js +2 -8
- package/build/ExpoGaodeMapView.js.map +1 -1
- package/build/components/AreaMaskOverlay.d.ts +1 -2
- package/build/components/AreaMaskOverlay.d.ts.map +1 -1
- package/build/components/AreaMaskOverlay.js +2 -1
- package/build/components/AreaMaskOverlay.js.map +1 -1
- package/build/components/FoldableMapView.d.ts +3 -2
- package/build/components/FoldableMapView.d.ts.map +1 -1
- package/build/components/FoldableMapView.js +2 -1
- package/build/components/FoldableMapView.js.map +1 -1
- package/build/components/MapUI.js +2 -1
- package/build/components/MapUI.js.map +1 -1
- package/build/components/RouteOverlay.d.ts +1 -2
- package/build/components/RouteOverlay.d.ts.map +1 -1
- package/build/components/RouteOverlay.js +5 -5
- package/build/components/RouteOverlay.js.map +1 -1
- package/build/components/overlays/Circle.d.ts +1 -1
- package/build/components/overlays/Circle.d.ts.map +1 -1
- package/build/components/overlays/Circle.js +2 -1
- package/build/components/overlays/Circle.js.map +1 -1
- package/build/components/overlays/Cluster.d.ts +1 -1
- package/build/components/overlays/Cluster.d.ts.map +1 -1
- package/build/components/overlays/Cluster.js +2 -1
- package/build/components/overlays/Cluster.js.map +1 -1
- package/build/components/overlays/HeatMap.d.ts +1 -1
- package/build/components/overlays/HeatMap.d.ts.map +1 -1
- package/build/components/overlays/HeatMap.js +2 -1
- package/build/components/overlays/HeatMap.js.map +1 -1
- package/build/components/overlays/Marker.d.ts +1 -1
- package/build/components/overlays/Marker.d.ts.map +1 -1
- package/build/components/overlays/Marker.js +8 -7
- package/build/components/overlays/Marker.js.map +1 -1
- package/build/components/overlays/MultiPoint.d.ts +1 -2
- package/build/components/overlays/MultiPoint.d.ts.map +1 -1
- package/build/components/overlays/MultiPoint.js +2 -1
- package/build/components/overlays/MultiPoint.js.map +1 -1
- package/build/components/overlays/Polygon.d.ts +1 -1
- package/build/components/overlays/Polygon.d.ts.map +1 -1
- package/build/components/overlays/Polygon.js +2 -1
- package/build/components/overlays/Polygon.js.map +1 -1
- package/build/components/overlays/Polyline.d.ts +1 -1
- package/build/components/overlays/Polyline.d.ts.map +1 -1
- package/build/components/overlays/Polyline.js +2 -1
- package/build/components/overlays/Polyline.js.map +1 -1
- package/build/module/geometry.d.ts.map +1 -1
- package/build/module/geometry.js +2 -1
- package/build/module/geometry.js.map +1 -1
- package/build/search/ExpoGaodeMapSearchModule.d.ts +1 -1
- package/build/search/ExpoGaodeMapSearchModule.d.ts.map +1 -1
- package/build/search/ExpoGaodeMapSearchModule.js.map +1 -1
- package/build/types/common.types.d.ts +1 -1
- package/build/types/common.types.d.ts.map +1 -1
- package/build/types/common.types.js.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/index.js.map +1 -1
- package/build/types/map-view.types.d.ts +13 -2
- package/build/types/map-view.types.d.ts.map +1 -1
- package/build/types/map-view.types.js.map +1 -1
- package/build/utils/GeoUtils.d.ts +2 -2
- package/build/utils/GeoUtils.d.ts.map +1 -1
- package/build/utils/GeoUtils.js +3 -3
- package/build/utils/GeoUtils.js.map +1 -1
- package/build/utils/RouteUtils.d.ts.map +1 -1
- package/build/utils/RouteUtils.js +5 -2
- package/build/utils/RouteUtils.js.map +1 -1
- package/ios/ExpoGaodeMapView.swift +281 -15
- package/ios/ExpoGaodeMapViewModule.swift +5 -0
- package/ios/managers/UIManager.swift +3 -0
- package/ios/overlays/MarkerView.swift +205 -38
- package/package.json +9 -7
- package/plugin/build/withGaodeMap.js +3 -2
package/android/build.gradle
CHANGED
|
@@ -1,35 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
plugins {
|
|
2
|
+
id 'com.android.library'
|
|
3
|
+
id 'expo-module-gradle-plugin'
|
|
4
|
+
}
|
|
2
5
|
|
|
3
6
|
group = 'expo.modules.gaodemap'
|
|
4
|
-
version = '2.2.
|
|
5
|
-
|
|
6
|
-
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
|
-
apply from: expoModulesCorePlugin
|
|
8
|
-
applyKotlinExpoModulesCorePlugin()
|
|
9
|
-
useCoreDependencies()
|
|
10
|
-
useExpoPublishing()
|
|
11
|
-
|
|
12
|
-
// If you want to use the managed Android SDK versions from expo-modules-core, set this to true.
|
|
13
|
-
// The Android SDK versions will be bumped from time to time in SDK releases and may introduce breaking changes in your module code.
|
|
14
|
-
// Most of the time, you may like to manage the Android SDK versions yourself.
|
|
15
|
-
def useManagedAndroidSdkVersions = false
|
|
16
|
-
if (useManagedAndroidSdkVersions) {
|
|
17
|
-
useDefaultAndroidSdkVersions()
|
|
18
|
-
} else {
|
|
19
|
-
buildscript {
|
|
20
|
-
// Simple helper that allows the root project to override versions declared by this library.
|
|
21
|
-
ext.safeExtGet = { prop, fallback ->
|
|
22
|
-
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
project.android {
|
|
26
|
-
compileSdkVersion safeExtGet("compileSdkVersion", 36)
|
|
27
|
-
defaultConfig {
|
|
28
|
-
minSdkVersion safeExtGet("minSdkVersion", 24)
|
|
29
|
-
targetSdkVersion safeExtGet("targetSdkVersion", 36)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
7
|
+
version = '2.2.39'
|
|
33
8
|
|
|
34
9
|
logger.warn("[expo-gaode-map] Thank you for using expo-gaode-map ❤️")
|
|
35
10
|
logger.warn("[expo-gaode-map] If you enjoy using expo-gaode-map, please consider sponsoring this project: https://github.com/TomWq")
|
|
@@ -38,7 +13,7 @@ android {
|
|
|
38
13
|
namespace "expo.modules.gaodemap"
|
|
39
14
|
defaultConfig {
|
|
40
15
|
versionCode 1
|
|
41
|
-
versionName "2.2.
|
|
16
|
+
versionName "2.2.39"
|
|
42
17
|
externalNativeBuild {
|
|
43
18
|
cmake {
|
|
44
19
|
cppFlags "-std=c++17"
|
|
@@ -119,6 +119,8 @@ class ExpoGaodeMapView(context: Context, appContext: AppContext) : ExpoView(cont
|
|
|
119
119
|
private var myLocationButtonEnabled: Boolean = false
|
|
120
120
|
/** 相机移动事件节流间隔 */
|
|
121
121
|
private var cameraEventThrottleMs: Long = 32L
|
|
122
|
+
/** 缩放手势锚点 */
|
|
123
|
+
private var zoomGestureAnchor: String = "gesture"
|
|
122
124
|
/** 自定义地图样式配置(缓存) */
|
|
123
125
|
private var customMapStyleData: Map<String, Any>? = null
|
|
124
126
|
|
|
@@ -204,6 +206,7 @@ class ExpoGaodeMapView(context: Context, appContext: AppContext) : ExpoView(cont
|
|
|
204
206
|
|
|
205
207
|
uiManager.setLabelsEnabled(labelsEnabled)
|
|
206
208
|
uiManager.setMyLocationButtonEnabled(myLocationButtonEnabled)
|
|
209
|
+
uiManager.setZoomGestureAnchor(zoomGestureAnchor)
|
|
207
210
|
|
|
208
211
|
onLoad(mapOf("loaded" to true))
|
|
209
212
|
}
|
|
@@ -214,6 +217,7 @@ class ExpoGaodeMapView(context: Context, appContext: AppContext) : ExpoView(cont
|
|
|
214
217
|
|
|
215
218
|
// 辅助监听器列表
|
|
216
219
|
private val cameraChangeListeners = mutableListOf<AMap.OnCameraChangeListener>()
|
|
220
|
+
private val pendingMarkerRemovalTasks = mutableMapOf<MarkerView, Runnable>()
|
|
217
221
|
|
|
218
222
|
fun addCameraChangeListener(listener: AMap.OnCameraChangeListener) {
|
|
219
223
|
if (!cameraChangeListeners.contains(listener)) {
|
|
@@ -390,6 +394,11 @@ class ExpoGaodeMapView(context: Context, appContext: AppContext) : ExpoView(cont
|
|
|
390
394
|
|
|
391
395
|
/** 设置是否启用缩放手势 */
|
|
392
396
|
fun setZoomEnabled(enabled: Boolean) = uiManager.setZoomEnabled(enabled)
|
|
397
|
+
/** 设置缩放手势锚点 */
|
|
398
|
+
fun setZoomGestureAnchor(anchor: String?) {
|
|
399
|
+
zoomGestureAnchor = if (anchor == "center") "center" else "gesture"
|
|
400
|
+
uiManager.setZoomGestureAnchor(zoomGestureAnchor)
|
|
401
|
+
}
|
|
393
402
|
/** 设置是否启用滚动手势 */
|
|
394
403
|
fun setScrollEnabled(enabled: Boolean) = uiManager.setScrollEnabled(enabled)
|
|
395
404
|
/** 设置是否启用旋转手势 */
|
|
@@ -638,10 +647,11 @@ class ExpoGaodeMapView(context: Context, appContext: AppContext) : ExpoView(cont
|
|
|
638
647
|
@Suppress("unused")
|
|
639
648
|
fun onDestroy() {
|
|
640
649
|
try {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
650
|
+
// 清理 Handler 回调,防止内存泄露
|
|
651
|
+
mainHandler.removeCallbacksAndMessages(null)
|
|
652
|
+
pendingCameraMoveData = null
|
|
653
|
+
pendingCameraMoveDispatch = null
|
|
654
|
+
pendingMarkerRemovalTasks.clear()
|
|
645
655
|
|
|
646
656
|
// 清理所有地图监听器
|
|
647
657
|
aMap.setOnMapClickListener(null)
|
|
@@ -747,6 +757,7 @@ class ExpoGaodeMapView(context: Context, appContext: AppContext) : ExpoView(cont
|
|
|
747
757
|
@SuppressLint("UseKtx")
|
|
748
758
|
override fun addView(child: View?, index: Int) {
|
|
749
759
|
if (child is MarkerView) {
|
|
760
|
+
cancelPendingMarkerRemoval(child)
|
|
750
761
|
child.setMap(aMap)
|
|
751
762
|
// MarkerView 需要保留可测量尺寸,否则 Android 无法正确处理
|
|
752
763
|
// Text / View 的 maxWidth 等布局约束,最终会被测成整行宽度。
|
|
@@ -784,10 +795,7 @@ class ExpoGaodeMapView(context: Context, appContext: AppContext) : ExpoView(cont
|
|
|
784
795
|
*/
|
|
785
796
|
override fun removeView(child: View?) {
|
|
786
797
|
if (child is MarkerView) {
|
|
787
|
-
|
|
788
|
-
mainHandler.postDelayed({
|
|
789
|
-
child.removeMarker()
|
|
790
|
-
}, 500)
|
|
798
|
+
scheduleMarkerRemoval(child)
|
|
791
799
|
super.removeView(child)
|
|
792
800
|
return
|
|
793
801
|
}
|
|
@@ -812,10 +820,7 @@ class ExpoGaodeMapView(context: Context, appContext: AppContext) : ExpoView(cont
|
|
|
812
820
|
}
|
|
813
821
|
|
|
814
822
|
if (child is MarkerView) {
|
|
815
|
-
|
|
816
|
-
mainHandler.postDelayed({
|
|
817
|
-
child.removeMarker()
|
|
818
|
-
}, 500)
|
|
823
|
+
scheduleMarkerRemoval(child)
|
|
819
824
|
}
|
|
820
825
|
|
|
821
826
|
super.removeViewAt(index)
|
|
@@ -825,6 +830,24 @@ class ExpoGaodeMapView(context: Context, appContext: AppContext) : ExpoView(cont
|
|
|
825
830
|
}
|
|
826
831
|
}
|
|
827
832
|
|
|
833
|
+
private fun scheduleMarkerRemoval(markerView: MarkerView) {
|
|
834
|
+
cancelPendingMarkerRemoval(markerView)
|
|
835
|
+
|
|
836
|
+
val task = Runnable {
|
|
837
|
+
pendingMarkerRemovalTasks.remove(markerView)
|
|
838
|
+
if (markerView.parent == null) {
|
|
839
|
+
markerView.removeMarker()
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
pendingMarkerRemovalTasks[markerView] = task
|
|
844
|
+
mainHandler.postDelayed(task, 500)
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
private fun cancelPendingMarkerRemoval(markerView: MarkerView) {
|
|
848
|
+
pendingMarkerRemovalTasks.remove(markerView)?.let(mainHandler::removeCallbacks)
|
|
849
|
+
}
|
|
850
|
+
|
|
828
851
|
private fun checkDeclarativePolylinePress(latLng: LatLng): Boolean {
|
|
829
852
|
for (i in 0 until childCount) {
|
|
830
853
|
val child = getChildAt(i)
|
|
@@ -39,6 +39,8 @@ class ExpoGaodeMapViewModule : Module() {
|
|
|
39
39
|
Prop<Boolean>("scaleControlsEnabled") { view, show -> view.setShowsScale(show) }
|
|
40
40
|
|
|
41
41
|
Prop<Boolean>("zoomGesturesEnabled") { view, enabled -> view.setZoomEnabled(enabled) }
|
|
42
|
+
// 缩放手势锚点:gesture 使用手势焦点,center 固定地图中心点
|
|
43
|
+
Prop<String?>("zoomGestureAnchor") { view, anchor -> view.setZoomGestureAnchor(anchor) }
|
|
42
44
|
Prop<Boolean>("scrollGesturesEnabled") { view, enabled -> view.setScrollEnabled(enabled) }
|
|
43
45
|
Prop<Boolean>("rotateGesturesEnabled") { view, enabled -> view.setRotateEnabled(enabled) }
|
|
44
46
|
Prop<Boolean>("tiltGesturesEnabled") { view, enabled -> view.setTiltEnabled(enabled) }
|
|
@@ -62,6 +62,14 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
|
|
|
62
62
|
fun setZoomEnabled(enabled: Boolean) {
|
|
63
63
|
aMap.uiSettings.isZoomGesturesEnabled = enabled
|
|
64
64
|
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 设置缩放手势锚点
|
|
68
|
+
*/
|
|
69
|
+
fun setZoomGestureAnchor(anchor: String?) {
|
|
70
|
+
val scaleByMapCenter = anchor == "center"
|
|
71
|
+
aMap.uiSettings.setGestureScaleByMapCenter(scaleByMapCenter)
|
|
72
|
+
}
|
|
65
73
|
|
|
66
74
|
/**
|
|
67
75
|
* 设置是否启用滚动手势
|
|
@@ -224,6 +224,7 @@ class MarkerView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
224
224
|
private val mainHandler = Handler(Looper.getMainLooper())
|
|
225
225
|
private var isRemoving = false // 标记是否正在被移除
|
|
226
226
|
private var pendingMarkerIconUpdate: Runnable? = null
|
|
227
|
+
private var pendingDetachRemovalTask: Runnable? = null
|
|
227
228
|
private var lastAppliedCustomMarkerKey: String? = null
|
|
228
229
|
|
|
229
230
|
// 缓存属性,在 marker 创建前保存
|
|
@@ -480,9 +481,17 @@ class MarkerView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
480
481
|
return
|
|
481
482
|
}
|
|
482
483
|
|
|
483
|
-
invalidateAppliedCustomMarkerCaches(clearGlobalCache = true)
|
|
484
484
|
cacheKey = key
|
|
485
|
-
|
|
485
|
+
if (isNotEmpty()) {
|
|
486
|
+
// cacheKey 通常和 selected/zoom level 同帧变化。先淘汰当前 key 可能存在的旧截图,
|
|
487
|
+
// 再延后一帧重绘,避免切换选中态时命中 stale bitmap。
|
|
488
|
+
invalidateCurrentSnapshotCache()
|
|
489
|
+
markCustomMarkerContentDirty(32)
|
|
490
|
+
} else {
|
|
491
|
+
pendingIconUri?.let { iconUri ->
|
|
492
|
+
marker?.let { loadAndSetIcon(iconUri, it) }
|
|
493
|
+
}
|
|
494
|
+
}
|
|
486
495
|
}
|
|
487
496
|
|
|
488
497
|
/**
|
|
@@ -993,6 +1002,11 @@ class MarkerView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
993
1002
|
}
|
|
994
1003
|
}
|
|
995
1004
|
|
|
1005
|
+
private fun cancelPendingMarkerIconUpdate() {
|
|
1006
|
+
pendingMarkerIconUpdate?.let { mainHandler.removeCallbacks(it) }
|
|
1007
|
+
pendingMarkerIconUpdate = null
|
|
1008
|
+
}
|
|
1009
|
+
|
|
996
1010
|
private fun invalidateAppliedCustomMarkerCaches(clearGlobalCache: Boolean) {
|
|
997
1011
|
val key = lastAppliedCustomMarkerKey ?: return
|
|
998
1012
|
if (clearGlobalCache) {
|
|
@@ -1002,6 +1016,12 @@ class MarkerView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
1002
1016
|
lastAppliedCustomMarkerKey = null
|
|
1003
1017
|
}
|
|
1004
1018
|
|
|
1019
|
+
private fun invalidateCurrentSnapshotCache() {
|
|
1020
|
+
val key = resolveMarkerBitmapSnapshot()?.fullCacheKey ?: return
|
|
1021
|
+
BitmapDescriptorCache.remove(key)
|
|
1022
|
+
IconBitmapCache.remove(key)
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1005
1025
|
private fun markCustomMarkerContentDirty(delayMs: Long = 16L) {
|
|
1006
1026
|
if (isRemoving || isEmpty()) {
|
|
1007
1027
|
return
|
|
@@ -1324,6 +1344,9 @@ class MarkerView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
1324
1344
|
* 移除标记
|
|
1325
1345
|
*/
|
|
1326
1346
|
fun removeMarker() {
|
|
1347
|
+
cancelPendingDetachRemoval()
|
|
1348
|
+
cancelPendingMarkerIconUpdate()
|
|
1349
|
+
|
|
1327
1350
|
// 停止平滑移动
|
|
1328
1351
|
stopSmoothMove()
|
|
1329
1352
|
smoothMoveMarker?.destroy()
|
|
@@ -1336,19 +1359,30 @@ class MarkerView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
1336
1359
|
marker = null
|
|
1337
1360
|
}
|
|
1338
1361
|
|
|
1362
|
+
override fun onAttachedToWindow() {
|
|
1363
|
+
super.onAttachedToWindow()
|
|
1364
|
+
cancelPendingDetachRemoval()
|
|
1365
|
+
isRemoving = false
|
|
1366
|
+
|
|
1367
|
+
if (isNotEmpty() && marker != null) {
|
|
1368
|
+
scheduleMarkerIconUpdate(16)
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1339
1372
|
override fun onDetachedFromWindow() {
|
|
1340
1373
|
super.onDetachedFromWindow()
|
|
1341
1374
|
|
|
1342
1375
|
// 🔑 关键修复:使用 post 延迟检查
|
|
1343
|
-
|
|
1344
|
-
mainHandler.removeCallbacksAndMessages(null)
|
|
1345
|
-
pendingMarkerIconUpdate = null
|
|
1376
|
+
cancelPendingDetachRemoval()
|
|
1346
1377
|
|
|
1347
|
-
// 延迟检查 parent
|
|
1348
|
-
|
|
1378
|
+
// 延迟检查 parent 状态。React 更新 children 时可能会短暂 detach/attach,
|
|
1379
|
+
// 过早删除会导致点击后其它 Marker 消失。
|
|
1380
|
+
val task = Runnable {
|
|
1381
|
+
pendingDetachRemovalTask = null
|
|
1349
1382
|
if (parent == null) {
|
|
1350
1383
|
// 标记正在移除
|
|
1351
1384
|
isRemoving = true
|
|
1385
|
+
cancelPendingMarkerIconUpdate()
|
|
1352
1386
|
|
|
1353
1387
|
// 🔑 修复:不要清空全局缓存
|
|
1354
1388
|
// 理由:会影响其他 Marker 的性能
|
|
@@ -1358,6 +1392,13 @@ class MarkerView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
1358
1392
|
removeMarker()
|
|
1359
1393
|
}
|
|
1360
1394
|
}
|
|
1395
|
+
pendingDetachRemovalTask = task
|
|
1396
|
+
mainHandler.postDelayed(task, 500)
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
private fun cancelPendingDetachRemoval() {
|
|
1400
|
+
pendingDetachRemovalTask?.let { mainHandler.removeCallbacks(it) }
|
|
1401
|
+
pendingDetachRemovalTask = null
|
|
1361
1402
|
}
|
|
1362
1403
|
|
|
1363
1404
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoGaodeMapOfflineModule.js","sourceRoot":"","sources":["../src/ExpoGaodeMapOfflineModule.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"ExpoGaodeMapOfflineModule.js","sourceRoot":"","sources":["../src/ExpoGaodeMapOfflineModule.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAsLzD,IAAI,iBAAiB,GAAqC,IAAI,CAAC;AAE/D,SAAS,eAAe;IACtB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,iBAAiB,GAAG,mBAAmB,CAA4B,qBAAqB,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,SAAS,mBAAmB,CAC1B,MAAiC,EACjC,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,EAA+B,EAAE;IACxD,GAAG,CAAC,OAAO,EAAE,IAAI;QACf,OAAO,mBAAmB,CAAC,eAAe,EAAE,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;CACF,CAAC,CAAC","sourcesContent":["/**\n * 高德地图离线地图原生模块\n */\n\nimport { NativeModule, requireNativeModule } from 'expo';\nimport type {\n OfflineMapInfo,\n OfflineMapDownloadConfig,\n OfflineMapStorageInfo,\n OfflineMapEvents,\n} from './types/offline.types';\n\n/**\n * 离线地图原生模块接口\n */\ndeclare class ExpoGaodeMapOfflineModule extends NativeModule<OfflineMapEvents> {\n // ==================== 地图列表管理 ====================\n\n /**\n * 打开高德 3D 地图 SDK 官方离线地图 UI 组件(Android)。\n * 官方组件内置城市下载、暂停、更新、删除和城市搜索。\n */\n openOfflineMapUI(): Promise<void>;\n \n /**\n * 获取所有可下载的城市列表\n * @returns Promise<OfflineMapInfo[]> 城市列表\n */\n getAvailableCities(): Promise<OfflineMapInfo[]>;\n \n /**\n * 获取所有省份列表\n * @returns Promise<OfflineMapInfo[]> 省份列表\n */\n getAvailableProvinces(): Promise<OfflineMapInfo[]>;\n \n /**\n * 根据省份代码获取城市列表\n * @param provinceCode 省份代码\n * @returns Promise<OfflineMapInfo[]> 该省份下的城市列表\n */\n getCitiesByProvince(provinceCode: string): Promise<OfflineMapInfo[]>;\n \n /**\n * 获取已下载的地图列表\n * @returns Promise<OfflineMapInfo[]> 已下载的地图列表\n */\n getDownloadedMaps(): Promise<OfflineMapInfo[]>;\n \n // ==================== 下载管理 ====================\n \n /**\n * 开始下载离线地图\n * @param config 下载配置\n */\n startDownload(config: OfflineMapDownloadConfig): Promise<void>;\n \n /**\n * 暂停下载\n * @param cityCode 城市代码\n */\n pauseDownload(cityCode: string): Promise<void>;\n \n /**\n * 恢复下载\n * @param cityCode 城市代码\n */\n resumeDownload(cityCode: string): Promise<void>;\n \n /**\n * 取消下载\n * @param cityCode 城市代码\n */\n cancelDownload(cityCode: string): Promise<void>;\n \n /**\n * 删除离线地图\n * @param cityCode 城市代码\n */\n deleteMap(cityCode: string): Promise<void>;\n \n /**\n * 更新离线地图\n * @param cityCode 城市代码\n */\n updateMap(cityCode: string): Promise<void>;\n \n /**\n * 检查是否有可用更新\n * @param cityCode 城市代码\n * @returns Promise<boolean> 是否有更新\n */\n checkUpdate(cityCode: string): Promise<boolean>;\n \n // ==================== 状态查询 ====================\n \n /**\n * 检查地图是否已下载\n * @param cityCode 城市代码\n * @returns Promise<boolean> 是否已下载\n */\n isMapDownloaded(cityCode: string): Promise<boolean>;\n \n /**\n * 获取地图下载状态\n * @param cityCode 城市代码\n * @returns Promise<OfflineMapInfo> 地图信息\n */\n getMapStatus(cityCode: string): Promise<OfflineMapInfo>;\n \n /**\n * 获取所有下载任务的总进度\n * @returns Promise<number> 总进度 (0-100)\n */\n getTotalProgress(): Promise<number>;\n \n /**\n * 获取当前正在下载的城市列表\n * @returns Promise<string[]> 城市代码列表\n */\n getDownloadingCities(): Promise<string[]>;\n \n // ==================== 存储管理 ====================\n \n /**\n * 获取离线地图占用的存储空间(字节)\n * @returns Promise<number> 存储空间大小\n */\n getStorageSize(): Promise<number>;\n \n /**\n * 获取详细的存储信息\n * @returns Promise<OfflineMapStorageInfo> 存储信息\n */\n getStorageInfo(): Promise<OfflineMapStorageInfo>;\n \n /**\n * 清理所有离线地图\n */\n clearAllMaps(): Promise<void>;\n \n /**\n * 设置离线地图存储路径\n * @param path 存储路径\n */\n setStoragePath(path: string): void;\n \n /**\n * 获取离线地图存储路径\n * @returns Promise<string> 存储路径\n */\n getStoragePath(): Promise<string>;\n \n // ==================== 批量操作 ====================\n \n /**\n * 批量下载地图\n * @param cityCodes 城市代码列表\n * @param allowCellular 是否允许移动网络\n */\n batchDownload(cityCodes: string[], allowCellular?: boolean): Promise<void>;\n \n /**\n * 批量删除地图\n * @param cityCodes 城市代码列表\n */\n batchDelete(cityCodes: string[]): Promise<void>;\n \n /**\n * 批量更新地图\n * @param cityCodes 城市代码列表\n */\n batchUpdate(cityCodes: string[]): Promise<void>;\n \n /**\n * 暂停所有下载任务\n */\n pauseAllDownloads(): Promise<void>;\n \n /**\n * 恢复所有下载任务\n */\n resumeAllDownloads(): Promise<void>;\n\n}\n\nlet nativeModuleCache: ExpoGaodeMapOfflineModule | null = null;\n\nfunction getNativeModule(): ExpoGaodeMapOfflineModule {\n if (!nativeModuleCache) {\n nativeModuleCache = requireNativeModule<ExpoGaodeMapOfflineModule>('ExpoGaodeMapOffline');\n }\n return nativeModuleCache;\n}\n\nfunction getBoundNativeValue(\n module: ExpoGaodeMapOfflineModule,\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 ExpoGaodeMapOfflineModule, {\n get(_target, prop) {\n return getBoundNativeValue(getNativeModule(), prop);\n },\n});\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import ExpoGaodeMapModule from './ExpoGaodeMapModule';
|
|
3
4
|
import { ErrorHandler } from './utils/ErrorHandler';
|
|
@@ -126,14 +127,7 @@ const ExpoGaodeMapView = React.forwardRef((props, ref) => {
|
|
|
126
127
|
const { children, style, ...otherProps } = props;
|
|
127
128
|
const { overlays, uiControls } = React.useMemo(() => splitMapChildren(children), [children]);
|
|
128
129
|
const containerStyle = React.useMemo(() => [styles.container, style], [style]);
|
|
129
|
-
return (
|
|
130
|
-
<View style={containerStyle}>
|
|
131
|
-
<NativeView ref={nativeRef} style={StyleSheet.absoluteFill} {...otherProps}>
|
|
132
|
-
{overlays}
|
|
133
|
-
</NativeView>
|
|
134
|
-
{uiControls}
|
|
135
|
-
</View>
|
|
136
|
-
</MapContext.Provider>);
|
|
130
|
+
return (_jsx(MapContext.Provider, { value: apiRef, children: _jsxs(View, { style: containerStyle, children: [_jsx(NativeView, { ref: nativeRef, style: StyleSheet.absoluteFill, ...otherProps, children: overlays }), uiControls] }) }));
|
|
137
131
|
});
|
|
138
132
|
ExpoGaodeMapView.displayName = 'ExpoGaodeMapView';
|
|
139
133
|
export default ExpoGaodeMapView;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoGaodeMapView.js","sourceRoot":"","sources":["../src/ExpoGaodeMapView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAI5D,MAAM,aAAa,GAAG,2BAA2B,CAAiD,kBAAkB,CAAC,C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EAAE,CAAC;QACP,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,QAAQ;KACnB;CACF,CAAC,CAAC","sourcesContent":["import * as React from 'react';\n\nimport type {\n MapViewProps,\n MapViewRef,\n CameraPosition,\n CameraUpdate,\n LatLng,\n Point,\n LatLngPoint,\n} from './types';\nimport ExpoGaodeMapModule from './ExpoGaodeMapModule';\n\nimport { ErrorHandler } from './utils/ErrorHandler';\nimport { MapContext } from './components/MapContext';\nimport { MapUI } from './components/MapUI';\nimport { createLazyNativeViewManager } from './utils/lazyNativeViewManager';\nimport { View, StyleSheet } from 'react-native';\nimport { normalizeLatLng } from './utils/GeoUtils';\nimport type { FitToCoordinatesOptions } from './types/route-playback.types';\nimport { fitCameraToCoordinates } from './utils/RouteUtils';\n\nexport type { MapViewRef } from './types';\n\nconst getNativeView = createLazyNativeViewManager<MapViewProps & { ref?: React.Ref<MapViewRef> }>('ExpoGaodeMapView');\n\nfunction splitMapChildren(children: React.ReactNode) {\n const overlays: React.ReactNode[] = [];\n const uiControls: React.ReactNode[] = [];\n\n React.Children.forEach(children, (child) => {\n if (\n React.isValidElement(child) &&\n (child.type === MapUI || (child.type as { isMapUI?: boolean })?.isMapUI)\n ) {\n uiControls.push(child);\n } else {\n overlays.push(child);\n }\n });\n\n return { overlays, uiControls };\n}\n\n/**\n * 高德地图视图组件,提供地图操作API和覆盖物管理功能\n * \n * @param props - 组件属性\n * @param ref - 外部ref引用,用于访问地图API方法\n * @returns 返回包含地图视图和上下文提供者的React组件\n * \n * @remarks\n * 该组件内部维护 nativeRef,用于将 JS ref API 转发到原生地图视图。\n * MapContext 会向子组件共享同一组地图 API 方法。\n * \n * 提供的主要API功能包括:\n * - 相机控制(移动、缩放、获取当前位置)\n * - 屏幕坐标转换、截图、根据坐标集合拟合相机\n * \n * 所有API方法都会检查地图是否已初始化,未初始化时抛出错误\n */\nconst ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref) => {\n const privacyStatus = ExpoGaodeMapModule.getPrivacyStatus();\n if (!privacyStatus.isReady) {\n throw ErrorHandler.privacyNotAgreed('map');\n }\n\n const nativeRef = React.useRef<MapViewRef>(null);\n const NativeView = React.useMemo(() => getNativeView(), []);\n\n const callNativeMethod = React.useCallback(<T extends (...args: never[]) => unknown>(\n methodName: keyof MapViewRef,\n ...args: Parameters<T>\n ) => {\n if (!nativeRef.current) {\n throw ErrorHandler.mapViewNotInitialized(methodName as string);\n }\n\n const nativeMethod = Reflect.get(\n nativeRef.current as object,\n methodName,\n nativeRef.current as object\n );\n\n if (typeof nativeMethod !== 'function') {\n throw new Error(`Method '${methodName}' is not available on native view. Make sure the native module is linked and rebuilt.`);\n }\n\n return (nativeMethod as (...methodArgs: Parameters<T>) => ReturnType<T>).apply(\n nativeRef.current,\n args\n );\n }, []);\n \n /**\n * 通用 API 方法包装器,统一处理初始化检查和错误包装。\n */\n const createApiMethod = React.useCallback(<T extends (...args: never[]) => unknown>(\n methodName: keyof MapViewRef\n ) => {\n return ((...args: Parameters<T>) => {\n try {\n return callNativeMethod<T>(methodName, ...args);\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, methodName as string);\n }\n }) as T;\n }, [callNativeMethod]);\n\n /**\n * 使用通用包装器创建所有 API 方法\n * 所有方法共享相同的错误处理逻辑\n */\n const apiRef: MapViewRef = React.useMemo(() => ({\n moveCamera: (position: CameraUpdate, duration?: number) => {\n try {\n const normalizedPosition = {\n ...position,\n target: position.target ? normalizeLatLng(position.target) : undefined,\n };\n return callNativeMethod<(cameraPosition: CameraUpdate, animationDuration: number) => Promise<void>>(\n 'moveCamera',\n normalizedPosition,\n duration ?? 0\n );\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, 'moveCamera');\n }\n },\n getLatLng: createApiMethod<(point: Point) => Promise<LatLng>>('getLatLng'),\n setCenter: (center: LatLngPoint, animated?: boolean) => {\n try {\n return callNativeMethod<(normalizedCenter: LatLng, animatedFlag: boolean) => Promise<void>>(\n 'setCenter',\n normalizeLatLng(center),\n animated ?? false\n );\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, 'setCenter');\n }\n },\n setZoom: (zoom: number, animated?: boolean) => {\n try {\n return callNativeMethod<(zoomLevel: number, animatedFlag: boolean) => Promise<void>>(\n 'setZoom',\n zoom,\n animated ?? false\n );\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, 'setZoom');\n }\n },\n getCameraPosition: createApiMethod<() => Promise<CameraPosition>>('getCameraPosition'),\n takeSnapshot: createApiMethod<() => Promise<string>>('takeSnapshot'),\n fitToCoordinates: async (points: LatLngPoint[], options?: FitToCoordinatesOptions) => {\n try {\n await fitCameraToCoordinates(\n {\n moveCamera: (position, duration) =>\n callNativeMethod<(cameraPosition: CameraUpdate, animationDuration: number) => Promise<void>>(\n 'moveCamera',\n position,\n duration ?? 0\n ),\n getCameraPosition: () =>\n callNativeMethod<() => Promise<CameraPosition>>('getCameraPosition'),\n },\n points,\n options\n );\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, 'fitToCoordinates');\n }\n },\n }), [callNativeMethod, createApiMethod]);\n\n /**\n * 获取当前地图实例的API引用\n * @returns 返回地图API的引用对象,可用于调用地图相关方法\n */\n React.useImperativeHandle(ref, () => apiRef, [apiRef]);\n\n // 分离 children:区分原生覆盖物和普通 UI 组件\n const { children, style, ...otherProps } = props;\n const { overlays, uiControls } = React.useMemo(\n () => splitMapChildren(children),\n [children]\n );\n const containerStyle = React.useMemo(\n () => [styles.container, style],\n [style]\n );\n\n return (\n <MapContext.Provider value={apiRef}>\n <View style={containerStyle}>\n <NativeView\n ref={nativeRef}\n style={StyleSheet.absoluteFill}\n {...otherProps}\n >\n {overlays}\n </NativeView>\n {uiControls}\n </View>\n </MapContext.Provider>\n );\n});\n\nExpoGaodeMapView.displayName = 'ExpoGaodeMapView';\n\nexport default ExpoGaodeMapView;\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n position: 'relative',\n overflow: 'hidden',\n },\n});\n"]}
|
|
1
|
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;IAEF,OAAO,CACL,KAAC,UAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,YAChC,MAAC,IAAI,IAAC,KAAK,EAAE,cAAc,aACzB,KAAC,UAAU,IACT,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,UAAU,CAAC,YAAY,KAC1B,UAAU,YAEb,QAAQ,GACE,EACZ,UAAU,IACN,GACa,CACvB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAElD,eAAe,gBAAgB,CAAC;AAEhC,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,QAAQ;KACnB;CACF,CAAC,CAAC","sourcesContent":["import * as React from 'react';\n\nimport type {\n MapViewProps,\n MapViewRef,\n CameraPosition,\n CameraUpdate,\n LatLng,\n Point,\n LatLngPoint,\n} from './types';\nimport ExpoGaodeMapModule from './ExpoGaodeMapModule';\n\nimport { ErrorHandler } from './utils/ErrorHandler';\nimport { MapContext } from './components/MapContext';\nimport { MapUI } from './components/MapUI';\nimport { createLazyNativeViewManager } from './utils/lazyNativeViewManager';\nimport { View, StyleSheet } from 'react-native';\nimport { normalizeLatLng } from './utils/GeoUtils';\nimport type { FitToCoordinatesOptions } from './types/route-playback.types';\nimport { fitCameraToCoordinates } from './utils/RouteUtils';\n\nexport type { MapViewRef } from './types';\n\nconst getNativeView = createLazyNativeViewManager<MapViewProps & { ref?: React.Ref<MapViewRef> }>('ExpoGaodeMapView');\n\nfunction splitMapChildren(children: React.ReactNode) {\n const overlays: React.ReactNode[] = [];\n const uiControls: React.ReactNode[] = [];\n\n React.Children.forEach(children, (child) => {\n if (\n React.isValidElement(child) &&\n (child.type === MapUI || (child.type as { isMapUI?: boolean })?.isMapUI)\n ) {\n uiControls.push(child);\n } else {\n overlays.push(child);\n }\n });\n\n return { overlays, uiControls };\n}\n\n/**\n * 高德地图视图组件,提供地图操作API和覆盖物管理功能\n * \n * @param props - 组件属性\n * @param ref - 外部ref引用,用于访问地图API方法\n * @returns 返回包含地图视图和上下文提供者的React组件\n * \n * @remarks\n * 该组件内部维护 nativeRef,用于将 JS ref API 转发到原生地图视图。\n * MapContext 会向子组件共享同一组地图 API 方法。\n * \n * 提供的主要API功能包括:\n * - 相机控制(移动、缩放、获取当前位置)\n * - 屏幕坐标转换、截图、根据坐标集合拟合相机\n * \n * 所有API方法都会检查地图是否已初始化,未初始化时抛出错误\n */\nconst ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref) => {\n const privacyStatus = ExpoGaodeMapModule.getPrivacyStatus();\n if (!privacyStatus.isReady) {\n throw ErrorHandler.privacyNotAgreed('map');\n }\n\n const nativeRef = React.useRef<MapViewRef>(null);\n const NativeView = React.useMemo(() => getNativeView(), []);\n\n const callNativeMethod = React.useCallback(<T extends (...args: never[]) => unknown>(\n methodName: keyof MapViewRef,\n ...args: Parameters<T>\n ) => {\n if (!nativeRef.current) {\n throw ErrorHandler.mapViewNotInitialized(methodName as string);\n }\n\n const nativeMethod = Reflect.get(\n nativeRef.current as object,\n methodName,\n nativeRef.current as object\n );\n\n if (typeof nativeMethod !== 'function') {\n throw new Error(`Method '${methodName}' is not available on native view. Make sure the native module is linked and rebuilt.`);\n }\n\n return (nativeMethod as (...methodArgs: Parameters<T>) => ReturnType<T>).apply(\n nativeRef.current,\n args\n );\n }, []);\n \n /**\n * 通用 API 方法包装器,统一处理初始化检查和错误包装。\n */\n const createApiMethod = React.useCallback(<T extends (...args: never[]) => unknown>(\n methodName: keyof MapViewRef\n ) => {\n return ((...args: Parameters<T>) => {\n try {\n return callNativeMethod<T>(methodName, ...args);\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, methodName as string);\n }\n }) as T;\n }, [callNativeMethod]);\n\n /**\n * 使用通用包装器创建所有 API 方法\n * 所有方法共享相同的错误处理逻辑\n */\n const apiRef: MapViewRef = React.useMemo(() => ({\n moveCamera: (position: CameraUpdate, duration?: number) => {\n try {\n const normalizedPosition = {\n ...position,\n target: position.target ? normalizeLatLng(position.target) : undefined,\n };\n return callNativeMethod<(cameraPosition: CameraUpdate, animationDuration: number) => Promise<void>>(\n 'moveCamera',\n normalizedPosition,\n duration ?? 0\n );\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, 'moveCamera');\n }\n },\n getLatLng: createApiMethod<(point: Point) => Promise<LatLng>>('getLatLng'),\n setCenter: (center: LatLngPoint, animated?: boolean) => {\n try {\n return callNativeMethod<(normalizedCenter: LatLng, animatedFlag: boolean) => Promise<void>>(\n 'setCenter',\n normalizeLatLng(center),\n animated ?? false\n );\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, 'setCenter');\n }\n },\n setZoom: (zoom: number, animated?: boolean) => {\n try {\n return callNativeMethod<(zoomLevel: number, animatedFlag: boolean) => Promise<void>>(\n 'setZoom',\n zoom,\n animated ?? false\n );\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, 'setZoom');\n }\n },\n getCameraPosition: createApiMethod<() => Promise<CameraPosition>>('getCameraPosition'),\n takeSnapshot: createApiMethod<() => Promise<string>>('takeSnapshot'),\n fitToCoordinates: async (points: LatLngPoint[], options?: FitToCoordinatesOptions) => {\n try {\n await fitCameraToCoordinates(\n {\n moveCamera: (position, duration) =>\n callNativeMethod<(cameraPosition: CameraUpdate, animationDuration: number) => Promise<void>>(\n 'moveCamera',\n position,\n duration ?? 0\n ),\n getCameraPosition: () =>\n callNativeMethod<() => Promise<CameraPosition>>('getCameraPosition'),\n },\n points,\n options\n );\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, 'fitToCoordinates');\n }\n },\n }), [callNativeMethod, createApiMethod]);\n\n /**\n * 获取当前地图实例的API引用\n * @returns 返回地图API的引用对象,可用于调用地图相关方法\n */\n React.useImperativeHandle(ref, () => apiRef, [apiRef]);\n\n // 分离 children:区分原生覆盖物和普通 UI 组件\n const { children, style, ...otherProps } = props;\n const { overlays, uiControls } = React.useMemo(\n () => splitMapChildren(children),\n [children]\n );\n const containerStyle = React.useMemo(\n () => [styles.container, style],\n [style]\n );\n\n return (\n <MapContext.Provider value={apiRef}>\n <View style={containerStyle}>\n <NativeView\n ref={nativeRef}\n style={StyleSheet.absoluteFill}\n {...otherProps}\n >\n {overlays}\n </NativeView>\n {uiControls}\n </View>\n </MapContext.Provider>\n );\n});\n\nExpoGaodeMapView.displayName = 'ExpoGaodeMapView';\n\nexport default ExpoGaodeMapView;\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n position: 'relative',\n overflow: 'hidden',\n },\n});\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import type { AreaMaskOverlayProps } from '../types/route-playback.types';
|
|
3
|
-
export declare function AreaMaskOverlay({ rings, polygonProps }: AreaMaskOverlayProps):
|
|
2
|
+
export declare function AreaMaskOverlay({ rings, polygonProps }: AreaMaskOverlayProps): import("react/jsx-runtime").JSX.Element | null;
|
|
4
3
|
export default AreaMaskOverlay;
|
|
5
4
|
//# sourceMappingURL=AreaMaskOverlay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AreaMaskOverlay.d.ts","sourceRoot":"","sources":["../../src/components/AreaMaskOverlay.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AreaMaskOverlay.d.ts","sourceRoot":"","sources":["../../src/components/AreaMaskOverlay.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAK1E,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,oBAAoB,kDAwB5E;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { normalizeLatLngList } from '../utils/GeoUtils';
|
|
3
4
|
import { parseMultiRingPolyline } from '../utils/RouteUtils';
|
|
@@ -14,7 +15,7 @@ export function AreaMaskOverlay({ rings, polygonProps }) {
|
|
|
14
15
|
if (!normalizedPoints.length) {
|
|
15
16
|
return null;
|
|
16
17
|
}
|
|
17
|
-
return (
|
|
18
|
+
return (_jsx(Polygon, { points: normalizedPoints, fillColor: polygonProps?.fillColor ?? 'rgba(15, 23, 42, 0.45)', strokeColor: polygonProps?.strokeColor ?? 'rgba(15, 23, 42, 0.8)', strokeWidth: polygonProps?.strokeWidth ?? 1, ...polygonProps }));
|
|
18
19
|
}
|
|
19
20
|
export default AreaMaskOverlay;
|
|
20
21
|
//# sourceMappingURL=AreaMaskOverlay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AreaMaskOverlay.js","sourceRoot":"","sources":["../../src/components/AreaMaskOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,UAAU,eAAe,CAAC,EAAE,KAAK,EAAE,YAAY,EAAwB;IAC3E,kCAAkC;IAClC,6BAA6B;IAC7B,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;QAC7C,CAAC;QAED,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,
|
|
1
|
+
{"version":3,"file":"AreaMaskOverlay.js","sourceRoot":"","sources":["../../src/components/AreaMaskOverlay.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,UAAU,eAAe,CAAC,EAAE,KAAK,EAAE,YAAY,EAAwB;IAC3E,kCAAkC;IAClC,6BAA6B;IAC7B,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;QAC7C,CAAC;QAED,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,KAAC,OAAO,IACN,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,YAAY,EAAE,SAAS,IAAI,wBAAwB,EAC9D,WAAW,EAAE,YAAY,EAAE,WAAW,IAAI,uBAAuB,EACjE,WAAW,EAAE,YAAY,EAAE,WAAW,IAAI,CAAC,KACvC,YAAY,GAChB,CACH,CAAC;AACJ,CAAC;AAED,eAAe,eAAe,CAAC","sourcesContent":["import * as React from 'react';\n\nimport type { AreaMaskOverlayProps } from '../types/route-playback.types';\nimport { normalizeLatLngList } from '../utils/GeoUtils';\nimport { parseMultiRingPolyline } from '../utils/RouteUtils';\nimport { Polygon } from './overlays';\n\nexport function AreaMaskOverlay({ rings, polygonProps }: AreaMaskOverlayProps) {\n // 支持直接传多环坐标,或传高德返回的 polyline 字符串。\n // 最终都落到 Polygon 的“带孔多边形”能力上。\n const normalizedPoints = React.useMemo(() => {\n if (typeof rings === 'string') {\n return parseMultiRingPolyline(rings).rings;\n }\n\n return normalizeLatLngList(rings);\n }, [rings]);\n\n if (!normalizedPoints.length) {\n return null;\n }\n\n return (\n <Polygon\n points={normalizedPoints}\n fillColor={polygonProps?.fillColor ?? 'rgba(15, 23, 42, 0.45)'}\n strokeColor={polygonProps?.strokeColor ?? 'rgba(15, 23, 42, 0.8)'}\n strokeWidth={polygonProps?.strokeWidth ?? 1}\n {...polygonProps}\n />\n );\n}\n\nexport default AreaMaskOverlay;\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { FoldState } from '../utils/PlatformDetector';
|
|
3
|
+
import type { DeviceInfo } from '../utils/PlatformDetector';
|
|
4
|
+
import type { MapViewProps, MapViewRef } from '../types';
|
|
4
5
|
/**
|
|
5
6
|
* 折叠屏适配配置
|
|
6
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FoldableMapView.d.ts","sourceRoot":"","sources":["../../src/components/FoldableMapView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAKpE,OAAO,EAAoB,
|
|
1
|
+
{"version":3,"file":"FoldableMapView.d.ts","sourceRoot":"","sources":["../../src/components/FoldableMapView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAKpE,OAAO,EAAoB,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oBAAoB;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qBAAqB;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe;IACf,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IACvE,eAAe;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,cAAc;IACd,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AA2ED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA0F1D,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,EACnC,MAAM,CAAC,EAAE,cAAc;;;;EA8DxB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
3
|
import { Platform } from 'react-native';
|
|
3
4
|
import ExpoGaodeMapView from '../ExpoGaodeMapView';
|
|
@@ -119,7 +120,7 @@ export const FoldableMapView = ({ foldableConfig, ...mapProps }) => {
|
|
|
119
120
|
removeListener();
|
|
120
121
|
};
|
|
121
122
|
}, [config.debug, deviceInfo.isFoldable, handleFoldStateChange]);
|
|
122
|
-
return (
|
|
123
|
+
return (_jsx(ExpoGaodeMapView, { ref: mapRef, ...mapProps }));
|
|
123
124
|
};
|
|
124
125
|
/**
|
|
125
126
|
* 折叠屏适配 Hook
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FoldableMapView.js","sourceRoot":"","sources":["../../src/components/FoldableMapView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAA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AC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC;oBACvB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;gBACjD,CAAC;YACH,CAAC;QACH,CAAC;QAED,YAAY,CAAC,OAAO,GAAG,YAAY,CAAC;QACpC,YAAY,CAAC,YAAY,CAAC,CAAC;QAC3B,aAAa,CAAC,OAAO,CAAC,CAAC;QACvB,YAAY,CAAC,iBAAiB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;YACxD,OAAO;QACT,CAAC;QAED,MAAM,YAAY,GAAG,gBAAgB,CAAC,YAAY,EAAE,CAAC;QACrD,YAAY,CAAC,OAAO,GAAG,YAAY,CAAC;QACpC,YAAY,CAAC,YAAY,CAAC,CAAC;QAE3B,MAAM,cAAc,GAAG,gBAAgB,CAAC,0BAA0B,CAChE,KAAK,EAAE,OAAmB,EAAE,EAAE;YAC5B,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC,CACF,CAAC;QAEF,OAAO,GAAG,EAAE;YACV,cAAc,EAAE,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,qBAAqB,EAAE,MAAM,CAAC,CAAC,CAAC;IAE3D,OAAO;QACL,SAAS;QACT,UAAU;QACV,UAAU,EAAE,UAAU,CAAC,UAAU;KAClC,CAAC;AACJ,CAAC","sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from 'react';\nimport { Platform } from 'react-native';\nimport ExpoGaodeMapView from '../ExpoGaodeMapView';\n\nimport { useEventCallback } from '../hooks/useEventCallback';\nimport { PlatformDetector, DeviceInfo, FoldState } from '../utils/PlatformDetector';\nimport { MapViewProps, MapViewRef } from '../types';\n\n/**\n * 折叠屏适配配置\n */\nexport interface FoldableConfig {\n /** 折叠时是否自动调整缩放级别 */\n autoAdjustZoom?: boolean;\n /** 展开时的缩放级别增量 */\n unfoldedZoomDelta?: number;\n /** 是否在折叠/展开时保持中心点 */\n keepCenterOnFold?: boolean;\n /** 折叠状态变化回调 */\n onFoldStateChange?: (state: FoldState, deviceInfo: DeviceInfo) => void;\n /** 是否启用调试日志 */\n debug?: boolean;\n}\n\n/**\n * 折叠屏地图视图组件\n * \n * 自动适配折叠屏设备的展开/折叠状态变化\n */\nexport interface FoldableMapViewProps extends MapViewProps {\n /** 折叠屏适配配置 */\n foldableConfig?: FoldableConfig;\n}\n\nconst DEFAULT_FOLDABLE_CONFIG: Required<FoldableConfig> = {\n autoAdjustZoom: true,\n unfoldedZoomDelta: 1,\n keepCenterOnFold: true,\n onFoldStateChange: () => {},\n debug: false,\n};\n\nfunction clampZoomLevel(zoom: number): number {\n return Math.max(3, Math.min(20, zoom));\n}\n\nfunction createFoldableConfig(config?: FoldableConfig): Required<FoldableConfig> {\n return {\n ...DEFAULT_FOLDABLE_CONFIG,\n ...config,\n };\n}\n\nasync function applyFoldStateCameraAdjustment(\n mapRef: React.RefObject<MapViewRef | null>,\n oldState: FoldState,\n newState: FoldState,\n config: Required<FoldableConfig>,\n debugPrefix: 'FoldableMapView' | 'useFoldableMap'\n): Promise<void> {\n if (!mapRef.current || !config.autoAdjustZoom) {\n return;\n }\n\n const currentCamera = await mapRef.current.getCameraPosition();\n if (!currentCamera) {\n if (config.debug) {\n console.warn(`[${debugPrefix}] 无法获取相机位置`);\n }\n return;\n }\n\n const isUnfolding = newState === FoldState.UNFOLDED && oldState === FoldState.FOLDED;\n const isFolding = newState === FoldState.FOLDED && oldState === FoldState.UNFOLDED;\n\n if (config.debug) {\n console.log(`[${debugPrefix}] 折叠状态变化:`, {\n oldState,\n newState,\n isUnfolding,\n isFolding,\n currentZoom: currentCamera.zoom,\n });\n }\n\n if (!isUnfolding && !isFolding) {\n return;\n }\n\n const currentZoom = currentCamera.zoom ?? 15;\n const zoomDelta = isUnfolding ? config.unfoldedZoomDelta : -config.unfoldedZoomDelta;\n const nextZoom = clampZoomLevel(currentZoom + zoomDelta);\n\n if (config.debug) {\n console.log(`[${debugPrefix}] 调整缩放:`, {\n oldZoom: currentZoom,\n newZoom: nextZoom,\n delta: zoomDelta,\n });\n }\n\n await mapRef.current.moveCamera({\n target: config.keepCenterOnFold ? currentCamera.target : undefined,\n zoom: nextZoom,\n }, 300);\n}\n\nexport const FoldableMapView: React.FC<FoldableMapViewProps> = ({\n foldableConfig,\n ...mapProps\n}) => {\n const mapRef = useRef<MapViewRef>(null);\n const [currentFoldState, setCurrentFoldState] = useState<FoldState>(FoldState.UNKNOWN);\n const [deviceInfo, setDeviceInfo] = useState<DeviceInfo>(PlatformDetector.getDeviceInfo());\n const config = useMemo(() => createFoldableConfig(foldableConfig), [foldableConfig]);\n const foldStateRef = useRef(currentFoldState);\n\n const handleFoldStateChange = useEventCallback(\n async (newInfo: DeviceInfo, debugPrefix: 'FoldableMapView' | 'useFoldableMap') => {\n const newFoldState = PlatformDetector.getFoldState();\n const previousFoldState = foldStateRef.current;\n\n if (config.debug) {\n console.log(`[${debugPrefix}] 屏幕尺寸变化`);\n console.log('新设备信息:', newInfo);\n console.log('新折叠状态:', newFoldState);\n }\n\n if (newFoldState !== previousFoldState && previousFoldState !== FoldState.UNKNOWN) {\n try {\n await applyFoldStateCameraAdjustment(\n mapRef,\n previousFoldState,\n newFoldState,\n config,\n debugPrefix\n );\n } catch (error) {\n if (config.debug) {\n console.error(`[${debugPrefix}] 处理折叠状态变化失败:`, error);\n }\n }\n }\n\n foldStateRef.current = newFoldState;\n setCurrentFoldState(newFoldState);\n setDeviceInfo(newInfo);\n config.onFoldStateChange(newFoldState, newInfo);\n }\n );\n\n useEffect(() => {\n foldStateRef.current = currentFoldState;\n }, [currentFoldState]);\n\n useEffect(() => {\n const latestDeviceInfo = PlatformDetector.getDeviceInfo();\n setDeviceInfo(latestDeviceInfo);\n }, []);\n\n useEffect(() => {\n // 仅在 Android 折叠屏设备上启用\n if (Platform.OS !== 'android' || !deviceInfo.isFoldable) {\n if (config.debug) {\n console.log('[FoldableMapView] 非折叠屏设备,跳过适配');\n }\n return;\n }\n\n const initialState = PlatformDetector.getFoldState();\n foldStateRef.current = initialState;\n setCurrentFoldState(initialState);\n\n if (config.debug) {\n console.log('[FoldableMapView] 初始化折叠屏适配');\n console.log('设备信息:', deviceInfo);\n console.log('初始折叠状态:', initialState);\n }\n\n // 监听屏幕尺寸变化\n const removeListener = PlatformDetector.addDimensionChangeListener(\n async (newInfo: DeviceInfo) => {\n await handleFoldStateChange(newInfo, 'FoldableMapView');\n }\n );\n\n return () => {\n removeListener();\n };\n }, [config.debug, deviceInfo.isFoldable, handleFoldStateChange]);\n\n return (\n <ExpoGaodeMapView\n ref={mapRef}\n {...mapProps}\n />\n );\n};\n\n/**\n * 折叠屏适配 Hook\n * \n * 用于在现有地图组件中添加折叠屏适配功能\n */\nexport function useFoldableMap(\n mapRef: React.RefObject<MapViewRef>,\n config?: FoldableConfig\n) {\n const [foldState, setFoldState] = useState<FoldState>(FoldState.UNKNOWN);\n const [deviceInfo, setDeviceInfo] = useState<DeviceInfo>(PlatformDetector.getDeviceInfo());\n const mergedConfig = useMemo(() => createFoldableConfig(config), [config]);\n const foldStateRef = useRef(foldState);\n\n useEffect(() => {\n foldStateRef.current = foldState;\n }, [foldState]);\n\n const handleFoldStateChange = useEventCallback(async (newInfo: DeviceInfo) => {\n const newFoldState = PlatformDetector.getFoldState();\n const previousFoldState = foldStateRef.current;\n\n if (newFoldState !== previousFoldState && previousFoldState !== FoldState.UNKNOWN) {\n try {\n await applyFoldStateCameraAdjustment(\n mapRef,\n previousFoldState,\n newFoldState,\n mergedConfig,\n 'useFoldableMap'\n );\n } catch (error) {\n if (mergedConfig.debug) {\n console.error('[useFoldableMap] 调整失败:', error);\n }\n }\n }\n\n foldStateRef.current = newFoldState;\n setFoldState(newFoldState);\n setDeviceInfo(newInfo);\n mergedConfig.onFoldStateChange(newFoldState, newInfo);\n });\n\n useEffect(() => {\n if (Platform.OS !== 'android' || !deviceInfo.isFoldable) {\n return;\n }\n\n const initialState = PlatformDetector.getFoldState();\n foldStateRef.current = initialState;\n setFoldState(initialState);\n\n const removeListener = PlatformDetector.addDimensionChangeListener(\n async (newInfo: DeviceInfo) => {\n await handleFoldStateChange(newInfo);\n }\n );\n\n return () => {\n removeListener();\n };\n }, [deviceInfo.isFoldable, handleFoldStateChange, mapRef]);\n\n return {\n foldState,\n deviceInfo,\n isFoldable: deviceInfo.isFoldable,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FoldableMapView.js","sourceRoot":"","sources":["../../src/components/FoldableMapView.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AA8BxE,MAAM,uBAAuB,GAA6B;IACxD,cAAc,EAAE,IAAI;IACpB,iBAAiB,EAAE,CAAC;IACpB,gBAAgB,EAAE,IAAI;IACtB,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC3B,KAAK,EAAE,KAAK;CACb,CAAC;AAEF,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAuB;IACnD,OAAO;QACL,GAAG,uBAAuB;QAC1B,GAAG,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AAmB,EAAE,EAAE;YAC5B,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC,CACF,CAAC;QAEF,OAAO,GAAG,EAAE;YACV,cAAc,EAAE,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,qBAAqB,EAAE,MAAM,CAAC,CAAC,CAAC;IAE3D,OAAO;QACL,SAAS;QACT,UAAU;QACV,UAAU,EAAE,UAAU,CAAC,UAAU;KAClC,CAAC;AACJ,CAAC","sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from 'react';\nimport { Platform } from 'react-native';\nimport ExpoGaodeMapView from '../ExpoGaodeMapView';\n\nimport { useEventCallback } from '../hooks/useEventCallback';\nimport { PlatformDetector, FoldState } from '../utils/PlatformDetector';\nimport type { DeviceInfo } from '../utils/PlatformDetector';\nimport type { MapViewProps, MapViewRef } from '../types';\n\n/**\n * 折叠屏适配配置\n */\nexport interface FoldableConfig {\n /** 折叠时是否自动调整缩放级别 */\n autoAdjustZoom?: boolean;\n /** 展开时的缩放级别增量 */\n unfoldedZoomDelta?: number;\n /** 是否在折叠/展开时保持中心点 */\n keepCenterOnFold?: boolean;\n /** 折叠状态变化回调 */\n onFoldStateChange?: (state: FoldState, deviceInfo: DeviceInfo) => void;\n /** 是否启用调试日志 */\n debug?: boolean;\n}\n\n/**\n * 折叠屏地图视图组件\n * \n * 自动适配折叠屏设备的展开/折叠状态变化\n */\nexport interface FoldableMapViewProps extends MapViewProps {\n /** 折叠屏适配配置 */\n foldableConfig?: FoldableConfig;\n}\n\nconst DEFAULT_FOLDABLE_CONFIG: Required<FoldableConfig> = {\n autoAdjustZoom: true,\n unfoldedZoomDelta: 1,\n keepCenterOnFold: true,\n onFoldStateChange: () => {},\n debug: false,\n};\n\nfunction clampZoomLevel(zoom: number): number {\n return Math.max(3, Math.min(20, zoom));\n}\n\nfunction createFoldableConfig(config?: FoldableConfig): Required<FoldableConfig> {\n return {\n ...DEFAULT_FOLDABLE_CONFIG,\n ...config,\n };\n}\n\nasync function applyFoldStateCameraAdjustment(\n mapRef: React.RefObject<MapViewRef | null>,\n oldState: FoldState,\n newState: FoldState,\n config: Required<FoldableConfig>,\n debugPrefix: 'FoldableMapView' | 'useFoldableMap'\n): Promise<void> {\n if (!mapRef.current || !config.autoAdjustZoom) {\n return;\n }\n\n const currentCamera = await mapRef.current.getCameraPosition();\n if (!currentCamera) {\n if (config.debug) {\n console.warn(`[${debugPrefix}] 无法获取相机位置`);\n }\n return;\n }\n\n const isUnfolding = newState === FoldState.UNFOLDED && oldState === FoldState.FOLDED;\n const isFolding = newState === FoldState.FOLDED && oldState === FoldState.UNFOLDED;\n\n if (config.debug) {\n console.log(`[${debugPrefix}] 折叠状态变化:`, {\n oldState,\n newState,\n isUnfolding,\n isFolding,\n currentZoom: currentCamera.zoom,\n });\n }\n\n if (!isUnfolding && !isFolding) {\n return;\n }\n\n const currentZoom = currentCamera.zoom ?? 15;\n const zoomDelta = isUnfolding ? config.unfoldedZoomDelta : -config.unfoldedZoomDelta;\n const nextZoom = clampZoomLevel(currentZoom + zoomDelta);\n\n if (config.debug) {\n console.log(`[${debugPrefix}] 调整缩放:`, {\n oldZoom: currentZoom,\n newZoom: nextZoom,\n delta: zoomDelta,\n });\n }\n\n await mapRef.current.moveCamera({\n target: config.keepCenterOnFold ? currentCamera.target : undefined,\n zoom: nextZoom,\n }, 300);\n}\n\nexport const FoldableMapView: React.FC<FoldableMapViewProps> = ({\n foldableConfig,\n ...mapProps\n}) => {\n const mapRef = useRef<MapViewRef>(null);\n const [currentFoldState, setCurrentFoldState] = useState<FoldState>(FoldState.UNKNOWN);\n const [deviceInfo, setDeviceInfo] = useState<DeviceInfo>(PlatformDetector.getDeviceInfo());\n const config = useMemo(() => createFoldableConfig(foldableConfig), [foldableConfig]);\n const foldStateRef = useRef(currentFoldState);\n\n const handleFoldStateChange = useEventCallback(\n async (newInfo: DeviceInfo, debugPrefix: 'FoldableMapView' | 'useFoldableMap') => {\n const newFoldState = PlatformDetector.getFoldState();\n const previousFoldState = foldStateRef.current;\n\n if (config.debug) {\n console.log(`[${debugPrefix}] 屏幕尺寸变化`);\n console.log('新设备信息:', newInfo);\n console.log('新折叠状态:', newFoldState);\n }\n\n if (newFoldState !== previousFoldState && previousFoldState !== FoldState.UNKNOWN) {\n try {\n await applyFoldStateCameraAdjustment(\n mapRef,\n previousFoldState,\n newFoldState,\n config,\n debugPrefix\n );\n } catch (error) {\n if (config.debug) {\n console.error(`[${debugPrefix}] 处理折叠状态变化失败:`, error);\n }\n }\n }\n\n foldStateRef.current = newFoldState;\n setCurrentFoldState(newFoldState);\n setDeviceInfo(newInfo);\n config.onFoldStateChange(newFoldState, newInfo);\n }\n );\n\n useEffect(() => {\n foldStateRef.current = currentFoldState;\n }, [currentFoldState]);\n\n useEffect(() => {\n const latestDeviceInfo = PlatformDetector.getDeviceInfo();\n setDeviceInfo(latestDeviceInfo);\n }, []);\n\n useEffect(() => {\n // 仅在 Android 折叠屏设备上启用\n if (Platform.OS !== 'android' || !deviceInfo.isFoldable) {\n if (config.debug) {\n console.log('[FoldableMapView] 非折叠屏设备,跳过适配');\n }\n return;\n }\n\n const initialState = PlatformDetector.getFoldState();\n foldStateRef.current = initialState;\n setCurrentFoldState(initialState);\n\n if (config.debug) {\n console.log('[FoldableMapView] 初始化折叠屏适配');\n console.log('设备信息:', deviceInfo);\n console.log('初始折叠状态:', initialState);\n }\n\n // 监听屏幕尺寸变化\n const removeListener = PlatformDetector.addDimensionChangeListener(\n async (newInfo: DeviceInfo) => {\n await handleFoldStateChange(newInfo, 'FoldableMapView');\n }\n );\n\n return () => {\n removeListener();\n };\n }, [config.debug, deviceInfo.isFoldable, handleFoldStateChange]);\n\n return (\n <ExpoGaodeMapView\n ref={mapRef}\n {...mapProps}\n />\n );\n};\n\n/**\n * 折叠屏适配 Hook\n * \n * 用于在现有地图组件中添加折叠屏适配功能\n */\nexport function useFoldableMap(\n mapRef: React.RefObject<MapViewRef>,\n config?: FoldableConfig\n) {\n const [foldState, setFoldState] = useState<FoldState>(FoldState.UNKNOWN);\n const [deviceInfo, setDeviceInfo] = useState<DeviceInfo>(PlatformDetector.getDeviceInfo());\n const mergedConfig = useMemo(() => createFoldableConfig(config), [config]);\n const foldStateRef = useRef(foldState);\n\n useEffect(() => {\n foldStateRef.current = foldState;\n }, [foldState]);\n\n const handleFoldStateChange = useEventCallback(async (newInfo: DeviceInfo) => {\n const newFoldState = PlatformDetector.getFoldState();\n const previousFoldState = foldStateRef.current;\n\n if (newFoldState !== previousFoldState && previousFoldState !== FoldState.UNKNOWN) {\n try {\n await applyFoldStateCameraAdjustment(\n mapRef,\n previousFoldState,\n newFoldState,\n mergedConfig,\n 'useFoldableMap'\n );\n } catch (error) {\n if (mergedConfig.debug) {\n console.error('[useFoldableMap] 调整失败:', error);\n }\n }\n }\n\n foldStateRef.current = newFoldState;\n setFoldState(newFoldState);\n setDeviceInfo(newInfo);\n mergedConfig.onFoldStateChange(newFoldState, newInfo);\n });\n\n useEffect(() => {\n if (Platform.OS !== 'android' || !deviceInfo.isFoldable) {\n return;\n }\n\n const initialState = PlatformDetector.getFoldState();\n foldStateRef.current = initialState;\n setFoldState(initialState);\n\n const removeListener = PlatformDetector.addDimensionChangeListener(\n async (newInfo: DeviceInfo) => {\n await handleFoldStateChange(newInfo);\n }\n );\n\n return () => {\n removeListener();\n };\n }, [deviceInfo.isFoldable, handleFoldStateChange, mapRef]);\n\n return {\n foldState,\n deviceInfo,\n isFoldable: deviceInfo.isFoldable,\n };\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import React from 'react';
|
|
2
3
|
/**
|
|
3
4
|
* MapUI 组件
|
|
@@ -16,7 +17,7 @@ import React from 'react';
|
|
|
16
17
|
* </MapView>
|
|
17
18
|
*/
|
|
18
19
|
export const MapUI = ({ children }) => {
|
|
19
|
-
return
|
|
20
|
+
return _jsx(_Fragment, { children: children });
|
|
20
21
|
};
|
|
21
22
|
// 静态标志,用于识别
|
|
22
23
|
MapUI.isMapUI = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapUI.js","sourceRoot":"","sources":["../../src/components/MapUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,KAAK,GAA0C,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC3E,OAAO,
|
|
1
|
+
{"version":3,"file":"MapUI.js","sourceRoot":"","sources":["../../src/components/MapUI.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,KAAK,GAA0C,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC3E,OAAO,4BAAG,QAAQ,GAAI,CAAC;AACzB,CAAC,CAAC;AAEF,YAAY;AACX,KAAyC,CAAC,OAAO,GAAG,IAAI,CAAC","sourcesContent":["import React from 'react';\n\n/**\n * MapUI 组件\n * 用于包裹不需要作为地图原生子组件(如 Marker)的普通 React 组件。\n * 被此组件包裹的内容将渲染在地图视图的上方(兄弟节点),而不是内部。\n * 这解决了在地图内部放置普通 View 导致的触摸事件冲突问题。\n * \n * 示例:\n * <MapView>\n * <Marker ... />\n * <MapUI>\n * <View style={{ position: 'absolute', ... }}>\n * <Text>悬浮层</Text>\n * </View>\n * </MapUI>\n * </MapView>\n */\nexport const MapUI: React.FC<React.PropsWithChildren<{}>> = ({ children }) => {\n return <>{children}</>;\n};\n\n// 静态标志,用于识别\n(MapUI as React.FC & { isMapUI: boolean }).isMapUI = true;\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import type { RouteOverlayProps } from '../types/route-playback.types';
|
|
3
|
-
export declare function RouteOverlay({ points, showStartMarker, showEndMarker, polylineProps, startMarkerProps, endMarkerProps, }: RouteOverlayProps):
|
|
2
|
+
export declare function RouteOverlay({ points, showStartMarker, showEndMarker, polylineProps, startMarkerProps, endMarkerProps, }: RouteOverlayProps): import("react/jsx-runtime").JSX.Element | null;
|
|
4
3
|
export default RouteOverlay;
|
|
5
4
|
//# sourceMappingURL=RouteOverlay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouteOverlay.d.ts","sourceRoot":"","sources":["../../src/components/RouteOverlay.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RouteOverlay.d.ts","sourceRoot":"","sources":["../../src/components/RouteOverlay.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAIvE,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,eAAsB,EACtB,aAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,cAAc,GACf,EAAE,iBAAiB,kDA0CnB;AAED,eAAe,YAAY,CAAC"}
|