expo-gaode-map 1.0.4 → 1.0.5
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/src/main/AndroidManifest.xml +13 -1
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapModule.kt +8 -3
- package/android/src/main/java/expo/modules/gaodemap/modules/LocationManager.kt +25 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerView.kt +2 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/MultiPointView.kt +1 -1
- package/android/src/main/java/expo/modules/gaodemap/services/LocationForegroundService.kt +78 -0
- package/build/ExpoGaodeMapModule.d.ts +33 -0
- package/build/ExpoGaodeMapModule.d.ts.map +1 -1
- package/build/ExpoGaodeMapModule.js +0 -1
- package/build/ExpoGaodeMapModule.js.map +1 -1
- package/build/ExpoGaodeMapView.d.ts +6 -35
- package/build/ExpoGaodeMapView.d.ts.map +1 -1
- package/build/ExpoGaodeMapView.js +25 -92
- package/build/ExpoGaodeMapView.js.map +1 -1
- package/build/components/overlays/Circle.d.ts.map +1 -1
- package/build/components/overlays/Circle.js +7 -0
- package/build/components/overlays/Circle.js.map +1 -1
- package/build/components/overlays/Marker.js +10 -0
- package/build/components/overlays/Marker.js.map +1 -1
- package/build/components/overlays/Polygon.d.ts.map +1 -1
- package/build/components/overlays/Polygon.js +7 -0
- package/build/components/overlays/Polygon.js.map +1 -1
- package/build/components/overlays/Polyline.d.ts.map +1 -1
- package/build/components/overlays/Polyline.js +7 -0
- package/build/components/overlays/Polyline.js.map +1 -1
- package/build/modules/AMapLocation.d.ts +2 -19
- package/build/modules/AMapLocation.d.ts.map +1 -1
- package/build/modules/AMapLocation.js +36 -73
- package/build/modules/AMapLocation.js.map +1 -1
- package/build/types/location.types.d.ts +0 -1
- package/build/types/location.types.d.ts.map +1 -1
- package/build/types/location.types.js.map +1 -1
- package/build/utils/EventManager.d.ts +11 -0
- package/build/utils/EventManager.d.ts.map +1 -0
- package/build/utils/EventManager.js +21 -0
- package/build/utils/EventManager.js.map +1 -0
- package/docs/API.md +10 -0
- package/ios/modules/LocationManager.swift +2 -2
- package/package.json +1 -1
- package/src/ExpoGaodeMapModule.ts +39 -5
- package/src/ExpoGaodeMapView.tsx +30 -137
- package/src/components/overlays/Circle.tsx +8 -0
- package/src/components/overlays/Marker.tsx +11 -0
- package/src/components/overlays/Polygon.tsx +8 -0
- package/src/components/overlays/Polyline.tsx +8 -0
- package/src/modules/AMapLocation.ts +38 -73
- package/src/types/location.types.ts +0 -1
- package/src/utils/EventManager.ts +23 -0
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
<!-- Android 10及以上需要后台定位权限 -->
|
|
22
22
|
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
|
23
23
|
|
|
24
|
+
<!-- 前台服务权限 (Android 9+) -->
|
|
25
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
26
|
+
<!-- Android 14+ 需要指定前台服务类型 -->
|
|
27
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
|
|
28
|
+
|
|
24
29
|
<!-- 写入扩展存储,用于缓存地图数据 -->
|
|
25
30
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
26
31
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
|
@@ -30,11 +35,18 @@
|
|
|
30
35
|
|
|
31
36
|
<application>
|
|
32
37
|
<!-- 高德地图 API Key(这里只是示例,实际会通过代码设置) -->
|
|
33
|
-
<!--
|
|
38
|
+
<!--
|
|
34
39
|
<meta-data
|
|
35
40
|
android:name="com.amap.api.v2.apikey"
|
|
36
41
|
android:value="YOUR_API_KEY_HERE"/>
|
|
37
42
|
-->
|
|
43
|
+
|
|
44
|
+
<!-- 定位前台服务 -->
|
|
45
|
+
<service
|
|
46
|
+
android:name="expo.modules.gaodemap.services.LocationForegroundService"
|
|
47
|
+
android:enabled="true"
|
|
48
|
+
android:exported="false"
|
|
49
|
+
android:foregroundServiceType="location" />
|
|
38
50
|
</application>
|
|
39
51
|
|
|
40
52
|
</manifest>
|
|
@@ -220,11 +220,12 @@ class ExpoGaodeMapModule : Module() {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
/**
|
|
223
|
-
* 设置是否允许后台定位
|
|
223
|
+
* 设置是否允许后台定位
|
|
224
|
+
* Android 通过前台服务实现,iOS 通过系统配置实现
|
|
224
225
|
* @param allows 是否允许后台定位
|
|
225
226
|
*/
|
|
226
|
-
Function("setAllowsBackgroundLocationUpdates") {
|
|
227
|
-
|
|
227
|
+
Function("setAllowsBackgroundLocationUpdates") { allows: Boolean ->
|
|
228
|
+
getLocationManager().setAllowsBackgroundLocationUpdates(allows)
|
|
228
229
|
}
|
|
229
230
|
|
|
230
231
|
/**
|
|
@@ -511,6 +512,10 @@ class ExpoGaodeMapModule : Module() {
|
|
|
511
512
|
Prop<Float>("strokeWidth") { view, width ->
|
|
512
513
|
view.setStrokeWidth(width)
|
|
513
514
|
}
|
|
515
|
+
|
|
516
|
+
Prop<Float>("zIndex") { view, zIndex ->
|
|
517
|
+
view.setZIndex(zIndex)
|
|
518
|
+
}
|
|
514
519
|
}
|
|
515
520
|
|
|
516
521
|
// Polyline - 折线
|
|
@@ -7,6 +7,7 @@ import com.amap.api.location.AMapLocationClient
|
|
|
7
7
|
import com.amap.api.location.AMapLocationClientOption
|
|
8
8
|
import com.amap.api.maps.model.LatLng
|
|
9
9
|
import expo.modules.kotlin.Promise
|
|
10
|
+
import expo.modules.gaodemap.services.LocationForegroundService
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* 定位管理器
|
|
@@ -32,6 +33,8 @@ class LocationManager(context: Context) {
|
|
|
32
33
|
private var isLocationStarted = false
|
|
33
34
|
/** 定位更新回调 */
|
|
34
35
|
private var onLocationUpdate: ((Map<String, Any?>) -> Unit)? = null
|
|
36
|
+
/** 是否启用后台定位 */
|
|
37
|
+
private var allowsBackgroundLocationUpdates = false
|
|
35
38
|
|
|
36
39
|
init {
|
|
37
40
|
initLocationClient()
|
|
@@ -52,6 +55,12 @@ class LocationManager(context: Context) {
|
|
|
52
55
|
if (locationClient == null) {
|
|
53
56
|
initLocationClient()
|
|
54
57
|
}
|
|
58
|
+
|
|
59
|
+
// 如果启用后台定位,启动前台服务
|
|
60
|
+
if (allowsBackgroundLocationUpdates) {
|
|
61
|
+
LocationForegroundService.start(appContext)
|
|
62
|
+
}
|
|
63
|
+
|
|
55
64
|
locationClient?.startLocation()
|
|
56
65
|
isLocationStarted = true
|
|
57
66
|
}
|
|
@@ -62,6 +71,11 @@ class LocationManager(context: Context) {
|
|
|
62
71
|
fun stop() {
|
|
63
72
|
locationClient?.stopLocation()
|
|
64
73
|
isLocationStarted = false
|
|
74
|
+
|
|
75
|
+
// 停止前台服务
|
|
76
|
+
if (allowsBackgroundLocationUpdates) {
|
|
77
|
+
LocationForegroundService.stop(appContext)
|
|
78
|
+
}
|
|
65
79
|
}
|
|
66
80
|
|
|
67
81
|
/**
|
|
@@ -205,6 +219,11 @@ class LocationManager(context: Context) {
|
|
|
205
219
|
applyLocationOption()
|
|
206
220
|
}
|
|
207
221
|
|
|
222
|
+
/** 设置是否允许后台定位 */
|
|
223
|
+
fun setAllowsBackgroundLocationUpdates(allows: Boolean) {
|
|
224
|
+
allowsBackgroundLocationUpdates = allows
|
|
225
|
+
}
|
|
226
|
+
|
|
208
227
|
/**
|
|
209
228
|
* 销毁资源
|
|
210
229
|
*/
|
|
@@ -214,6 +233,11 @@ class LocationManager(context: Context) {
|
|
|
214
233
|
locationClient?.onDestroy()
|
|
215
234
|
locationClient = null
|
|
216
235
|
locationOption = null
|
|
236
|
+
|
|
237
|
+
// 确保停止前台服务
|
|
238
|
+
if (allowsBackgroundLocationUpdates) {
|
|
239
|
+
LocationForegroundService.stop(appContext)
|
|
240
|
+
}
|
|
217
241
|
}
|
|
218
242
|
|
|
219
243
|
// ==================== 私有方法 ====================
|
|
@@ -229,6 +253,7 @@ class LocationManager(context: Context) {
|
|
|
229
253
|
onLocationUpdate?.invoke(formatLocation(location))
|
|
230
254
|
}
|
|
231
255
|
}
|
|
256
|
+
|
|
232
257
|
}
|
|
233
258
|
|
|
234
259
|
locationOption = AMapLocationClientOption().apply {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package expo.modules.gaodemap.overlays
|
|
2
2
|
|
|
3
|
+
import android.annotation.SuppressLint
|
|
3
4
|
import android.content.Context
|
|
4
5
|
import android.graphics.Bitmap
|
|
5
6
|
import android.graphics.Canvas
|
|
@@ -95,6 +96,7 @@ class MarkerView(context: Context, appContext: AppContext) : ExpoView(context, a
|
|
|
95
96
|
/**
|
|
96
97
|
* 设置锚点
|
|
97
98
|
*/
|
|
99
|
+
@SuppressLint("SuspiciousIndentation")
|
|
98
100
|
fun setAnchor(anchor: Map<String, Float>) {
|
|
99
101
|
val x = anchor["x"] ?: 0.5f
|
|
100
102
|
val y = anchor["y"] ?: 1.0f
|
|
@@ -80,7 +80,7 @@ class MultiPointView(context: Context, appContext: AppContext) : ExpoView(contex
|
|
|
80
80
|
|
|
81
81
|
// 创建海量点覆盖物
|
|
82
82
|
multiPointOverlay = map.addMultiPointOverlay(overlayOptions)
|
|
83
|
-
|
|
83
|
+
multiPointOverlay?.items = points
|
|
84
84
|
|
|
85
85
|
// 注意:MultiPointOverlay 在高德地图 Android SDK 中不直接支持点击事件
|
|
86
86
|
// 如果需要点击事件,需要使用 Marker 或其他方式实现
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
package expo.modules.gaodemap.services
|
|
2
|
+
|
|
3
|
+
import android.app.Notification
|
|
4
|
+
import android.app.NotificationChannel
|
|
5
|
+
import android.app.NotificationManager
|
|
6
|
+
import android.app.PendingIntent
|
|
7
|
+
import android.app.Service
|
|
8
|
+
import android.content.Context
|
|
9
|
+
import android.content.Intent
|
|
10
|
+
import android.os.Build
|
|
11
|
+
import android.os.IBinder
|
|
12
|
+
import androidx.core.app.NotificationCompat
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 定位前台服务
|
|
16
|
+
* 用于支持 Android 后台定位
|
|
17
|
+
*/
|
|
18
|
+
class LocationForegroundService : Service() {
|
|
19
|
+
|
|
20
|
+
companion object {
|
|
21
|
+
private const val NOTIFICATION_ID = 1001
|
|
22
|
+
private const val CHANNEL_ID = "location_service_channel"
|
|
23
|
+
private const val CHANNEL_NAME = "定位服务"
|
|
24
|
+
|
|
25
|
+
fun start(context: Context) {
|
|
26
|
+
val intent = Intent(context, LocationForegroundService::class.java)
|
|
27
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
28
|
+
context.startForegroundService(intent)
|
|
29
|
+
} else {
|
|
30
|
+
context.startService(intent)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
fun stop(context: Context) {
|
|
35
|
+
val intent = Intent(context, LocationForegroundService::class.java)
|
|
36
|
+
context.stopService(intent)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
override fun onCreate() {
|
|
41
|
+
super.onCreate()
|
|
42
|
+
createNotificationChannel()
|
|
43
|
+
startForeground(NOTIFICATION_ID, createNotification())
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
|
47
|
+
return START_STICKY
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
override fun onBind(intent: Intent?): IBinder? = null
|
|
51
|
+
|
|
52
|
+
private fun createNotificationChannel() {
|
|
53
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
54
|
+
val channel = NotificationChannel(
|
|
55
|
+
CHANNEL_ID,
|
|
56
|
+
CHANNEL_NAME,
|
|
57
|
+
NotificationManager.IMPORTANCE_LOW
|
|
58
|
+
).apply {
|
|
59
|
+
description = "后台定位服务通知"
|
|
60
|
+
setShowBadge(false)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
64
|
+
manager.createNotificationChannel(channel)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private fun createNotification(): Notification {
|
|
69
|
+
val builder = NotificationCompat.Builder(this, CHANNEL_ID)
|
|
70
|
+
.setContentTitle("定位服务运行中")
|
|
71
|
+
.setContentText("正在后台获取位置信息")
|
|
72
|
+
.setSmallIcon(android.R.drawable.ic_menu_mylocation)
|
|
73
|
+
.setPriority(NotificationCompat.PRIORITY_LOW)
|
|
74
|
+
.setOngoing(true)
|
|
75
|
+
|
|
76
|
+
return builder.build()
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
import { NativeModule } from 'expo';
|
|
2
2
|
import type { ExpoGaodeMapModuleEvents } from './ExpoGaodeMap.types';
|
|
3
|
+
import type { LatLng, CoordinateType } from './types';
|
|
3
4
|
declare class ExpoGaodeMapModule extends NativeModule<ExpoGaodeMapModuleEvents> {
|
|
5
|
+
initSDK(config: {
|
|
6
|
+
androidKey?: string;
|
|
7
|
+
iosKey?: string;
|
|
8
|
+
}): void;
|
|
9
|
+
getVersion(): string;
|
|
10
|
+
start(): void;
|
|
11
|
+
stop(): void;
|
|
12
|
+
isStarted(): Promise<boolean>;
|
|
13
|
+
getCurrentLocation(): Promise<any>;
|
|
14
|
+
coordinateConvert(coordinate: LatLng, type: CoordinateType): Promise<LatLng>;
|
|
15
|
+
setLocatingWithReGeocode(isReGeocode: boolean): void;
|
|
16
|
+
setLocationMode(mode: number): void;
|
|
17
|
+
setInterval(interval: number): void;
|
|
18
|
+
setOnceLocation(isOnceLocation: boolean): void;
|
|
19
|
+
setSensorEnable(sensorEnable: boolean): void;
|
|
20
|
+
setWifiScan(wifiScan: boolean): void;
|
|
21
|
+
setGpsFirst(gpsFirst: boolean): void;
|
|
22
|
+
setOnceLocationLatest(onceLocationLatest: boolean): void;
|
|
23
|
+
setGeoLanguage(language: string): void;
|
|
24
|
+
setLocationCacheEnable(locationCacheEnable: boolean): void;
|
|
25
|
+
setHttpTimeOut(httpTimeOut: number): void;
|
|
26
|
+
setDesiredAccuracy(accuracy: number): void;
|
|
27
|
+
setLocationTimeout(timeout: number): void;
|
|
28
|
+
setReGeocodeTimeout(timeout: number): void;
|
|
29
|
+
setDistanceFilter(distance: number): void;
|
|
30
|
+
setPausesLocationUpdatesAutomatically(pauses: boolean): void;
|
|
31
|
+
setAllowsBackgroundLocationUpdates(allows: boolean): void;
|
|
32
|
+
setLocationProtocol(protocol: string): void;
|
|
33
|
+
startUpdatingHeading(): void;
|
|
34
|
+
stopUpdatingHeading(): void;
|
|
35
|
+
checkLocationPermission(): Promise<any>;
|
|
36
|
+
requestLocationPermission(): Promise<any>;
|
|
4
37
|
}
|
|
5
38
|
declare const _default: ExpoGaodeMapModule;
|
|
6
39
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoGaodeMapModule.d.ts","sourceRoot":"","sources":["../src/ExpoGaodeMapModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExpoGaodeMapModule.d.ts","sourceRoot":"","sources":["../src/ExpoGaodeMapModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AACzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEtD,OAAO,OAAO,kBAAmB,SAAQ,YAAY,CAAC,wBAAwB,CAAC;IAE7E,OAAO,CAAC,MAAM,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAC/D,UAAU,IAAI,MAAM;IAGpB,KAAK,IAAI,IAAI;IACb,IAAI,IAAI,IAAI;IAC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AC;CAC1C;;AAED,wBAAuE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoGaodeMapModule.js","sourceRoot":"","sources":["../src/ExpoGaodeMapModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExpoGaodeMapModule.js","sourceRoot":"","sources":["../src/ExpoGaodeMapModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AA6CzD,eAAe,mBAAmB,CAAqB,cAAc,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from 'expo';\nimport type { ExpoGaodeMapModuleEvents } from './ExpoGaodeMap.types';\nimport type { LatLng, CoordinateType } from './types';\n\ndeclare class ExpoGaodeMapModule extends NativeModule<ExpoGaodeMapModuleEvents> {\n // SDK 初始化\n initSDK(config: { androidKey?: string; iosKey?: string }): void;\n getVersion(): string;\n \n // 定位控制\n start(): void;\n stop(): void;\n isStarted(): Promise<boolean>;\n getCurrentLocation(): Promise<any>;\n coordinateConvert(coordinate: LatLng, type: CoordinateType): Promise<LatLng>;\n \n // 定位配置\n setLocatingWithReGeocode(isReGeocode: boolean): void;\n setLocationMode(mode: number): void;\n setInterval(interval: number): void;\n setOnceLocation(isOnceLocation: boolean): void;\n setSensorEnable(sensorEnable: boolean): void;\n setWifiScan(wifiScan: boolean): void;\n setGpsFirst(gpsFirst: boolean): void;\n setOnceLocationLatest(onceLocationLatest: boolean): void;\n setGeoLanguage(language: string): void;\n setLocationCacheEnable(locationCacheEnable: boolean): void;\n setHttpTimeOut(httpTimeOut: number): void;\n setDesiredAccuracy(accuracy: number): void;\n setLocationTimeout(timeout: number): void;\n setReGeocodeTimeout(timeout: number): void;\n setDistanceFilter(distance: number): void;\n setPausesLocationUpdatesAutomatically(pauses: boolean): void;\n setAllowsBackgroundLocationUpdates(allows: boolean): void;\n setLocationProtocol(protocol: string): void;\n \n // 方向更新 (iOS)\n startUpdatingHeading(): void;\n stopUpdatingHeading(): void;\n \n // 权限\n checkLocationPermission(): Promise<any>;\n requestLocationPermission(): Promise<any>;\n}\n\nexport default requireNativeModule<ExpoGaodeMapModule>('ExpoGaodeMap');\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { EventManager } from './utils/EventManager';
|
|
2
3
|
import type { MapViewProps, MapViewRef, LatLng } from './types';
|
|
3
4
|
export type { MapViewRef } from './types';
|
|
4
5
|
export declare const MapContext: React.Context<React.RefObject<MapViewRef | null> | null>;
|
|
@@ -10,43 +11,13 @@ type MarkerEventCallbacks = {
|
|
|
10
11
|
nativeEvent: LatLng;
|
|
11
12
|
}) => void;
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
-
private callbacks;
|
|
15
|
-
register(markerId: string, callbacks: MarkerEventCallbacks): void;
|
|
16
|
-
unregister(markerId: string): void;
|
|
17
|
-
trigger(markerId: string, eventType: keyof MarkerEventCallbacks, data?: any): void;
|
|
18
|
-
}
|
|
19
|
-
export declare const MarkerEventContext: React.Context<MarkerEventManager | null>;
|
|
20
|
-
type CircleEventCallbacks = {
|
|
14
|
+
type OverlayEventCallbacks = {
|
|
21
15
|
onPress?: () => void;
|
|
22
16
|
};
|
|
23
|
-
declare
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
trigger(circleId: string, eventType: keyof CircleEventCallbacks): void;
|
|
28
|
-
}
|
|
29
|
-
export declare const CircleEventContext: React.Context<CircleEventManager | null>;
|
|
30
|
-
type PolygonEventCallbacks = {
|
|
31
|
-
onPress?: () => void;
|
|
32
|
-
};
|
|
33
|
-
declare class PolygonEventManager {
|
|
34
|
-
private callbacks;
|
|
35
|
-
register(polygonId: string, callbacks: PolygonEventCallbacks): void;
|
|
36
|
-
unregister(polygonId: string): void;
|
|
37
|
-
trigger(polygonId: string, eventType: keyof PolygonEventCallbacks): void;
|
|
38
|
-
}
|
|
39
|
-
export declare const PolygonEventContext: React.Context<PolygonEventManager | null>;
|
|
40
|
-
type PolylineEventCallbacks = {
|
|
41
|
-
onPress?: () => void;
|
|
42
|
-
};
|
|
43
|
-
declare class PolylineEventManager {
|
|
44
|
-
private callbacks;
|
|
45
|
-
register(polylineId: string, callbacks: PolylineEventCallbacks): void;
|
|
46
|
-
unregister(polylineId: string): void;
|
|
47
|
-
trigger(polylineId: string, eventType: keyof PolylineEventCallbacks): void;
|
|
48
|
-
}
|
|
49
|
-
export declare const PolylineEventContext: React.Context<PolylineEventManager | null>;
|
|
17
|
+
export declare const MarkerEventContext: React.Context<EventManager<MarkerEventCallbacks> | null>;
|
|
18
|
+
export declare const CircleEventContext: React.Context<EventManager<OverlayEventCallbacks> | null>;
|
|
19
|
+
export declare const PolygonEventContext: React.Context<EventManager<OverlayEventCallbacks> | null>;
|
|
20
|
+
export declare const PolylineEventContext: React.Context<EventManager<OverlayEventCallbacks> | null>;
|
|
50
21
|
/**
|
|
51
22
|
* 高德地图视图组件,提供地图操作API和覆盖物管理功能
|
|
52
23
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoGaodeMapView.d.ts","sourceRoot":"","sources":["../src/ExpoGaodeMapView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpoGaodeMapView.d.ts","sourceRoot":"","sources":["../src/ExpoGaodeMapView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EAGV,MAAM,EAMP,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI1C,eAAO,MAAM,UAAU,0DAAuE,CAAC;AAE/F,KAAK,oBAAoB,GAAG;IAC1B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACtD,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,kBAAkB,0DAAuE,CAAC;AACvG,eAAO,MAAM,kBAAkB,2DAAwE,CAAC;AACxG,eAAO,MAAM,mBAAmB,2DAAwE,CAAC;AACzG,eAAO,MAAM,oBAAoB,2DAAwE,CAAC;AAE1G;;;;;;;;;;;;;;;;;GAiBG;AACH,QAAA,MAAM,gBAAgB,iFAsRpB,CAAC;AAIH,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,71 +1,11 @@
|
|
|
1
1
|
import { requireNativeViewManager } from 'expo-modules-core';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { EventManager } from './utils/EventManager';
|
|
3
4
|
const NativeView = requireNativeViewManager('ExpoGaodeMap');
|
|
4
|
-
// 创建 Context 用于子组件访问 MapRef
|
|
5
5
|
export const MapContext = React.createContext(null);
|
|
6
|
-
class MarkerEventManager {
|
|
7
|
-
callbacks = new Map();
|
|
8
|
-
register(markerId, callbacks) {
|
|
9
|
-
this.callbacks.set(markerId, callbacks);
|
|
10
|
-
}
|
|
11
|
-
unregister(markerId) {
|
|
12
|
-
this.callbacks.delete(markerId);
|
|
13
|
-
}
|
|
14
|
-
trigger(markerId, eventType, data) {
|
|
15
|
-
const callbacks = this.callbacks.get(markerId);
|
|
16
|
-
if (callbacks && callbacks[eventType]) {
|
|
17
|
-
callbacks[eventType](data);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
6
|
export const MarkerEventContext = React.createContext(null);
|
|
22
|
-
class CircleEventManager {
|
|
23
|
-
callbacks = new Map();
|
|
24
|
-
register(circleId, callbacks) {
|
|
25
|
-
this.callbacks.set(circleId, callbacks);
|
|
26
|
-
}
|
|
27
|
-
unregister(circleId) {
|
|
28
|
-
this.callbacks.delete(circleId);
|
|
29
|
-
}
|
|
30
|
-
trigger(circleId, eventType) {
|
|
31
|
-
const callbacks = this.callbacks.get(circleId);
|
|
32
|
-
if (callbacks && callbacks[eventType]) {
|
|
33
|
-
callbacks[eventType]();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
7
|
export const CircleEventContext = React.createContext(null);
|
|
38
|
-
class PolygonEventManager {
|
|
39
|
-
callbacks = new Map();
|
|
40
|
-
register(polygonId, callbacks) {
|
|
41
|
-
this.callbacks.set(polygonId, callbacks);
|
|
42
|
-
}
|
|
43
|
-
unregister(polygonId) {
|
|
44
|
-
this.callbacks.delete(polygonId);
|
|
45
|
-
}
|
|
46
|
-
trigger(polygonId, eventType) {
|
|
47
|
-
const callbacks = this.callbacks.get(polygonId);
|
|
48
|
-
if (callbacks && callbacks[eventType]) {
|
|
49
|
-
callbacks[eventType]();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
8
|
export const PolygonEventContext = React.createContext(null);
|
|
54
|
-
class PolylineEventManager {
|
|
55
|
-
callbacks = new Map();
|
|
56
|
-
register(polylineId, callbacks) {
|
|
57
|
-
this.callbacks.set(polylineId, callbacks);
|
|
58
|
-
}
|
|
59
|
-
unregister(polylineId) {
|
|
60
|
-
this.callbacks.delete(polylineId);
|
|
61
|
-
}
|
|
62
|
-
trigger(polylineId, eventType) {
|
|
63
|
-
const callbacks = this.callbacks.get(polylineId);
|
|
64
|
-
if (callbacks && callbacks[eventType]) {
|
|
65
|
-
callbacks[eventType]();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
9
|
export const PolylineEventContext = React.createContext(null);
|
|
70
10
|
/**
|
|
71
11
|
* 高德地图视图组件,提供地图操作API和覆盖物管理功能
|
|
@@ -88,33 +28,29 @@ export const PolylineEventContext = React.createContext(null);
|
|
|
88
28
|
const ExpoGaodeMapView = React.forwardRef((props, ref) => {
|
|
89
29
|
const nativeRef = React.useRef(null);
|
|
90
30
|
const internalRef = React.useRef(null);
|
|
91
|
-
const markerEventManager = React.
|
|
92
|
-
const circleEventManager = React.
|
|
93
|
-
const polygonEventManager = React.
|
|
94
|
-
const polylineEventManager = React.
|
|
95
|
-
|
|
96
|
-
const handleMarkerPress = React.useCallback((event) => {
|
|
31
|
+
const markerEventManager = React.useMemo(() => new EventManager(), []);
|
|
32
|
+
const circleEventManager = React.useMemo(() => new EventManager(), []);
|
|
33
|
+
const polygonEventManager = React.useMemo(() => new EventManager(), []);
|
|
34
|
+
const polylineEventManager = React.useMemo(() => new EventManager(), []);
|
|
35
|
+
const handleMarkerPress = (event) => {
|
|
97
36
|
const markerId = event.nativeEvent?.markerId;
|
|
98
|
-
if (markerId)
|
|
37
|
+
if (markerId)
|
|
99
38
|
markerEventManager.trigger(markerId, 'onPress');
|
|
100
|
-
}
|
|
101
39
|
props.onMarkerPress?.(event);
|
|
102
|
-
}
|
|
103
|
-
const handleMarkerDragStart =
|
|
40
|
+
};
|
|
41
|
+
const handleMarkerDragStart = (event) => {
|
|
104
42
|
const markerId = event.nativeEvent?.markerId;
|
|
105
|
-
if (markerId)
|
|
43
|
+
if (markerId)
|
|
106
44
|
markerEventManager.trigger(markerId, 'onDragStart');
|
|
107
|
-
}
|
|
108
45
|
props.onMarkerDragStart?.(event);
|
|
109
|
-
}
|
|
110
|
-
const handleMarkerDrag =
|
|
46
|
+
};
|
|
47
|
+
const handleMarkerDrag = (event) => {
|
|
111
48
|
const markerId = event.nativeEvent?.markerId;
|
|
112
|
-
if (markerId)
|
|
49
|
+
if (markerId)
|
|
113
50
|
markerEventManager.trigger(markerId, 'onDrag');
|
|
114
|
-
}
|
|
115
51
|
props.onMarkerDrag?.(event);
|
|
116
|
-
}
|
|
117
|
-
const handleMarkerDragEnd =
|
|
52
|
+
};
|
|
53
|
+
const handleMarkerDragEnd = (event) => {
|
|
118
54
|
const markerId = event.nativeEvent?.markerId;
|
|
119
55
|
if (markerId) {
|
|
120
56
|
markerEventManager.trigger(markerId, 'onDragEnd', {
|
|
@@ -125,28 +61,25 @@ const ExpoGaodeMapView = React.forwardRef((props, ref) => {
|
|
|
125
61
|
});
|
|
126
62
|
}
|
|
127
63
|
props.onMarkerDragEnd?.(event);
|
|
128
|
-
}
|
|
129
|
-
const handleCirclePress =
|
|
64
|
+
};
|
|
65
|
+
const handleCirclePress = (event) => {
|
|
130
66
|
const circleId = event.nativeEvent?.circleId;
|
|
131
|
-
if (circleId)
|
|
67
|
+
if (circleId)
|
|
132
68
|
circleEventManager.trigger(circleId, 'onPress');
|
|
133
|
-
}
|
|
134
69
|
props.onCirclePress?.(event);
|
|
135
|
-
}
|
|
136
|
-
const handlePolygonPress =
|
|
70
|
+
};
|
|
71
|
+
const handlePolygonPress = (event) => {
|
|
137
72
|
const polygonId = event.nativeEvent?.polygonId;
|
|
138
|
-
if (polygonId)
|
|
73
|
+
if (polygonId)
|
|
139
74
|
polygonEventManager.trigger(polygonId, 'onPress');
|
|
140
|
-
}
|
|
141
75
|
props.onPolygonPress?.(event);
|
|
142
|
-
}
|
|
143
|
-
const handlePolylinePress =
|
|
76
|
+
};
|
|
77
|
+
const handlePolylinePress = (event) => {
|
|
144
78
|
const polylineId = event.nativeEvent?.polylineId;
|
|
145
|
-
if (polylineId)
|
|
79
|
+
if (polylineId)
|
|
146
80
|
polylineEventManager.trigger(polylineId, 'onPress');
|
|
147
|
-
}
|
|
148
81
|
props.onPolylinePress?.(event);
|
|
149
|
-
}
|
|
82
|
+
};
|
|
150
83
|
const apiRef = React.useMemo(() => ({
|
|
151
84
|
/**
|
|
152
85
|
* 移动地图相机到指定位置
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoGaodeMapView.js","sourceRoot":"","sources":["../src/ExpoGaodeMapView.tsx"],"names":[],"mappings":"AAAA,OAA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AAa,CAAC,CAAC,iBAAiB,CAAC,CACjC,iBAAiB,CAAC,CAAC,qBAAqB,CAAC,CACzC,YAAY,CAAC,CAAC,gBAAgB,CAAC,CAC/B,eAAe,CAAC,CAAC,mBAAmB,CAAC,CACrC,aAAa,CAAC,CAAC,iBAAiB,CAAC,CACjC,cAAc,CAAC,CAAC,kBAAkB,CAAC,CACnC,eAAe,CAAC,CAAC,mBAAmB,CAAC,CAErC;gBAAA,CAAC,KAAK,CAAC,QAAQ,CACjB;cAAA,EAAE,UAAU,CACd;YAAA,EAAE,oBAAoB,CAAC,QAAQ,CACjC;UAAA,EAAE,mBAAmB,CAAC,QAAQ,CAChC;QAAA,EAAE,kBAAkB,CAAC,QAAQ,CAC/B;MAAA,EAAE,kBAAkB,CAAC,QAAQ,CAC/B;IAAA,EAAE,UAAU,CAAC,QAAQ,CAAC,CACvB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAElD,eAAe,gBAAgB,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\n\nimport type {\n MapViewProps,\n MapViewRef,\n NativeMapViewRef,\n CameraPosition,\n LatLng,\n Point,\n CircleProps,\n MarkerProps,\n PolylineProps,\n PolygonProps,\n} from './types';\n\n// 重新导出 MapViewRef 供外部使用\nexport type { MapViewRef } from './types';\n\nconst NativeView: React.ComponentType<MapViewProps & { ref?: React.Ref<NativeMapViewRef> }> = requireNativeViewManager('ExpoGaodeMap');\n\n// 创建 Context 用于子组件访问 MapRef\nexport const MapContext = React.createContext<React.RefObject<MapViewRef | null> | null>(null);\n\n// Marker 事件管理器\ntype MarkerEventCallbacks = {\n onPress?: () => void;\n onDragStart?: () => void;\n onDrag?: () => void;\n onDragEnd?: (event: { nativeEvent: LatLng }) => void;\n};\n\nclass MarkerEventManager {\n private callbacks = new Map<string, MarkerEventCallbacks>();\n \n register(markerId: string, callbacks: MarkerEventCallbacks) {\n this.callbacks.set(markerId, callbacks);\n }\n \n unregister(markerId: string) {\n this.callbacks.delete(markerId);\n }\n \n trigger(markerId: string, eventType: keyof MarkerEventCallbacks, data?: any) {\n const callbacks = this.callbacks.get(markerId);\n if (callbacks && callbacks[eventType]) {\n callbacks[eventType]!(data);\n }\n }\n}\n\nexport const MarkerEventContext = React.createContext<MarkerEventManager | null>(null);\n\n// Circle 事件管理器\ntype CircleEventCallbacks = {\n onPress?: () => void;\n};\n\nclass CircleEventManager {\n private callbacks = new Map<string, CircleEventCallbacks>();\n \n register(circleId: string, callbacks: CircleEventCallbacks) {\n this.callbacks.set(circleId, callbacks);\n }\n \n unregister(circleId: string) {\n this.callbacks.delete(circleId);\n }\n \n trigger(circleId: string, eventType: keyof CircleEventCallbacks) {\n const callbacks = this.callbacks.get(circleId);\n if (callbacks && callbacks[eventType]) {\n callbacks[eventType]!();\n }\n }\n}\n\nexport const CircleEventContext = React.createContext<CircleEventManager | null>(null);\n\n// Polygon 事件管理器\ntype PolygonEventCallbacks = {\n onPress?: () => void;\n};\n\nclass PolygonEventManager {\n private callbacks = new Map<string, PolygonEventCallbacks>();\n \n register(polygonId: string, callbacks: PolygonEventCallbacks) {\n this.callbacks.set(polygonId, callbacks);\n }\n \n unregister(polygonId: string) {\n this.callbacks.delete(polygonId);\n }\n \n trigger(polygonId: string, eventType: keyof PolygonEventCallbacks) {\n const callbacks = this.callbacks.get(polygonId);\n if (callbacks && callbacks[eventType]) {\n callbacks[eventType]!();\n }\n }\n}\n\nexport const PolygonEventContext = React.createContext<PolygonEventManager | null>(null);\n\n// Polyline 事件管理器\ntype PolylineEventCallbacks = {\n onPress?: () => void;\n};\n\nclass PolylineEventManager {\n private callbacks = new Map<string, PolylineEventCallbacks>();\n \n register(polylineId: string, callbacks: PolylineEventCallbacks) {\n this.callbacks.set(polylineId, callbacks);\n }\n \n unregister(polylineId: string) {\n this.callbacks.delete(polylineId);\n }\n \n trigger(polylineId: string, eventType: keyof PolylineEventCallbacks) {\n const callbacks = this.callbacks.get(polylineId);\n if (callbacks && callbacks[eventType]) {\n callbacks[eventType]!();\n }\n }\n}\n\nexport const PolylineEventContext = React.createContext<PolylineEventManager | null>(null);\n\n/**\n * 高德地图视图组件,提供地图操作API和覆盖物管理功能\n * \n * @param props - 组件属性\n * @param ref - 外部ref引用,用于访问地图API方法\n * @returns 返回包含地图视图和上下文提供者的React组件\n * \n * @remarks\n * 该组件内部维护两个ref:\n * - nativeRef: 指向原生地图视图的引用\n * - internalRef: 内部使用的API引用,通过MapContext共享\n * \n * 提供的主要API功能包括:\n * - 相机控制(移动、缩放、获取当前位置)\n * - 覆盖物管理(添加/删除/更新标记、折线、多边形、圆形等)\n * \n * 所有API方法都会检查地图是否已初始化,未初始化时抛出错误\n */\nconst ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref) => {\n const nativeRef = React.useRef<NativeMapViewRef>(null);\n const internalRef = React.useRef<MapViewRef | null>(null);\n const markerEventManager = React.useRef(new MarkerEventManager()).current;\n const circleEventManager = React.useRef(new CircleEventManager()).current;\n const polygonEventManager = React.useRef(new PolygonEventManager()).current;\n const polylineEventManager = React.useRef(new PolylineEventManager()).current;\n \n // 处理 Marker 事件\n const handleMarkerPress = React.useCallback((event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) {\n markerEventManager.trigger(markerId, 'onPress');\n }\n props.onMarkerPress?.(event);\n }, [props.onMarkerPress]);\n \n const handleMarkerDragStart = React.useCallback((event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) {\n markerEventManager.trigger(markerId, 'onDragStart');\n }\n props.onMarkerDragStart?.(event);\n }, [props.onMarkerDragStart]);\n \n const handleMarkerDrag = React.useCallback((event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) {\n markerEventManager.trigger(markerId, 'onDrag');\n }\n props.onMarkerDrag?.(event);\n }, [props.onMarkerDrag]);\n \n const handleMarkerDragEnd = React.useCallback((event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) {\n markerEventManager.trigger(markerId, 'onDragEnd', {\n nativeEvent: {\n latitude: event.nativeEvent.latitude,\n longitude: event.nativeEvent.longitude\n }\n });\n }\n props.onMarkerDragEnd?.(event);\n }, [props.onMarkerDragEnd]);\n \n const handleCirclePress = React.useCallback((event: any) => {\n const circleId = event.nativeEvent?.circleId;\n if (circleId) {\n circleEventManager.trigger(circleId, 'onPress');\n }\n props.onCirclePress?.(event);\n }, [props.onCirclePress]);\n \n const handlePolygonPress = React.useCallback((event: any) => {\n const polygonId = event.nativeEvent?.polygonId;\n if (polygonId) {\n polygonEventManager.trigger(polygonId, 'onPress');\n }\n props.onPolygonPress?.(event);\n }, [props.onPolygonPress]);\n \n const handlePolylinePress = React.useCallback((event: any) => {\n const polylineId = event.nativeEvent?.polylineId;\n if (polylineId) {\n polylineEventManager.trigger(polylineId, 'onPress');\n }\n props.onPolylinePress?.(event);\n }, [props.onPolylinePress]);\n\n const apiRef: MapViewRef = React.useMemo(() => ({\n /**\n * 移动地图相机到指定位置\n * @param position 相机位置参数对象,包含目标经纬度、缩放级别等信息\n * @param duration 动画持续时间(毫秒),默认300毫秒\n * @throws 如果地图视图未初始化则抛出错误\n * @returns Promise<void> 异步操作完成后的Promise\n */\n moveCamera: async (position: CameraPosition, duration: number = 300) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.moveCamera(position, duration);\n },\n /**\n * 将屏幕坐标点转换为地理坐标(经纬度)\n * @param point 屏幕坐标点 {x: number, y: number}\n * @returns 返回Promise,解析为对应的地理坐标 {latitude: number, longitude: number}\n * @throws 如果地图视图未初始化,抛出错误 'MapView not initialized'\n */\n getLatLng: async (point: Point) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.getLatLng(point);\n },\n /**\n * 设置地图中心点坐标\n * @param center 要设置的中心点坐标(LatLng格式)\n * @param animated 是否使用动画效果移动地图(默认为false)\n * @throws 如果地图视图未初始化则抛出错误\n */\n setCenter: async (center: LatLng, animated: boolean = false) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.setCenter(center, animated);\n },\n /**\n * 设置地图的缩放级别\n * @param zoom 目标缩放级别\n * @param animated 是否使用动画过渡效果,默认为false\n * @throws 如果地图视图未初始化,抛出错误\n */\n setZoom: async (zoom: number, animated: boolean = false) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.setZoom(zoom, animated);\n },\n /**\n * 获取当前地图的相机位置(视角中心点、缩放级别、倾斜角度等)\n * @returns 返回一个Promise,解析为当前相机位置的对象\n * @throws 如果地图视图未初始化,则抛出错误\n */\n getCameraPosition: async () => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.getCameraPosition();\n },\n /**\n * 在地图上添加圆形覆盖物\n * @param id - 圆形覆盖物的唯一标识符\n * @param props - 圆形覆盖物的属性配置\n * @returns Promise<void> 添加操作的异步结果\n * @throws 如果地图视图未初始化,抛出错误'MapView not initialized'\n */\n addCircle: async (id: string, props: CircleProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addCircle(id, props);\n },\n /**\n * 从地图上移除指定的圆形覆盖物\n * @param id - 要移除的圆形覆盖物的唯一标识符\n * @throws 如果地图视图未初始化,抛出错误\n * @returns Promise<void> 异步操作完成\n */\n removeCircle: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removeCircle(id);\n },\n /**\n * 更新地图上的圆形覆盖物\n * @param id 要更新的圆形覆盖物的唯一标识符\n * @param props 要更新的圆形属性(部分属性)\n * @throws 如果地图视图未初始化,抛出错误\n * @returns Promise<void> 表示更新操作完成\n */\n updateCircle: async (id: string, props: Partial<CircleProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updateCircle(id, props);\n },\n /**\n * 添加一个标记点到地图上\n * @param id 标记点的唯一标识符\n * @param props 标记点的配置属性\n * @returns Promise<void> 添加操作完成后的Promise\n * @throws 如果地图视图未初始化则抛出错误\n */\n addMarker: async (id: string, props: MarkerProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addMarker(id, props);\n },\n /**\n * 从地图上移除指定ID的标记点\n * @param id 要移除的标记点ID\n * @throws 如果地图视图未初始化则抛出错误\n * @returns Promise<void> 异步操作完成\n */\n removeMarker: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removeMarker(id);\n },\n /**\n * 更新地图上指定ID的标记点属性\n * @param id - 要更新的标记点唯一标识符\n * @param props - 需要更新的标记点属性对象(部分属性)\n * @throws 如果地图视图未初始化则抛出错误\n * @returns Promise对象,表示异步更新操作\n */\n updateMarker: async (id: string, props: Partial<MarkerProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updateMarker(id, props);\n },\n /**\n * 添加折线覆盖物到地图\n * @param id - 折线的唯一标识符\n * @param props - 折线的配置属性\n * @returns Promise<void> 添加操作的异步结果\n * @throws 如果地图视图未初始化则抛出错误\n */\n addPolyline: async (id: string, props: PolylineProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addPolyline(id, props);\n },\n /**\n * 移除地图上的指定折线\n * @param id - 要移除的折线的唯一标识符\n * @throws 如果地图视图未初始化,抛出错误\n * @returns Promise<void>\n */\n removePolyline: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removePolyline(id);\n },\n /**\n * 更新地图上的折线覆盖物\n * \n * @param id 要更新的折线覆盖物的唯一标识符\n * @param props 要更新的折线属性,包含部分PolylineProps属性\n * @returns Promise<void> 异步操作结果\n * @throws 如果地图视图未初始化,抛出错误\n */\n updatePolyline: async (id: string, props: Partial<PolylineProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updatePolyline(id, props);\n },\n /**\n * 向地图添加多边形覆盖物\n * @param id - 多边形的唯一标识符\n * @param props - 多边形的配置属性\n * @returns Promise<void> 添加操作的异步结果\n * @throws 如果地图视图未初始化则抛出错误\n */\n addPolygon: async (id: string, props: PolygonProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addPolygon(id, props);\n },\n /**\n * 移除地图上的多边形覆盖物\n * @param id - 要移除的多边形覆盖物的唯一标识符\n * @throws 如果地图视图未初始化,抛出错误 'MapView not initialized'\n * @returns Promise<void> 异步操作完成\n */\n removePolygon: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removePolygon(id);\n },\n /**\n * 更新多边形覆盖物的属性\n * \n * @param id - 要更新的多边形覆盖物的唯一标识符\n * @param props - 要更新的多边形属性对象,包含需要更新的部分属性\n * @throws {Error} 当地图视图未初始化时抛出错误\n * @returns Promise<void> 异步操作完成后的Promise\n */\n updatePolygon: async (id: string, props: Partial<PolygonProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updatePolygon(id, props);\n },\n }), []);\n\n /**\n * 将传入的apiRef赋值给internalRef.current\n * 用于在组件内部保存对地图API实例的引用\n */\n React.useEffect(() => {\n internalRef.current = apiRef;\n }, [apiRef]);\n\n /**\n * 获取当前地图实例的API引用\n * @returns 返回地图API的引用对象,可用于调用地图相关方法\n */\n React.useImperativeHandle(ref, () => apiRef, [apiRef]);\n\n return (\n <MapContext.Provider value={internalRef}>\n <MarkerEventContext.Provider value={markerEventManager}>\n <CircleEventContext.Provider value={circleEventManager}>\n <PolygonEventContext.Provider value={polygonEventManager}>\n <PolylineEventContext.Provider value={polylineEventManager}>\n <NativeView\n ref={nativeRef}\n {...props}\n onMarkerPress={handleMarkerPress}\n onMarkerDragStart={handleMarkerDragStart}\n onMarkerDrag={handleMarkerDrag}\n onMarkerDragEnd={handleMarkerDragEnd}\n onCirclePress={handleCirclePress}\n onPolygonPress={handlePolygonPress}\n onPolylinePress={handlePolylinePress}\n >\n {props.children}\n </NativeView>\n </PolylineEventContext.Provider>\n </PolygonEventContext.Provider>\n </CircleEventContext.Provider>\n </MarkerEventContext.Provider>\n </MapContext.Provider>\n );\n});\n\nExpoGaodeMapView.displayName = 'ExpoGaodeMapView';\n\nexport default ExpoGaodeMapView;\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoGaodeMapView.js","sourceRoot":"","sources":["../src/ExpoGaodeMapView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAgBpD,MAAM,UAAU,GAA8E,wBAAwB,CAAC,cAAc,CAAC,CAAC;AAEvI,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,CAA4C,IAAI,CAAC,CAAC;AAa/F,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,aAAa,CAA4C,IAAI,CAAC,CAAC;AACvG,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,aAAa,CAA6C,IAAI,CAAC,CAAC;AACxG,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC,aAAa,CAA6C,IAAI,CAAC,CAAC;AACzG,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC,aAAa,CAA6C,IAAI,CAAC,CAAC;AAE1G;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,gBAAgB,GAAG,KAAK,CAAC,UAAU,CAA2B,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACjF,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAmB,IAAI,CAAC,CAAC;IACvD,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAoB,IAAI,CAAC,CAAC;IAC1D,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,YAAY,EAAwB,EAAE,EAAE,CAAC,CAAC;IAC7F,MAAM,kBA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AAI,KAAK,CAAC,CACV,aAAa,CAAC,CAAC,iBAAiB,CAAC,CACjC,iBAAiB,CAAC,CAAC,qBAAqB,CAAC,CACzC,YAAY,CAAC,CAAC,gBAAgB,CAAC,CAC/B,eAAe,CAAC,CAAC,mBAAmB,CAAC,CACrC,aAAa,CAAC,CAAC,iBAAiB,CAAC,CACjC,cAAc,CAAC,CAAC,kBAAkB,CAAC,CACnC,eAAe,CAAC,CAAC,mBAAmB,CAAC,CAErC;gBAAA,CAAC,KAAK,CAAC,QAAQ,CACjB;cAAA,EAAE,UAAU,CACd;YAAA,EAAE,oBAAoB,CAAC,QAAQ,CACjC;UAAA,EAAE,mBAAmB,CAAC,QAAQ,CAChC;QAAA,EAAE,kBAAkB,CAAC,QAAQ,CAC/B;MAAA,EAAE,kBAAkB,CAAC,QAAQ,CAC/B;IAAA,EAAE,UAAU,CAAC,QAAQ,CAAC,CACvB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC;AAElD,eAAe,gBAAgB,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\nimport { EventManager } from './utils/EventManager';\nimport type {\n MapViewProps,\n MapViewRef,\n NativeMapViewRef,\n CameraPosition,\n LatLng,\n Point,\n CircleProps,\n MarkerProps,\n PolylineProps,\n PolygonProps,\n} from './types';\n\nexport type { MapViewRef } from './types';\n\nconst NativeView: React.ComponentType<MapViewProps & { ref?: React.Ref<NativeMapViewRef> }> = requireNativeViewManager('ExpoGaodeMap');\n\nexport const MapContext = React.createContext<React.RefObject<MapViewRef | null> | null>(null);\n\ntype MarkerEventCallbacks = {\n onPress?: () => void;\n onDragStart?: () => void;\n onDrag?: () => void;\n onDragEnd?: (event: { nativeEvent: LatLng }) => void;\n};\n\ntype OverlayEventCallbacks = {\n onPress?: () => void;\n};\n\nexport const MarkerEventContext = React.createContext<EventManager<MarkerEventCallbacks> | null>(null);\nexport const CircleEventContext = React.createContext<EventManager<OverlayEventCallbacks> | null>(null);\nexport const PolygonEventContext = React.createContext<EventManager<OverlayEventCallbacks> | null>(null);\nexport const PolylineEventContext = React.createContext<EventManager<OverlayEventCallbacks> | null>(null);\n\n/**\n * 高德地图视图组件,提供地图操作API和覆盖物管理功能\n * \n * @param props - 组件属性\n * @param ref - 外部ref引用,用于访问地图API方法\n * @returns 返回包含地图视图和上下文提供者的React组件\n * \n * @remarks\n * 该组件内部维护两个ref:\n * - nativeRef: 指向原生地图视图的引用\n * - internalRef: 内部使用的API引用,通过MapContext共享\n * \n * 提供的主要API功能包括:\n * - 相机控制(移动、缩放、获取当前位置)\n * - 覆盖物管理(添加/删除/更新标记、折线、多边形、圆形等)\n * \n * 所有API方法都会检查地图是否已初始化,未初始化时抛出错误\n */\nconst ExpoGaodeMapView = React.forwardRef<MapViewRef, MapViewProps>((props, ref) => {\n const nativeRef = React.useRef<NativeMapViewRef>(null);\n const internalRef = React.useRef<MapViewRef | null>(null);\n const markerEventManager = React.useMemo(() => new EventManager<MarkerEventCallbacks>(), []);\n const circleEventManager = React.useMemo(() => new EventManager<OverlayEventCallbacks>(), []);\n const polygonEventManager = React.useMemo(() => new EventManager<OverlayEventCallbacks>(), []);\n const polylineEventManager = React.useMemo(() => new EventManager<OverlayEventCallbacks>(), []);\n const handleMarkerPress = (event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) markerEventManager.trigger(markerId, 'onPress');\n props.onMarkerPress?.(event);\n };\n \n const handleMarkerDragStart = (event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) markerEventManager.trigger(markerId, 'onDragStart');\n props.onMarkerDragStart?.(event);\n };\n \n const handleMarkerDrag = (event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) markerEventManager.trigger(markerId, 'onDrag');\n props.onMarkerDrag?.(event);\n };\n \n const handleMarkerDragEnd = (event: any) => {\n const markerId = event.nativeEvent?.markerId;\n if (markerId) {\n markerEventManager.trigger(markerId, 'onDragEnd', {\n nativeEvent: {\n latitude: event.nativeEvent.latitude,\n longitude: event.nativeEvent.longitude\n }\n });\n }\n props.onMarkerDragEnd?.(event);\n };\n \n const handleCirclePress = (event: any) => {\n const circleId = event.nativeEvent?.circleId;\n if (circleId) circleEventManager.trigger(circleId, 'onPress');\n props.onCirclePress?.(event);\n };\n \n const handlePolygonPress = (event: any) => {\n const polygonId = event.nativeEvent?.polygonId;\n if (polygonId) polygonEventManager.trigger(polygonId, 'onPress');\n props.onPolygonPress?.(event);\n };\n \n const handlePolylinePress = (event: any) => {\n const polylineId = event.nativeEvent?.polylineId;\n if (polylineId) polylineEventManager.trigger(polylineId, 'onPress');\n props.onPolylinePress?.(event);\n };\n\n const apiRef: MapViewRef = React.useMemo(() => ({\n /**\n * 移动地图相机到指定位置\n * @param position 相机位置参数对象,包含目标经纬度、缩放级别等信息\n * @param duration 动画持续时间(毫秒),默认300毫秒\n * @throws 如果地图视图未初始化则抛出错误\n * @returns Promise<void> 异步操作完成后的Promise\n */\n moveCamera: async (position: CameraPosition, duration: number = 300) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.moveCamera(position, duration);\n },\n /**\n * 将屏幕坐标点转换为地理坐标(经纬度)\n * @param point 屏幕坐标点 {x: number, y: number}\n * @returns 返回Promise,解析为对应的地理坐标 {latitude: number, longitude: number}\n * @throws 如果地图视图未初始化,抛出错误 'MapView not initialized'\n */\n getLatLng: async (point: Point) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.getLatLng(point);\n },\n /**\n * 设置地图中心点坐标\n * @param center 要设置的中心点坐标(LatLng格式)\n * @param animated 是否使用动画效果移动地图(默认为false)\n * @throws 如果地图视图未初始化则抛出错误\n */\n setCenter: async (center: LatLng, animated: boolean = false) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.setCenter(center, animated);\n },\n /**\n * 设置地图的缩放级别\n * @param zoom 目标缩放级别\n * @param animated 是否使用动画过渡效果,默认为false\n * @throws 如果地图视图未初始化,抛出错误\n */\n setZoom: async (zoom: number, animated: boolean = false) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.setZoom(zoom, animated);\n },\n /**\n * 获取当前地图的相机位置(视角中心点、缩放级别、倾斜角度等)\n * @returns 返回一个Promise,解析为当前相机位置的对象\n * @throws 如果地图视图未初始化,则抛出错误\n */\n getCameraPosition: async () => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.getCameraPosition();\n },\n /**\n * 在地图上添加圆形覆盖物\n * @param id - 圆形覆盖物的唯一标识符\n * @param props - 圆形覆盖物的属性配置\n * @returns Promise<void> 添加操作的异步结果\n * @throws 如果地图视图未初始化,抛出错误'MapView not initialized'\n */\n addCircle: async (id: string, props: CircleProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addCircle(id, props);\n },\n /**\n * 从地图上移除指定的圆形覆盖物\n * @param id - 要移除的圆形覆盖物的唯一标识符\n * @throws 如果地图视图未初始化,抛出错误\n * @returns Promise<void> 异步操作完成\n */\n removeCircle: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removeCircle(id);\n },\n /**\n * 更新地图上的圆形覆盖物\n * @param id 要更新的圆形覆盖物的唯一标识符\n * @param props 要更新的圆形属性(部分属性)\n * @throws 如果地图视图未初始化,抛出错误\n * @returns Promise<void> 表示更新操作完成\n */\n updateCircle: async (id: string, props: Partial<CircleProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updateCircle(id, props);\n },\n /**\n * 添加一个标记点到地图上\n * @param id 标记点的唯一标识符\n * @param props 标记点的配置属性\n * @returns Promise<void> 添加操作完成后的Promise\n * @throws 如果地图视图未初始化则抛出错误\n */\n addMarker: async (id: string, props: MarkerProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addMarker(id, props);\n },\n /**\n * 从地图上移除指定ID的标记点\n * @param id 要移除的标记点ID\n * @throws 如果地图视图未初始化则抛出错误\n * @returns Promise<void> 异步操作完成\n */\n removeMarker: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removeMarker(id);\n },\n /**\n * 更新地图上指定ID的标记点属性\n * @param id - 要更新的标记点唯一标识符\n * @param props - 需要更新的标记点属性对象(部分属性)\n * @throws 如果地图视图未初始化则抛出错误\n * @returns Promise对象,表示异步更新操作\n */\n updateMarker: async (id: string, props: Partial<MarkerProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updateMarker(id, props);\n },\n /**\n * 添加折线覆盖物到地图\n * @param id - 折线的唯一标识符\n * @param props - 折线的配置属性\n * @returns Promise<void> 添加操作的异步结果\n * @throws 如果地图视图未初始化则抛出错误\n */\n addPolyline: async (id: string, props: PolylineProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addPolyline(id, props);\n },\n /**\n * 移除地图上的指定折线\n * @param id - 要移除的折线的唯一标识符\n * @throws 如果地图视图未初始化,抛出错误\n * @returns Promise<void>\n */\n removePolyline: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removePolyline(id);\n },\n /**\n * 更新地图上的折线覆盖物\n * \n * @param id 要更新的折线覆盖物的唯一标识符\n * @param props 要更新的折线属性,包含部分PolylineProps属性\n * @returns Promise<void> 异步操作结果\n * @throws 如果地图视图未初始化,抛出错误\n */\n updatePolyline: async (id: string, props: Partial<PolylineProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updatePolyline(id, props);\n },\n /**\n * 向地图添加多边形覆盖物\n * @param id - 多边形的唯一标识符\n * @param props - 多边形的配置属性\n * @returns Promise<void> 添加操作的异步结果\n * @throws 如果地图视图未初始化则抛出错误\n */\n addPolygon: async (id: string, props: PolygonProps) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.addPolygon(id, props);\n },\n /**\n * 移除地图上的多边形覆盖物\n * @param id - 要移除的多边形覆盖物的唯一标识符\n * @throws 如果地图视图未初始化,抛出错误 'MapView not initialized'\n * @returns Promise<void> 异步操作完成\n */\n removePolygon: async (id: string) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.removePolygon(id);\n },\n /**\n * 更新多边形覆盖物的属性\n * \n * @param id - 要更新的多边形覆盖物的唯一标识符\n * @param props - 要更新的多边形属性对象,包含需要更新的部分属性\n * @throws {Error} 当地图视图未初始化时抛出错误\n * @returns Promise<void> 异步操作完成后的Promise\n */\n updatePolygon: async (id: string, props: Partial<PolygonProps>) => {\n if (!nativeRef.current) throw new Error('MapView not initialized');\n return nativeRef.current.updatePolygon(id, props);\n },\n }), []);\n\n /**\n * 将传入的apiRef赋值给internalRef.current\n * 用于在组件内部保存对地图API实例的引用\n */\n React.useEffect(() => {\n internalRef.current = apiRef;\n }, [apiRef]);\n\n /**\n * 获取当前地图实例的API引用\n * @returns 返回地图API的引用对象,可用于调用地图相关方法\n */\n React.useImperativeHandle(ref, () => apiRef, [apiRef]);\n\n return (\n <MapContext.Provider value={internalRef}>\n <MarkerEventContext.Provider value={markerEventManager}>\n <CircleEventContext.Provider value={circleEventManager}>\n <PolygonEventContext.Provider value={polygonEventManager}>\n <PolylineEventContext.Provider value={polylineEventManager}>\n <NativeView\n ref={nativeRef}\n {...props}\n onMarkerPress={handleMarkerPress}\n onMarkerDragStart={handleMarkerDragStart}\n onMarkerDrag={handleMarkerDrag}\n onMarkerDragEnd={handleMarkerDragEnd}\n onCirclePress={handleCirclePress}\n onPolygonPress={handlePolygonPress}\n onPolylinePress={handlePolylinePress}\n >\n {props.children}\n </NativeView>\n </PolylineEventContext.Provider>\n </PolygonEventContext.Provider>\n </CircleEventContext.Provider>\n </MarkerEventContext.Provider>\n </MapContext.Provider>\n );\n});\n\nExpoGaodeMapView.displayName = 'ExpoGaodeMapView';\n\nexport default ExpoGaodeMapView;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Circle.d.ts","sourceRoot":"","sources":["../../../src/components/overlays/Circle.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"Circle.d.ts","sourceRoot":"","sources":["../../../src/components/overlays/Circle.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,WAAW,QA0DhD"}
|