expo-gaode-map 0.1.6 → 1.0.0
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/PUBLISHING.md +1 -1
- package/README.md +57 -9
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapModule.kt +117 -26
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapView.kt +97 -36
- package/android/src/main/java/expo/modules/gaodemap/managers/CameraManager.kt +27 -21
- package/android/src/main/java/expo/modules/gaodemap/managers/OverlayManager.kt +4 -23
- package/android/src/main/java/expo/modules/gaodemap/managers/UIManager.kt +30 -27
- package/android/src/main/java/expo/modules/gaodemap/modules/LocationManager.kt +49 -4
- package/android/src/main/java/expo/modules/gaodemap/modules/SDKInitializer.kt +13 -5
- package/android/src/main/java/expo/modules/gaodemap/overlays/CircleView.kt +0 -6
- package/build/ExpoGaodeMapView.js +2 -2
- package/build/ExpoGaodeMapView.js.map +1 -1
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/modules/AMapPermissions.d.ts +27 -0
- package/build/modules/AMapPermissions.d.ts.map +1 -0
- package/build/modules/AMapPermissions.js +31 -0
- package/build/modules/AMapPermissions.js.map +1 -0
- package/build/modules/AMapView.d.ts +7 -2
- package/build/modules/AMapView.d.ts.map +1 -1
- package/build/modules/AMapView.js +15 -3
- package/build/modules/AMapView.js.map +1 -1
- package/build/types/common.types.d.ts +1 -0
- package/build/types/common.types.d.ts.map +1 -1
- package/build/types/common.types.js +1 -0
- package/build/types/common.types.js.map +1 -1
- package/docs/API.md +5 -1
- package/docs/ARCHITECTURE.md +421 -0
- package/docs/EXAMPLES.md +166 -24
- package/docs/INITIALIZATION.md +342 -0
- package/ios/ExpoGaodeMapModule.swift +95 -9
- package/ios/ExpoGaodeMapView.swift +88 -6
- package/ios/managers/CameraManager.swift +58 -0
- package/ios/managers/OverlayManager.swift +105 -29
- package/ios/managers/UIManager.swift +73 -1
- package/ios/modules/LocationManager.swift +109 -3
- package/ios/overlays/CircleView.swift +53 -0
- package/ios/overlays/HeatMapView.swift +27 -0
- package/ios/overlays/MarkerView.swift +29 -1
- package/ios/overlays/PolygonView.swift +51 -0
- package/ios/overlays/PolylineView.swift +61 -14
- package/ios/utils/PermissionManager.swift +58 -0
- package/package.json +1 -1
- package/src/ExpoGaodeMapView.tsx +2 -2
- package/src/index.ts +9 -1
- package/src/modules/AMapPermissions.ts +48 -0
- package/src/modules/AMapView.ts +15 -3
- package/src/types/common.types.ts +1 -0
package/PUBLISHING.md
CHANGED
package/README.md
CHANGED
|
@@ -76,27 +76,73 @@ npx react-native run-android
|
|
|
76
76
|
>
|
|
77
77
|
> 对于 Expo 项目,使用 `npx expo prebuild` 生成原生代码后进行配置。
|
|
78
78
|
|
|
79
|
-
### 2.
|
|
79
|
+
### 2. 初始化和权限管理
|
|
80
|
+
|
|
81
|
+
**推荐的初始化流程**:
|
|
80
82
|
|
|
81
83
|
```tsx
|
|
82
|
-
import { useEffect } from 'react';
|
|
83
|
-
import {
|
|
84
|
+
import { useEffect, useState } from 'react';
|
|
85
|
+
import {
|
|
86
|
+
MapView,
|
|
87
|
+
initSDK,
|
|
88
|
+
checkLocationPermission,
|
|
89
|
+
requestLocationPermission,
|
|
90
|
+
getCurrentLocation,
|
|
91
|
+
} from 'expo-gaode-map';
|
|
84
92
|
|
|
85
93
|
export default function App() {
|
|
94
|
+
const [initialPosition, setInitialPosition] = useState(null);
|
|
95
|
+
|
|
86
96
|
useEffect(() => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
97
|
+
const initialize = async () => {
|
|
98
|
+
// 1. 初始化 SDK
|
|
99
|
+
initSDK({
|
|
100
|
+
androidKey: 'your-android-api-key',
|
|
101
|
+
iosKey: 'your-ios-api-key',
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// 2. 检查并请求权限
|
|
105
|
+
const status = await checkLocationPermission();
|
|
106
|
+
if (!status.granted) {
|
|
107
|
+
await requestLocationPermission();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 3. 获取位置并设置地图
|
|
111
|
+
try {
|
|
112
|
+
const location = await getCurrentLocation();
|
|
113
|
+
setInitialPosition({
|
|
114
|
+
target: { latitude: location.latitude, longitude: location.longitude },
|
|
115
|
+
zoom: 15
|
|
116
|
+
});
|
|
117
|
+
} catch (error) {
|
|
118
|
+
// 使用默认位置
|
|
119
|
+
setInitialPosition({
|
|
120
|
+
target: { latitude: 39.9, longitude: 116.4 },
|
|
121
|
+
zoom: 10
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
initialize();
|
|
91
127
|
}, []);
|
|
92
128
|
|
|
129
|
+
if (!initialPosition) return null;
|
|
130
|
+
|
|
93
131
|
return (
|
|
94
|
-
|
|
132
|
+
<MapView
|
|
133
|
+
style={{ flex: 1 }}
|
|
134
|
+
initialCameraPosition={initialPosition}
|
|
135
|
+
myLocationEnabled={true}
|
|
136
|
+
/>
|
|
95
137
|
);
|
|
96
138
|
}
|
|
97
139
|
```
|
|
98
140
|
|
|
99
|
-
|
|
141
|
+
> 📖 **详细的初始化指南**: [INITIALIZATION.md](docs/INITIALIZATION.md)
|
|
142
|
+
>
|
|
143
|
+
> 包含完整的权限处理、错误处理和最佳实践。
|
|
144
|
+
|
|
145
|
+
### 3. 基础地图使用
|
|
100
146
|
|
|
101
147
|
```tsx
|
|
102
148
|
import { MapView } from 'expo-gaode-map';
|
|
@@ -151,6 +197,8 @@ export default function MapScreen() {
|
|
|
151
197
|
|
|
152
198
|
- [API 文档](docs/API.md) - 完整的 API 参考
|
|
153
199
|
- [使用示例](docs/EXAMPLES.md) - 详细的代码示例
|
|
200
|
+
- [初始化指南](docs/INITIALIZATION.md) - SDK 初始化和权限管理
|
|
201
|
+
- [架构文档](docs/ARCHITECTURE.md) - 项目结构和文件说明
|
|
154
202
|
|
|
155
203
|
## ⚠️ 注意事项
|
|
156
204
|
|
|
@@ -7,25 +7,33 @@ import expo.modules.gaodemap.modules.SDKInitializer
|
|
|
7
7
|
import expo.modules.gaodemap.modules.LocationManager
|
|
8
8
|
import expo.modules.gaodemap.overlays.*
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* 高德地图 Expo 模块
|
|
12
|
+
*
|
|
13
|
+
* 负责:
|
|
14
|
+
* - SDK 初始化和版本管理
|
|
15
|
+
* - 定位功能和配置
|
|
16
|
+
* - 权限管理
|
|
17
|
+
* - 地图视图和覆盖物注册
|
|
18
|
+
*/
|
|
10
19
|
class ExpoGaodeMapModule : Module() {
|
|
11
20
|
companion object {
|
|
12
21
|
private const val TAG = "ExpoGaodeMapModule"
|
|
13
22
|
}
|
|
14
23
|
|
|
24
|
+
/** 定位管理器实例 */
|
|
15
25
|
private var locationManager: LocationManager? = null
|
|
16
26
|
|
|
17
27
|
override fun definition() = ModuleDefinition {
|
|
18
28
|
Name("ExpoGaodeMap")
|
|
19
|
-
|
|
20
|
-
Log.d(TAG, "ExpoGaodeMapModule 正在定义")
|
|
21
29
|
|
|
22
30
|
// ==================== SDK 初始化 ====================
|
|
23
31
|
|
|
24
32
|
/**
|
|
25
33
|
* 初始化 SDK(地图 + 定位)
|
|
34
|
+
* @param config 配置对象,包含 androidKey
|
|
26
35
|
*/
|
|
27
36
|
Function("initSDK") { config: Map<String, String> ->
|
|
28
|
-
Log.d(TAG, "initSDK 被调用")
|
|
29
37
|
val androidKey = config["androidKey"]
|
|
30
38
|
if (androidKey != null) {
|
|
31
39
|
SDKInitializer.initSDK(appContext.reactContext!!, androidKey)
|
|
@@ -35,6 +43,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
35
43
|
|
|
36
44
|
/**
|
|
37
45
|
* 获取 SDK 版本
|
|
46
|
+
* @return SDK 版本号
|
|
38
47
|
*/
|
|
39
48
|
Function("getVersion") {
|
|
40
49
|
SDKInitializer.getVersion()
|
|
@@ -57,7 +66,8 @@ class ExpoGaodeMapModule : Module() {
|
|
|
57
66
|
}
|
|
58
67
|
|
|
59
68
|
/**
|
|
60
|
-
*
|
|
69
|
+
* 检查是否正在定位
|
|
70
|
+
* @return 是否正在定位
|
|
61
71
|
*/
|
|
62
72
|
AsyncFunction("isStarted") { promise: expo.modules.kotlin.Promise ->
|
|
63
73
|
promise.resolve(getLocationManager().isStarted())
|
|
@@ -65,6 +75,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
65
75
|
|
|
66
76
|
/**
|
|
67
77
|
* 获取当前位置(单次定位)
|
|
78
|
+
* @return 位置信息对象
|
|
68
79
|
*/
|
|
69
80
|
AsyncFunction("getCurrentLocation") { promise: expo.modules.kotlin.Promise ->
|
|
70
81
|
getLocationManager().getCurrentLocation(promise)
|
|
@@ -72,6 +83,9 @@ class ExpoGaodeMapModule : Module() {
|
|
|
72
83
|
|
|
73
84
|
/**
|
|
74
85
|
* 坐标转换
|
|
86
|
+
* @param coordinate 原始坐标
|
|
87
|
+
* @param type 坐标类型
|
|
88
|
+
* @return 转换后的坐标
|
|
75
89
|
*/
|
|
76
90
|
AsyncFunction("coordinateConvert") { coordinate: Map<String, Double>, type: Int, promise: expo.modules.kotlin.Promise ->
|
|
77
91
|
getLocationManager().coordinateConvert(coordinate, type, promise)
|
|
@@ -81,6 +95,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
81
95
|
|
|
82
96
|
/**
|
|
83
97
|
* 设置是否返回逆地理信息
|
|
98
|
+
* @param isReGeocode 是否返回逆地理信息
|
|
84
99
|
*/
|
|
85
100
|
Function("setLocatingWithReGeocode") { isReGeocode: Boolean ->
|
|
86
101
|
getLocationManager().setLocatingWithReGeocode(isReGeocode)
|
|
@@ -88,6 +103,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
88
103
|
|
|
89
104
|
/**
|
|
90
105
|
* 设置定位模式
|
|
106
|
+
* @param mode 定位模式
|
|
91
107
|
*/
|
|
92
108
|
Function("setLocationMode") { mode: Int ->
|
|
93
109
|
getLocationManager().setLocationMode(mode)
|
|
@@ -95,6 +111,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
95
111
|
|
|
96
112
|
/**
|
|
97
113
|
* 设置定位间隔
|
|
114
|
+
* @param interval 间隔时间(毫秒)
|
|
98
115
|
*/
|
|
99
116
|
Function("setInterval") { interval: Int ->
|
|
100
117
|
getLocationManager().setInterval(interval)
|
|
@@ -102,6 +119,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
102
119
|
|
|
103
120
|
/**
|
|
104
121
|
* 设置是否单次定位
|
|
122
|
+
* @param isOnceLocation 是否单次定位
|
|
105
123
|
*/
|
|
106
124
|
Function("setOnceLocation") { isOnceLocation: Boolean ->
|
|
107
125
|
getLocationManager().setOnceLocation(isOnceLocation)
|
|
@@ -109,6 +127,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
109
127
|
|
|
110
128
|
/**
|
|
111
129
|
* 设置是否使用设备传感器
|
|
130
|
+
* @param sensorEnable 是否启用传感器
|
|
112
131
|
*/
|
|
113
132
|
Function("setSensorEnable") { sensorEnable: Boolean ->
|
|
114
133
|
getLocationManager().setSensorEnable(sensorEnable)
|
|
@@ -116,6 +135,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
116
135
|
|
|
117
136
|
/**
|
|
118
137
|
* 设置是否允许 WIFI 扫描
|
|
138
|
+
* @param wifiScan 是否允许 WIFI 扫描
|
|
119
139
|
*/
|
|
120
140
|
Function("setWifiScan") { wifiScan: Boolean ->
|
|
121
141
|
getLocationManager().setWifiScan(wifiScan)
|
|
@@ -123,6 +143,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
123
143
|
|
|
124
144
|
/**
|
|
125
145
|
* 设置是否 GPS 优先
|
|
146
|
+
* @param gpsFirst 是否 GPS 优先
|
|
126
147
|
*/
|
|
127
148
|
Function("setGpsFirst") { gpsFirst: Boolean ->
|
|
128
149
|
getLocationManager().setGpsFirst(gpsFirst)
|
|
@@ -130,6 +151,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
130
151
|
|
|
131
152
|
/**
|
|
132
153
|
* 设置是否等待 WIFI 列表刷新
|
|
154
|
+
* @param onceLocationLatest 是否等待刷新
|
|
133
155
|
*/
|
|
134
156
|
Function("setOnceLocationLatest") { onceLocationLatest: Boolean ->
|
|
135
157
|
getLocationManager().setOnceLocationLatest(onceLocationLatest)
|
|
@@ -137,6 +159,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
137
159
|
|
|
138
160
|
/**
|
|
139
161
|
* 设置逆地理语言
|
|
162
|
+
* @param language 语言代码
|
|
140
163
|
*/
|
|
141
164
|
Function("setGeoLanguage") { language: String ->
|
|
142
165
|
getLocationManager().setGeoLanguage(language)
|
|
@@ -144,6 +167,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
144
167
|
|
|
145
168
|
/**
|
|
146
169
|
* 设置是否使用缓存策略
|
|
170
|
+
* @param locationCacheEnable 是否启用缓存
|
|
147
171
|
*/
|
|
148
172
|
Function("setLocationCacheEnable") { locationCacheEnable: Boolean ->
|
|
149
173
|
getLocationManager().setLocationCacheEnable(locationCacheEnable)
|
|
@@ -151,11 +175,92 @@ class ExpoGaodeMapModule : Module() {
|
|
|
151
175
|
|
|
152
176
|
/**
|
|
153
177
|
* 设置网络请求超时时间
|
|
178
|
+
* @param httpTimeOut 超时时间(毫秒)
|
|
154
179
|
*/
|
|
155
180
|
Function("setHttpTimeOut") { httpTimeOut: Int ->
|
|
156
181
|
getLocationManager().setHttpTimeOut(httpTimeOut)
|
|
157
182
|
}
|
|
158
183
|
|
|
184
|
+
// ==================== 权限管理 ====================
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* 检查位置权限状态
|
|
188
|
+
* @return 权限状态对象
|
|
189
|
+
*/
|
|
190
|
+
AsyncFunction("checkLocationPermission") { promise: expo.modules.kotlin.Promise ->
|
|
191
|
+
val context = appContext.reactContext!!
|
|
192
|
+
val fineLocation = android.Manifest.permission.ACCESS_FINE_LOCATION
|
|
193
|
+
val coarseLocation = android.Manifest.permission.ACCESS_COARSE_LOCATION
|
|
194
|
+
|
|
195
|
+
val hasFine = androidx.core.content.ContextCompat.checkSelfPermission(context, fineLocation) ==
|
|
196
|
+
android.content.pm.PackageManager.PERMISSION_GRANTED
|
|
197
|
+
val hasCoarse = androidx.core.content.ContextCompat.checkSelfPermission(context, coarseLocation) ==
|
|
198
|
+
android.content.pm.PackageManager.PERMISSION_GRANTED
|
|
199
|
+
|
|
200
|
+
promise.resolve(mapOf(
|
|
201
|
+
"granted" to (hasFine && hasCoarse),
|
|
202
|
+
"fineLocation" to hasFine,
|
|
203
|
+
"coarseLocation" to hasCoarse
|
|
204
|
+
))
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 请求位置权限
|
|
209
|
+
* 注意: Android 权限请求是异步的,使用轮询方式检查权限状态
|
|
210
|
+
* @return 权限请求结果
|
|
211
|
+
*/
|
|
212
|
+
AsyncFunction("requestLocationPermission") { promise: expo.modules.kotlin.Promise ->
|
|
213
|
+
val activity = appContext.currentActivity
|
|
214
|
+
if (activity == null) {
|
|
215
|
+
promise.reject("NO_ACTIVITY", "Activity not available", null)
|
|
216
|
+
return@AsyncFunction
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
val permissions = arrayOf(
|
|
220
|
+
android.Manifest.permission.ACCESS_FINE_LOCATION,
|
|
221
|
+
android.Manifest.permission.ACCESS_COARSE_LOCATION
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
androidx.core.app.ActivityCompat.requestPermissions(activity, permissions, 1001)
|
|
225
|
+
|
|
226
|
+
// 使用 WeakReference 避免内存泄露
|
|
227
|
+
val contextRef = java.lang.ref.WeakReference(appContext.reactContext)
|
|
228
|
+
val handler = android.os.Handler(android.os.Looper.getMainLooper())
|
|
229
|
+
var attempts = 0
|
|
230
|
+
val maxAttempts = 30 // 3 秒 / 100ms
|
|
231
|
+
|
|
232
|
+
val checkPermission = object : Runnable {
|
|
233
|
+
override fun run() {
|
|
234
|
+
val context = contextRef.get()
|
|
235
|
+
if (context == null) {
|
|
236
|
+
promise.reject("CONTEXT_LOST", "Context was garbage collected", null)
|
|
237
|
+
return
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
val hasFine = androidx.core.content.ContextCompat.checkSelfPermission(
|
|
241
|
+
context, android.Manifest.permission.ACCESS_FINE_LOCATION
|
|
242
|
+
) == android.content.pm.PackageManager.PERMISSION_GRANTED
|
|
243
|
+
val hasCoarse = androidx.core.content.ContextCompat.checkSelfPermission(
|
|
244
|
+
context, android.Manifest.permission.ACCESS_COARSE_LOCATION
|
|
245
|
+
) == android.content.pm.PackageManager.PERMISSION_GRANTED
|
|
246
|
+
|
|
247
|
+
// 如果权限已授予或达到最大尝试次数,返回结果并清理 Handler
|
|
248
|
+
if ((hasFine && hasCoarse) || attempts >= maxAttempts) {
|
|
249
|
+
handler.removeCallbacks(this)
|
|
250
|
+
promise.resolve(mapOf(
|
|
251
|
+
"granted" to (hasFine && hasCoarse),
|
|
252
|
+
"fineLocation" to hasFine,
|
|
253
|
+
"coarseLocation" to hasCoarse
|
|
254
|
+
))
|
|
255
|
+
} else {
|
|
256
|
+
attempts++
|
|
257
|
+
handler.postDelayed(this, 100)
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
handler.postDelayed(checkPermission, 100)
|
|
263
|
+
}
|
|
159
264
|
|
|
160
265
|
// ==================== 事件 ====================
|
|
161
266
|
|
|
@@ -164,21 +269,18 @@ class ExpoGaodeMapModule : Module() {
|
|
|
164
269
|
// ==================== 视图定义 ====================
|
|
165
270
|
|
|
166
271
|
View(ExpoGaodeMapView::class) {
|
|
167
|
-
Log.d(TAG, "正在注册 ExpoGaodeMapView 视图")
|
|
168
272
|
|
|
169
|
-
// 事件
|
|
273
|
+
// 事件
|
|
170
274
|
Events("onMapPress", "onMapLongPress", "onLoad")
|
|
171
275
|
|
|
172
|
-
// 地图类型
|
|
276
|
+
// 地图类型
|
|
173
277
|
Prop<Int>("mapType") { view, type ->
|
|
174
|
-
Log.d(TAG, "✅ Prop mapType 被调用: $type")
|
|
175
278
|
view.mapType = type
|
|
176
279
|
view.setMapType(type)
|
|
177
280
|
}
|
|
178
281
|
|
|
179
|
-
// 初始相机位置
|
|
282
|
+
// 初始相机位置
|
|
180
283
|
Prop<Map<String, Any?>?>("initialCameraPosition") { view, position ->
|
|
181
|
-
Log.d(TAG, "✅ Prop initialCameraPosition 被调用: $position")
|
|
182
284
|
view.initialCameraPosition = position
|
|
183
285
|
position?.let { view.setInitialCameraPosition(it) }
|
|
184
286
|
}
|
|
@@ -208,24 +310,18 @@ class ExpoGaodeMapModule : Module() {
|
|
|
208
310
|
Prop<Boolean>("buildingsEnabled") { view, show -> view.setShowsBuildings(show) }
|
|
209
311
|
Prop<Boolean>("indoorViewEnabled") { view, show -> view.setShowsIndoorMap(show) }
|
|
210
312
|
|
|
211
|
-
// 生命周期方法
|
|
313
|
+
// 生命周期方法
|
|
212
314
|
OnViewDidUpdateProps { view: ExpoGaodeMapView ->
|
|
213
|
-
Log.d(TAG, "🎯 OnViewDidUpdateProps 被调用")
|
|
214
|
-
Log.d(TAG, "当前 mapType: ${view.mapType}")
|
|
215
|
-
Log.d(TAG, "当前 initialCameraPosition: ${view.initialCameraPosition}")
|
|
216
|
-
|
|
217
|
-
// 手动应用 Props
|
|
218
315
|
if (view.mapType != 0) {
|
|
219
|
-
Log.d(TAG, "应用 mapType: ${view.mapType}")
|
|
220
316
|
view.setMapType(view.mapType)
|
|
221
317
|
}
|
|
222
318
|
|
|
223
319
|
view.initialCameraPosition?.let { position ->
|
|
224
|
-
Log.d(TAG, "应用 initialCameraPosition: $position")
|
|
225
320
|
view.setInitialCameraPosition(position)
|
|
226
321
|
}
|
|
227
322
|
}
|
|
228
323
|
|
|
324
|
+
// 相机控制方法
|
|
229
325
|
AsyncFunction("moveCamera") { view: ExpoGaodeMapView, position: Map<String, Any>, duration: Int ->
|
|
230
326
|
view.moveCamera(position, duration)
|
|
231
327
|
}
|
|
@@ -246,6 +342,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
246
342
|
view.getCameraPosition()
|
|
247
343
|
}
|
|
248
344
|
|
|
345
|
+
// Circle 命令
|
|
249
346
|
AsyncFunction("addCircle") { view: ExpoGaodeMapView, id: String, props: Map<String, Any> ->
|
|
250
347
|
view.addCircle(id, props)
|
|
251
348
|
}
|
|
@@ -258,6 +355,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
258
355
|
view.updateCircle(id, props)
|
|
259
356
|
}
|
|
260
357
|
|
|
358
|
+
// Marker 命令
|
|
261
359
|
AsyncFunction("addMarker") { view: ExpoGaodeMapView, id: String, props: Map<String, Any> ->
|
|
262
360
|
view.addMarker(id, props)
|
|
263
361
|
}
|
|
@@ -285,17 +383,14 @@ class ExpoGaodeMapModule : Module() {
|
|
|
285
383
|
|
|
286
384
|
// Polygon 命令
|
|
287
385
|
AsyncFunction("addPolygon") { view: ExpoGaodeMapView, id: String, props: Map<String, Any> ->
|
|
288
|
-
Log.d(TAG, "🔷 Module addPolygon 被调用: id=$id, props=$props")
|
|
289
386
|
view.addPolygon(id, props)
|
|
290
387
|
}
|
|
291
388
|
|
|
292
389
|
AsyncFunction("removePolygon") { view: ExpoGaodeMapView, id: String ->
|
|
293
|
-
Log.d(TAG, "🗑️ Module removePolygon 被调用: id=$id")
|
|
294
390
|
view.removePolygon(id)
|
|
295
391
|
}
|
|
296
392
|
|
|
297
393
|
AsyncFunction("updatePolygon") { view: ExpoGaodeMapView, id: String, props: Map<String, Any> ->
|
|
298
|
-
Log.d(TAG, "🔄 Module updatePolygon 被调用: id=$id, props=$props")
|
|
299
394
|
view.updatePolygon(id, props)
|
|
300
395
|
}
|
|
301
396
|
}
|
|
@@ -328,27 +423,22 @@ class ExpoGaodeMapModule : Module() {
|
|
|
328
423
|
Events("onPress")
|
|
329
424
|
|
|
330
425
|
Prop<Map<String, Double>>("center") { view, center ->
|
|
331
|
-
Log.d(TAG, "✅ Prop center 被调用: $center")
|
|
332
426
|
view.setCenter(center)
|
|
333
427
|
}
|
|
334
428
|
|
|
335
429
|
Prop<Double>("radius") { view, radius ->
|
|
336
|
-
Log.d(TAG, "✅ Prop radius 被调用: $radius")
|
|
337
430
|
view.setRadius(radius)
|
|
338
431
|
}
|
|
339
432
|
|
|
340
433
|
Prop<Int>("fillColor") { view, color ->
|
|
341
|
-
Log.d(TAG, "✅ Prop fillColor 被调用: $color")
|
|
342
434
|
view.setFillColor(color)
|
|
343
435
|
}
|
|
344
436
|
|
|
345
437
|
Prop<Int>("strokeColor") { view, color ->
|
|
346
|
-
Log.d(TAG, "✅ Prop strokeColor 被调用: $color")
|
|
347
438
|
view.setStrokeColor(color)
|
|
348
439
|
}
|
|
349
440
|
|
|
350
441
|
Prop<Float>("strokeWidth") { view, width ->
|
|
351
|
-
Log.d(TAG, "✅ Prop strokeWidth 被调用: $width")
|
|
352
442
|
view.setStrokeWidth(width)
|
|
353
443
|
}
|
|
354
444
|
}
|
|
@@ -444,6 +534,7 @@ class ExpoGaodeMapModule : Module() {
|
|
|
444
534
|
|
|
445
535
|
/**
|
|
446
536
|
* 获取或创建定位管理器
|
|
537
|
+
* @return 定位管理器实例
|
|
447
538
|
*/
|
|
448
539
|
private fun getLocationManager(): LocationManager {
|
|
449
540
|
if (locationManager == null) {
|