expo-gaode-map 1.1.8 → 2.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +32 -46
- package/README.md +51 -70
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapView.kt +98 -268
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapViewModule.kt +1 -49
- package/android/src/main/java/expo/modules/gaodemap/managers/CameraManager.kt +30 -7
- package/android/src/main/java/expo/modules/gaodemap/managers/UIManager.kt +1 -0
- package/android/src/main/java/expo/modules/gaodemap/modules/LocationManager.kt +10 -1
- package/android/src/main/java/expo/modules/gaodemap/overlays/CircleView.kt +38 -14
- package/android/src/main/java/expo/modules/gaodemap/overlays/CircleViewModule.kt +3 -3
- package/android/src/main/java/expo/modules/gaodemap/overlays/ClusterView.kt +8 -1
- package/android/src/main/java/expo/modules/gaodemap/overlays/HeatMapView.kt +4 -1
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerView.kt +322 -93
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerViewModule.kt +11 -3
- package/android/src/main/java/expo/modules/gaodemap/overlays/MultiPointView.kt +4 -1
- package/android/src/main/java/expo/modules/gaodemap/overlays/PolygonView.kt +25 -11
- package/android/src/main/java/expo/modules/gaodemap/overlays/PolygonViewModule.kt +3 -3
- package/android/src/main/java/expo/modules/gaodemap/overlays/PolylineView.kt +20 -10
- package/android/src/main/java/expo/modules/gaodemap/overlays/PolylineViewModule.kt +6 -2
- package/build/ExpoGaodeMap.types.d.ts +27 -6
- package/build/ExpoGaodeMap.types.d.ts.map +1 -1
- package/build/ExpoGaodeMap.types.js +3 -0
- package/build/ExpoGaodeMap.types.js.map +1 -1
- package/build/ExpoGaodeMapModule.d.ts +157 -10
- package/build/ExpoGaodeMapModule.d.ts.map +1 -1
- package/build/ExpoGaodeMapModule.js +4 -0
- package/build/ExpoGaodeMapModule.js.map +1 -1
- package/build/ExpoGaodeMapView.d.ts +1 -17
- package/build/ExpoGaodeMapView.d.ts.map +1 -1
- package/build/ExpoGaodeMapView.js +4 -221
- package/build/ExpoGaodeMapView.js.map +1 -1
- package/build/components/overlays/Circle.d.ts +11 -1
- package/build/components/overlays/Circle.d.ts.map +1 -1
- package/build/components/overlays/Circle.js +12 -58
- package/build/components/overlays/Circle.js.map +1 -1
- package/build/components/overlays/Cluster.d.ts.map +1 -1
- package/build/components/overlays/Cluster.js.map +1 -1
- package/build/components/overlays/Marker.d.ts +13 -1
- package/build/components/overlays/Marker.d.ts.map +1 -1
- package/build/components/overlays/Marker.js +51 -115
- package/build/components/overlays/Marker.js.map +1 -1
- package/build/components/overlays/Polygon.d.ts +7 -15
- package/build/components/overlays/Polygon.d.ts.map +1 -1
- package/build/components/overlays/Polygon.js +10 -80
- package/build/components/overlays/Polygon.js.map +1 -1
- package/build/components/overlays/Polyline.d.ts +7 -14
- package/build/components/overlays/Polyline.d.ts.map +1 -1
- package/build/components/overlays/Polyline.js +9 -66
- package/build/components/overlays/Polyline.js.map +1 -1
- package/build/index.d.ts +1 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -10
- package/build/index.js.map +1 -1
- package/build/types/map-view.types.d.ts +0 -90
- package/build/types/map-view.types.d.ts.map +1 -1
- package/build/types/map-view.types.js.map +1 -1
- package/build/types/overlays.types.d.ts +9 -9
- package/build/types/overlays.types.d.ts.map +1 -1
- package/build/types/overlays.types.js.map +1 -1
- package/docs/API.en.md +1 -21
- package/docs/API.md +84 -56
- package/docs/EXAMPLES.en.md +0 -48
- package/docs/EXAMPLES.md +49 -102
- package/docs/INITIALIZATION.md +59 -71
- package/docs/MIGRATION.md +423 -0
- package/ios/ExpoGaodeMapModule.swift +4 -0
- package/ios/ExpoGaodeMapView.swift +365 -258
- package/ios/ExpoGaodeMapViewModule.swift +3 -50
- package/ios/managers/CameraManager.swift +23 -2
- package/ios/managers/UIManager.swift +10 -5
- package/ios/modules/LocationManager.swift +10 -0
- package/ios/overlays/CircleView.swift +98 -19
- package/ios/overlays/CircleViewModule.swift +21 -0
- package/ios/overlays/ClusterView.swift +33 -4
- package/ios/overlays/HeatMapView.swift +16 -4
- package/ios/overlays/MarkerView.swift +235 -146
- package/ios/overlays/MarkerViewModule.swift +7 -3
- package/ios/overlays/MultiPointView.swift +30 -1
- package/ios/overlays/PolygonView.swift +63 -12
- package/ios/overlays/PolygonViewModule.swift +17 -0
- package/ios/overlays/PolylineView.swift +95 -25
- package/ios/overlays/PolylineViewModule.swift +17 -8
- package/ios/utils/PermissionManager.swift +9 -14
- package/package.json +4 -3
- package/src/ExpoGaodeMap.types.ts +28 -3
- package/src/ExpoGaodeMapModule.ts +201 -12
- package/src/ExpoGaodeMapView.tsx +9 -234
- package/src/components/overlays/Circle.tsx +14 -70
- package/src/components/overlays/Cluster.tsx +0 -1
- package/src/components/overlays/Marker.tsx +63 -138
- package/src/components/overlays/Polygon.tsx +12 -92
- package/src/components/overlays/Polyline.tsx +11 -77
- package/src/index.ts +4 -29
- package/src/types/map-view.types.ts +1 -85
- package/src/types/overlays.types.ts +9 -9
- package/android/src/main/java/expo/modules/gaodemap/managers/OverlayManager.kt +0 -574
- package/build/modules/AMapLocation.d.ts +0 -78
- package/build/modules/AMapLocation.d.ts.map +0 -1
- package/build/modules/AMapLocation.js +0 -132
- package/build/modules/AMapLocation.js.map +0 -1
- package/build/modules/AMapPermissions.d.ts +0 -29
- package/build/modules/AMapPermissions.d.ts.map +0 -1
- package/build/modules/AMapPermissions.js +0 -23
- package/build/modules/AMapPermissions.js.map +0 -1
- package/build/modules/AMapSDK.d.ts +0 -22
- package/build/modules/AMapSDK.d.ts.map +0 -1
- package/build/modules/AMapSDK.js +0 -25
- package/build/modules/AMapSDK.js.map +0 -1
- package/build/modules/AMapView.d.ts +0 -44
- package/build/modules/AMapView.d.ts.map +0 -1
- package/build/modules/AMapView.js +0 -65
- package/build/modules/AMapView.js.map +0 -1
- package/ios/managers/OverlayManager.swift +0 -522
- package/src/modules/AMapLocation.ts +0 -165
- package/src/modules/AMapPermissions.ts +0 -41
- package/src/modules/AMapSDK.ts +0 -31
- package/src/modules/AMapView.ts +0 -72
package/README.en.md
CHANGED
|
@@ -22,6 +22,8 @@ A full-featured AMap (Gaode Map) React Native component library, **built with Ex
|
|
|
22
22
|
|
|
23
23
|
## 📦 Installation
|
|
24
24
|
|
|
25
|
+
### Stable Version (Recommended)
|
|
26
|
+
|
|
25
27
|
```bash
|
|
26
28
|
npm install expo-gaode-map
|
|
27
29
|
# or
|
|
@@ -30,6 +32,30 @@ yarn add expo-gaode-map
|
|
|
30
32
|
pnpm add expo-gaode-map
|
|
31
33
|
```
|
|
32
34
|
|
|
35
|
+
### Try 2.0 Beta Version 🚀
|
|
36
|
+
|
|
37
|
+
> ⚠️ **Important**: Version 2.0 contains breaking changes with significant API adjustments. See [Migration Guide](docs/MIGRATION.md)
|
|
38
|
+
|
|
39
|
+
If you want to try the latest 2.0 alpha version (with improved architecture and better type support):
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install expo-gaode-map@next
|
|
43
|
+
# or
|
|
44
|
+
yarn add expo-gaode-map@next
|
|
45
|
+
# or
|
|
46
|
+
pnpm add expo-gaode-map@next
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Major Changes in 2.0:**
|
|
50
|
+
- ✅ Unified API calling method (`ExpoGaodeMapModule`)
|
|
51
|
+
- ✅ Complete TypeScript type support
|
|
52
|
+
- ✅ Removed unnecessary wrapper layers, direct native module calls
|
|
53
|
+
- ⚠️ **Not backward compatible**, code updates required per [Migration Guide](docs/MIGRATION.md)
|
|
54
|
+
|
|
55
|
+
**Version Comparison:**
|
|
56
|
+
- `1.x` (Stable): `import { initSDK, start, stop } from 'expo-gaode-map'`
|
|
57
|
+
- `2.0` (Beta): `import { ExpoGaodeMapModule } from 'expo-gaode-map'`
|
|
58
|
+
|
|
33
59
|
### Expo Projects
|
|
34
60
|
|
|
35
61
|
If you're using an Expo managed project (using `expo prebuild` or development builds), you need to rebuild native code after installation:
|
|
@@ -87,10 +113,7 @@ Visit [AMap Open Platform](https://lbs.amap.com/) to register and create an appl
|
|
|
87
113
|
import { useEffect, useState } from 'react';
|
|
88
114
|
import {
|
|
89
115
|
MapView,
|
|
90
|
-
|
|
91
|
-
checkLocationPermission,
|
|
92
|
-
requestLocationPermission,
|
|
93
|
-
getCurrentLocation,
|
|
116
|
+
ExpoGaodeMapModule,
|
|
94
117
|
} from 'expo-gaode-map';
|
|
95
118
|
|
|
96
119
|
export default function App() {
|
|
@@ -99,20 +122,20 @@ export default function App() {
|
|
|
99
122
|
useEffect(() => {
|
|
100
123
|
const initialize = async () => {
|
|
101
124
|
// 1. Initialize SDK
|
|
102
|
-
initSDK({
|
|
125
|
+
ExpoGaodeMapModule.initSDK({
|
|
103
126
|
androidKey: 'your-android-api-key',
|
|
104
127
|
iosKey: 'your-ios-api-key',
|
|
105
128
|
});
|
|
106
129
|
|
|
107
130
|
// 2. Check and request permission
|
|
108
|
-
const status = await checkLocationPermission();
|
|
131
|
+
const status = await ExpoGaodeMapModule.checkLocationPermission();
|
|
109
132
|
if (!status.granted) {
|
|
110
|
-
await requestLocationPermission();
|
|
133
|
+
await ExpoGaodeMapModule.requestLocationPermission();
|
|
111
134
|
}
|
|
112
135
|
|
|
113
136
|
// 3. Get location and set map
|
|
114
137
|
try {
|
|
115
|
-
const location = await getCurrentLocation();
|
|
138
|
+
const location = await ExpoGaodeMapModule.getCurrentLocation();
|
|
116
139
|
setInitialPosition({
|
|
117
140
|
target: { latitude: location.latitude, longitude: location.longitude },
|
|
118
141
|
zoom: 15
|
|
@@ -202,6 +225,7 @@ Includes:
|
|
|
202
225
|
- [Usage Examples](docs/EXAMPLES.en.md) - Detailed code examples
|
|
203
226
|
- [Initialization Guide](docs/INITIALIZATION.en.md) - SDK initialization and permission management
|
|
204
227
|
- [Architecture Documentation](docs/ARCHITECTURE.en.md) - Project structure and file descriptions
|
|
228
|
+
- [Migration Guide](docs/MIGRATION.md) - Migration guide from v1.x to v2.0
|
|
205
229
|
|
|
206
230
|
## 🎨 Advanced Usage
|
|
207
231
|
|
|
@@ -231,38 +255,6 @@ Includes:
|
|
|
231
255
|
- ✅ Map auto-follows user movement
|
|
232
256
|
- ⚠️ Suitable for navigation scenarios
|
|
233
257
|
|
|
234
|
-
### Imperative API Batch Operations
|
|
235
|
-
|
|
236
|
-
```tsx
|
|
237
|
-
const mapRef = useRef<MapViewRef>(null);
|
|
238
|
-
|
|
239
|
-
// Add multiple overlays
|
|
240
|
-
const addMultipleOverlays = async () => {
|
|
241
|
-
await mapRef.current?.addCircle('circle1', {
|
|
242
|
-
center: { latitude: 39.9, longitude: 116.4 },
|
|
243
|
-
radius: 1000,
|
|
244
|
-
fillColor: 0x8800FF00,
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
await mapRef.current?.addCircle('circle2', {
|
|
248
|
-
center: { latitude: 40.0, longitude: 116.5 },
|
|
249
|
-
radius: 500,
|
|
250
|
-
fillColor: 0x880000FF,
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
await mapRef.current?.addMarker('marker1', {
|
|
254
|
-
position: { latitude: 39.95, longitude: 116.45 },
|
|
255
|
-
title: 'Beijing',
|
|
256
|
-
});
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
// Batch clear
|
|
260
|
-
const clearAll = async () => {
|
|
261
|
-
await mapRef.current?.removeCircle('circle1');
|
|
262
|
-
await mapRef.current?.removeCircle('circle2');
|
|
263
|
-
await mapRef.current?.removeMarker('marker1');
|
|
264
|
-
};
|
|
265
|
-
```
|
|
266
258
|
|
|
267
259
|
### Color Format
|
|
268
260
|
|
|
@@ -272,12 +264,6 @@ Overlay colors support two formats:
|
|
|
272
264
|
```tsx
|
|
273
265
|
<Circle fillColor="#8800FF00" /> // 50% transparent green
|
|
274
266
|
```
|
|
275
|
-
|
|
276
|
-
2. **Number format** (imperative API): `0xAARRGGBB`
|
|
277
|
-
```tsx
|
|
278
|
-
await mapRef.current?.addCircle('circle1', {
|
|
279
|
-
fillColor: 0x8800FF00, // 50% transparent green
|
|
280
|
-
});
|
|
281
267
|
```
|
|
282
268
|
|
|
283
269
|
### Performance Optimization
|
package/README.md
CHANGED
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
|
|
23
23
|
## 📦 安装
|
|
24
24
|
|
|
25
|
+
### 稳定版本(推荐)
|
|
26
|
+
|
|
25
27
|
```bash
|
|
26
28
|
npm install expo-gaode-map
|
|
27
29
|
# 或
|
|
@@ -30,6 +32,32 @@ yarn add expo-gaode-map
|
|
|
30
32
|
pnpm add expo-gaode-map
|
|
31
33
|
```
|
|
32
34
|
|
|
35
|
+
### 体验 2.0 测试版本 🚀
|
|
36
|
+
|
|
37
|
+
> ⚠️ **重要提示**: 2.0 版本包含破坏性变更,API 调用方式有重大调整。详见 [迁移指南](docs/MIGRATION.md)
|
|
38
|
+
|
|
39
|
+
如果你想体验最新的 2.0 alpha 版本(包含改进的架构和更好的类型支持):
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install expo-gaode-map@next
|
|
43
|
+
# 或
|
|
44
|
+
yarn add expo-gaode-map@next
|
|
45
|
+
# 或
|
|
46
|
+
pnpm add expo-gaode-map@next
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**2.0 版本主要变化:**
|
|
50
|
+
- ✅ 统一的 API 调用方式(`ExpoGaodeMapModule`)
|
|
51
|
+
- ✅ 完整的 TypeScript 类型支持
|
|
52
|
+
- ✅ 移除了多余的封装层,直接调用原生模块
|
|
53
|
+
- ✅ 完全移除命令式 API的支持
|
|
54
|
+
- ✅ 添加未实现的一些新的 API(如:onCameraMove、onCameraIdle)
|
|
55
|
+
- ⚠️ **不向后兼容**,需要按照 [迁移指南](docs/MIGRATION.md) 更新代码
|
|
56
|
+
|
|
57
|
+
**版本对比:**
|
|
58
|
+
- `1.x`(稳定版):`import { initSDK, start, stop } from 'expo-gaode-map'`
|
|
59
|
+
- `2.0`(测试版):`import { ExpoGaodeMapModule } from 'expo-gaode-map'`
|
|
60
|
+
|
|
33
61
|
### Expo 项目
|
|
34
62
|
|
|
35
63
|
如果你使用的是 Expo 管理的项目(使用 `expo prebuild` 或开发构建),安装后需要重新构建原生代码:
|
|
@@ -87,10 +115,7 @@ npx react-native run-android
|
|
|
87
115
|
import { useEffect, useState } from 'react';
|
|
88
116
|
import {
|
|
89
117
|
MapView,
|
|
90
|
-
|
|
91
|
-
checkLocationPermission,
|
|
92
|
-
requestLocationPermission,
|
|
93
|
-
getCurrentLocation,
|
|
118
|
+
ExpoGaodeMapModule,
|
|
94
119
|
} from 'expo-gaode-map';
|
|
95
120
|
|
|
96
121
|
export default function App() {
|
|
@@ -99,20 +124,20 @@ export default function App() {
|
|
|
99
124
|
useEffect(() => {
|
|
100
125
|
const initialize = async () => {
|
|
101
126
|
// 1. 初始化 SDK
|
|
102
|
-
initSDK({
|
|
127
|
+
ExpoGaodeMapModule.initSDK({
|
|
103
128
|
androidKey: 'your-android-api-key',
|
|
104
129
|
iosKey: 'your-ios-api-key',
|
|
105
130
|
});
|
|
106
131
|
|
|
107
132
|
// 2. 检查并请求权限
|
|
108
|
-
const status = await checkLocationPermission();
|
|
133
|
+
const status = await ExpoGaodeMapModule.checkLocationPermission();
|
|
109
134
|
if (!status.granted) {
|
|
110
|
-
await requestLocationPermission();
|
|
135
|
+
await ExpoGaodeMapModule.requestLocationPermission();
|
|
111
136
|
}
|
|
112
137
|
|
|
113
138
|
// 3. 获取位置并设置地图
|
|
114
139
|
try {
|
|
115
|
-
const location = await getCurrentLocation();
|
|
140
|
+
const location = await ExpoGaodeMapModule.getCurrentLocation();
|
|
116
141
|
setInitialPosition({
|
|
117
142
|
target: { latitude: location.latitude, longitude: location.longitude },
|
|
118
143
|
zoom: 15
|
|
@@ -202,6 +227,7 @@ export default function MapScreen() {
|
|
|
202
227
|
- [使用示例](docs/EXAMPLES.md) - 详细的代码示例
|
|
203
228
|
- [初始化指南](docs/INITIALIZATION.md) - SDK 初始化和权限管理
|
|
204
229
|
- [架构文档](docs/ARCHITECTURE.md) - 项目结构和文件说明
|
|
230
|
+
- [迁移指南](docs/MIGRATION.md) - v1.x 到 v2.0 的迁移指南
|
|
205
231
|
|
|
206
232
|
## ⚠️ 注意事项
|
|
207
233
|
|
|
@@ -210,22 +236,23 @@ export default function MapScreen() {
|
|
|
210
236
|
```tsx
|
|
211
237
|
import React, { useRef, useEffect } from 'react';
|
|
212
238
|
import { View, StyleSheet, Button } from 'react-native';
|
|
213
|
-
import {
|
|
214
|
-
MapView,
|
|
215
|
-
|
|
239
|
+
import {
|
|
240
|
+
MapView,
|
|
241
|
+
ExpoGaodeMapModule,
|
|
216
242
|
Circle,
|
|
217
243
|
Marker,
|
|
218
244
|
Polyline,
|
|
219
245
|
Polygon,
|
|
220
|
-
type MapViewRef
|
|
246
|
+
type MapViewRef
|
|
221
247
|
} from 'expo-gaode-map';
|
|
222
248
|
|
|
223
249
|
export default function App() {
|
|
224
250
|
const mapRef = useRef<MapViewRef>(null);
|
|
225
251
|
|
|
226
252
|
useEffect(() => {
|
|
227
|
-
initSDK({
|
|
253
|
+
ExpoGaodeMapModule.initSDK({
|
|
228
254
|
androidKey: 'your-android-api-key',
|
|
255
|
+
iosKey: 'your-ios-api-key',
|
|
229
256
|
});
|
|
230
257
|
}, []);
|
|
231
258
|
|
|
@@ -322,16 +349,9 @@ const styles = StyleSheet.create({
|
|
|
322
349
|
```tsx
|
|
323
350
|
import React, { useEffect, useState } from 'react';
|
|
324
351
|
import { View, Text, Button, StyleSheet } from 'react-native';
|
|
325
|
-
import {
|
|
352
|
+
import {
|
|
326
353
|
MapView,
|
|
327
|
-
|
|
328
|
-
start,
|
|
329
|
-
stop,
|
|
330
|
-
getCurrentLocation,
|
|
331
|
-
addLocationListener,
|
|
332
|
-
setLocatingWithReGeocode,
|
|
333
|
-
setLocationMode,
|
|
334
|
-
setInterval,
|
|
354
|
+
ExpoGaodeMapModule,
|
|
335
355
|
type Location,
|
|
336
356
|
} from 'expo-gaode-map';
|
|
337
357
|
|
|
@@ -341,17 +361,18 @@ export default function LocationApp() {
|
|
|
341
361
|
|
|
342
362
|
useEffect(() => {
|
|
343
363
|
// 初始化 SDK
|
|
344
|
-
initSDK({
|
|
364
|
+
ExpoGaodeMapModule.initSDK({
|
|
345
365
|
androidKey: 'your-android-api-key',
|
|
366
|
+
iosKey: 'your-ios-api-key',
|
|
346
367
|
});
|
|
347
368
|
|
|
348
369
|
// 配置定位参数
|
|
349
|
-
setLocatingWithReGeocode(true); // 返回地址信息
|
|
350
|
-
setLocationMode(0); // 高精度模式
|
|
351
|
-
setInterval(2000); // 2秒更新一次
|
|
370
|
+
ExpoGaodeMapModule.setLocatingWithReGeocode(true); // 返回地址信息
|
|
371
|
+
ExpoGaodeMapModule.setLocationMode(0); // 高精度模式
|
|
372
|
+
ExpoGaodeMapModule.setInterval(2000); // 2秒更新一次
|
|
352
373
|
|
|
353
374
|
// 监听位置更新
|
|
354
|
-
const subscription =
|
|
375
|
+
const subscription = ExpoGaodeMapModule.addListener('onLocationUpdate', (loc) => {
|
|
355
376
|
console.log('位置更新:', loc);
|
|
356
377
|
setLocation(loc);
|
|
357
378
|
});
|
|
@@ -360,18 +381,18 @@ export default function LocationApp() {
|
|
|
360
381
|
}, []);
|
|
361
382
|
|
|
362
383
|
const handleStartTracking = () => {
|
|
363
|
-
start();
|
|
384
|
+
ExpoGaodeMapModule.start();
|
|
364
385
|
setIsTracking(true);
|
|
365
386
|
};
|
|
366
387
|
|
|
367
388
|
const handleStopTracking = () => {
|
|
368
|
-
stop();
|
|
389
|
+
ExpoGaodeMapModule.stop();
|
|
369
390
|
setIsTracking(false);
|
|
370
391
|
};
|
|
371
392
|
|
|
372
393
|
const handleGetLocation = async () => {
|
|
373
394
|
try {
|
|
374
|
-
const loc = await getCurrentLocation();
|
|
395
|
+
const loc = await ExpoGaodeMapModule.getCurrentLocation();
|
|
375
396
|
setLocation(loc);
|
|
376
397
|
} catch (error) {
|
|
377
398
|
console.error('获取位置失败:', error);
|
|
@@ -493,40 +514,6 @@ const styles = StyleSheet.create({
|
|
|
493
514
|
|
|
494
515
|
详细说明请参考:[docs/followUserLocation.md](docs/followUserLocation.md)
|
|
495
516
|
|
|
496
|
-
### 命令式 API 批量操作
|
|
497
|
-
|
|
498
|
-
```tsx
|
|
499
|
-
const mapRef = useRef<MapViewRef>(null);
|
|
500
|
-
|
|
501
|
-
// 批量添加覆盖物
|
|
502
|
-
const addMultipleOverlays = async () => {
|
|
503
|
-
// 添加多个圆形
|
|
504
|
-
await mapRef.current?.addCircle('circle1', {
|
|
505
|
-
center: { latitude: 39.9, longitude: 116.4 },
|
|
506
|
-
radius: 1000,
|
|
507
|
-
fillColor: 0x8800FF00,
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
await mapRef.current?.addCircle('circle2', {
|
|
511
|
-
center: { latitude: 40.0, longitude: 116.5 },
|
|
512
|
-
radius: 500,
|
|
513
|
-
fillColor: 0x880000FF,
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
// 添加标记
|
|
517
|
-
await mapRef.current?.addMarker('marker1', {
|
|
518
|
-
position: { latitude: 39.95, longitude: 116.45 },
|
|
519
|
-
title: '北京',
|
|
520
|
-
});
|
|
521
|
-
};
|
|
522
|
-
|
|
523
|
-
// 批量清除
|
|
524
|
-
const clearAll = async () => {
|
|
525
|
-
await mapRef.current?.removeCircle('circle1');
|
|
526
|
-
await mapRef.current?.removeCircle('circle2');
|
|
527
|
-
await mapRef.current?.removeMarker('marker1');
|
|
528
|
-
};
|
|
529
|
-
```
|
|
530
517
|
|
|
531
518
|
|
|
532
519
|
### 颜色格式
|
|
@@ -537,12 +524,6 @@ const clearAll = async () => {
|
|
|
537
524
|
```tsx
|
|
538
525
|
<Circle fillColor="#8800FF00" /> // 50% 透明绿色
|
|
539
526
|
```
|
|
540
|
-
|
|
541
|
-
2. **数字格式**(命令式 API):`0xAARRGGBB`
|
|
542
|
-
```tsx
|
|
543
|
-
await mapRef.current?.addCircle('circle1', {
|
|
544
|
-
fillColor: 0x8800FF00, // 50% 透明绿色
|
|
545
|
-
});
|
|
546
527
|
```
|
|
547
528
|
|
|
548
529
|
### 性能优化
|