expo-gaode-map 2.0.0-alpha.7 → 2.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/README.en.md +1 -25
- package/README.md +26 -456
- package/RELEASE_v2.0.0.md +59 -0
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -32,29 +32,6 @@ yarn add expo-gaode-map
|
|
|
32
32
|
pnpm add expo-gaode-map
|
|
33
33
|
```
|
|
34
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
35
|
|
|
59
36
|
### Expo Projects
|
|
60
37
|
|
|
@@ -224,8 +201,7 @@ Includes:
|
|
|
224
201
|
- [API Documentation](docs/API.en.md) - Complete API reference
|
|
225
202
|
- [Usage Examples](docs/EXAMPLES.en.md) - Detailed code examples
|
|
226
203
|
- [Initialization Guide](docs/INITIALIZATION.en.md) - SDK initialization and permission management
|
|
227
|
-
- [Architecture Documentation](docs/ARCHITECTURE.en.md) - Project structure and file
|
|
228
|
-
- [Migration Guide](docs/MIGRATION.md) - Migration guide from v1.x to v2.0
|
|
204
|
+
- [Architecture Documentation](docs/ARCHITECTURE.en.md) - Project structure and file
|
|
229
205
|
|
|
230
206
|
## 🎨 Advanced Usage
|
|
231
207
|
|
package/README.md
CHANGED
|
@@ -2,22 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
[English](./README.en.md) | 简体中文
|
|
4
4
|
|
|
5
|
-
一个功能完整的高德地图 React Native 组件库,**基于 Expo Modules
|
|
6
|
-
- Android: [高德地图 Android SDK](https://lbs.amap.com/api/android-sdk/summary)
|
|
7
|
-
- iOS: [高德地图 iOS SDK](https://lbs.amap.com/api/ios-sdk/summary)
|
|
5
|
+
一个功能完整的高德地图 React Native 组件库,**基于 Expo Modules 开发**,提供地图显示、定位、覆盖物等功能。
|
|
8
6
|
|
|
9
7
|
> 💡 本组件使用 [Expo Modules API](https://docs.expo.dev/modules/overview/) 构建,提供了类型安全的原生模块接口和优秀的开发体验。
|
|
10
8
|
|
|
11
|
-
##
|
|
9
|
+
## 📖 完整文档
|
|
10
|
+
|
|
11
|
+
**👉 [在线文档网站](https://TomWq.github.io/expo-gaode-map/)** - 包含完整的 API 文档、使用指南和示例代码
|
|
12
|
+
|
|
13
|
+
## ✨ 主要特性
|
|
12
14
|
|
|
13
15
|
- ✅ 完整的地图功能(多种地图类型、手势控制、相机操作)
|
|
14
16
|
- ✅ 精准定位(连续定位、单次定位、坐标转换)
|
|
15
|
-
- ✅ 丰富的覆盖物(Circle、Marker、Polyline、Polygon
|
|
16
|
-
- ✅ 完整的 TypeScript
|
|
17
|
-
- ✅ 模块化架构设计
|
|
18
|
-
- ✅ 同时支持声明式组件和命令式 API(注意:命令式 API 将在未来的版本删除,建议使用声明式组件)
|
|
17
|
+
- ✅ 丰富的覆盖物(Circle、Marker、Polyline、Polygon、HeatMap、Cluster 等)
|
|
18
|
+
- ✅ 完整的 TypeScript 类型定义
|
|
19
19
|
- ✅ 跨平台支持(Android、iOS)
|
|
20
|
-
- ✅ 支持自定义样式和事件监听
|
|
21
20
|
- ✅ 同时支持 React Native 新旧架构(Paper & Fabric)
|
|
22
21
|
|
|
23
22
|
## 📦 安装
|
|
@@ -32,91 +31,21 @@ yarn add expo-gaode-map
|
|
|
32
31
|
pnpm add expo-gaode-map
|
|
33
32
|
```
|
|
34
33
|
|
|
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
|
-
|
|
61
|
-
### Expo 项目
|
|
62
|
-
|
|
63
|
-
如果你使用的是 Expo 管理的项目(使用 `expo prebuild` 或开发构建),安装后需要重新构建原生代码:
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
# 使用 EAS Build
|
|
67
|
-
eas build --platform android
|
|
68
|
-
|
|
69
|
-
# 或使用本地构建
|
|
70
|
-
npx expo prebuild
|
|
71
|
-
npx expo run:android
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### 纯 React Native 项目
|
|
75
|
-
|
|
76
|
-
对于纯 React Native 项目(通过 `react-native init` 创建),确保已安装 `expo` 包作为依赖:
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
npm install expo
|
|
80
|
-
# 然后重新构建应用
|
|
81
|
-
npx react-native run-android
|
|
82
|
-
```
|
|
83
|
-
|
|
84
34
|
## 🚀 快速开始
|
|
85
35
|
|
|
86
36
|
### 1. 获取高德地图 API Key
|
|
87
37
|
|
|
88
38
|
前往 [高德开放平台](https://lbs.amap.com/) 注册并创建应用,获取 API Key。
|
|
89
39
|
|
|
90
|
-
> ⚠️
|
|
91
|
-
>
|
|
92
|
-
>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
> 1. 在 `AndroidManifest.xml` 中配置 API Key
|
|
96
|
-
> 2. 添加必需权限(网络、定位等)
|
|
97
|
-
> 3. 配置隐私合规(必需)
|
|
98
|
-
>
|
|
99
|
-
> **iOS 必需配置:**
|
|
100
|
-
> 1. 在 `Info.plist` 中配置 API Key
|
|
101
|
-
> 2. 添加定位权限描述(NSLocationWhenInUseUsageDescription 等)
|
|
102
|
-
> 3. 配置隐私合规(必需)
|
|
103
|
-
>
|
|
104
|
-
> **详细配置指南:**
|
|
105
|
-
> - **Android**: [高德地图 Android SDK 配置指南](https://lbs.amap.com/api/android-sdk/guide/create-project/android-studio-create-project)
|
|
106
|
-
> - **iOS**: [高德地图 iOS SDK 配置指南](https://lbs.amap.com/api/ios-sdk/guide/create-project/cocoapods)
|
|
107
|
-
>
|
|
108
|
-
> 对于 Expo 项目,使用 `npx expo prebuild` 生成原生代码后进行配置。
|
|
109
|
-
|
|
110
|
-
### 2. 初始化和权限管理
|
|
111
|
-
|
|
112
|
-
**推荐的初始化流程**:
|
|
40
|
+
> ⚠️ **重要提示**: 高德地图 SDK 需要在原生项目中进行配置(API Key、权限、隐私合规等)
|
|
41
|
+
>
|
|
42
|
+
> 详细配置请查看:[初始化指南](https://TomWq.github.io/expo-gaode-map/guide/initialization.html)
|
|
43
|
+
|
|
44
|
+
### 2. 基础使用
|
|
113
45
|
|
|
114
46
|
```tsx
|
|
115
47
|
import { useEffect, useState } from 'react';
|
|
116
|
-
import {
|
|
117
|
-
MapView,
|
|
118
|
-
ExpoGaodeMapModule,
|
|
119
|
-
} from 'expo-gaode-map';
|
|
48
|
+
import { MapView, ExpoGaodeMapModule } from 'expo-gaode-map';
|
|
120
49
|
|
|
121
50
|
export default function App() {
|
|
122
51
|
const [initialPosition, setInitialPosition] = useState(null);
|
|
@@ -166,372 +95,13 @@ export default function App() {
|
|
|
166
95
|
}
|
|
167
96
|
```
|
|
168
97
|
|
|
169
|
-
|
|
170
|
-
>
|
|
171
|
-
> 包含完整的权限处理、错误处理和最佳实践。
|
|
172
|
-
|
|
173
|
-
### 3. 基础地图使用
|
|
174
|
-
|
|
175
|
-
```tsx
|
|
176
|
-
import { MapView } from 'expo-gaode-map';
|
|
177
|
-
|
|
178
|
-
export default function MapScreen() {
|
|
179
|
-
return (
|
|
180
|
-
<MapView
|
|
181
|
-
style={{ flex: 1 }}
|
|
182
|
-
initialCameraPosition={{
|
|
183
|
-
target: { latitude: 39.9, longitude: 116.4 },
|
|
184
|
-
zoom: 10,
|
|
185
|
-
}}
|
|
186
|
-
myLocationEnabled={true}
|
|
187
|
-
onLoad={() => console.log('地图加载完成')}
|
|
188
|
-
/>
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
## 📚 功能概览
|
|
194
|
-
|
|
195
|
-
### 🗺️ 地图显示
|
|
196
|
-
- 多种地图类型(标准、卫星、夜间等)
|
|
197
|
-
- 相机控制(移动、缩放、旋转、倾斜)
|
|
198
|
-
- 手势控制和 UI 控件配置
|
|
199
|
-
- 缩放级别限制
|
|
200
|
-
|
|
201
|
-
### 📍 定位功能
|
|
202
|
-
- 连续定位和单次定位
|
|
203
|
-
- 逆地理编码(地址解析)
|
|
204
|
-
- 定位配置(精度、间隔、模式等)
|
|
205
|
-
- 自定义定位蓝点样式
|
|
206
|
-
|
|
207
|
-
### 🎨 覆盖物
|
|
208
|
-
- Circle(圆形)
|
|
209
|
-
- Marker(标记点)
|
|
210
|
-
- Polyline(折线)
|
|
211
|
-
- Polygon(多边形)
|
|
212
|
-
- 支持声明式和命令式两种使用方式
|
|
213
|
-
|
|
214
|
-
### 📝 更多示例
|
|
215
|
-
|
|
216
|
-
详细的使用示例请查看:[EXAMPLES.md](docs/EXAMPLES.md)
|
|
217
|
-
|
|
218
|
-
包含:
|
|
219
|
-
- 基础地图应用
|
|
220
|
-
- 定位追踪应用
|
|
221
|
-
- 覆盖物操作示例
|
|
222
|
-
- 高级用法和最佳实践
|
|
223
|
-
|
|
224
|
-
## 📝 文档
|
|
225
|
-
|
|
226
|
-
- [API 文档](docs/API.md) - 完整的 API 参考
|
|
227
|
-
- [使用示例](docs/EXAMPLES.md) - 详细的代码示例
|
|
228
|
-
- [初始化指南](docs/INITIALIZATION.md) - SDK 初始化和权限管理
|
|
229
|
-
- [架构文档](docs/ARCHITECTURE.md) - 项目结构和文件说明
|
|
230
|
-
- [迁移指南](docs/MIGRATION.md) - v1.x 到 v2.0 的迁移指南
|
|
231
|
-
|
|
232
|
-
## ⚠️ 注意事项
|
|
233
|
-
|
|
234
|
-
### 基础地图应用
|
|
235
|
-
|
|
236
|
-
```tsx
|
|
237
|
-
import React, { useRef, useEffect } from 'react';
|
|
238
|
-
import { View, StyleSheet, Button } from 'react-native';
|
|
239
|
-
import {
|
|
240
|
-
MapView,
|
|
241
|
-
ExpoGaodeMapModule,
|
|
242
|
-
Circle,
|
|
243
|
-
Marker,
|
|
244
|
-
Polyline,
|
|
245
|
-
Polygon,
|
|
246
|
-
type MapViewRef
|
|
247
|
-
} from 'expo-gaode-map';
|
|
248
|
-
|
|
249
|
-
export default function App() {
|
|
250
|
-
const mapRef = useRef<MapViewRef>(null);
|
|
251
|
-
|
|
252
|
-
useEffect(() => {
|
|
253
|
-
ExpoGaodeMapModule.initSDK({
|
|
254
|
-
androidKey: 'your-android-api-key',
|
|
255
|
-
iosKey: 'your-ios-api-key',
|
|
256
|
-
});
|
|
257
|
-
}, []);
|
|
258
|
-
|
|
259
|
-
const handleMoveCamera = async () => {
|
|
260
|
-
await mapRef.current?.moveCamera(
|
|
261
|
-
{
|
|
262
|
-
target: { latitude: 40.0, longitude: 116.5 },
|
|
263
|
-
zoom: 15,
|
|
264
|
-
},
|
|
265
|
-
1000
|
|
266
|
-
);
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
return (
|
|
270
|
-
<View style={styles.container}>
|
|
271
|
-
<MapView
|
|
272
|
-
ref={mapRef}
|
|
273
|
-
style={styles.map}
|
|
274
|
-
initialCameraPosition={{
|
|
275
|
-
target: { latitude: 39.9, longitude: 116.4 },
|
|
276
|
-
zoom: 10,
|
|
277
|
-
}}
|
|
278
|
-
myLocationEnabled={true}
|
|
279
|
-
followUserLocation={false}
|
|
280
|
-
trafficEnabled={true}
|
|
281
|
-
onPress={(e) => console.log('点击地图', e)}
|
|
282
|
-
onLoad={() => console.log('地图加载完成')}
|
|
283
|
-
>
|
|
284
|
-
{/* 圆形覆盖物 */}
|
|
285
|
-
<Circle
|
|
286
|
-
center={{ latitude: 39.9, longitude: 116.4 }}
|
|
287
|
-
radius={1000}
|
|
288
|
-
fillColor="#8800FF00"
|
|
289
|
-
strokeColor="#FFFF0000"
|
|
290
|
-
strokeWidth={2}
|
|
291
|
-
/>
|
|
292
|
-
|
|
293
|
-
{/* 标记点 */}
|
|
294
|
-
<Marker
|
|
295
|
-
position={{ latitude: 39.95, longitude: 116.45 }}
|
|
296
|
-
title="这是一个标记"
|
|
297
|
-
draggable={true}
|
|
298
|
-
/>
|
|
299
|
-
|
|
300
|
-
{/* 折线 */}
|
|
301
|
-
<Polyline
|
|
302
|
-
points={[
|
|
303
|
-
{ latitude: 39.9, longitude: 116.4 },
|
|
304
|
-
{ latitude: 39.95, longitude: 116.45 },
|
|
305
|
-
{ latitude: 40.0, longitude: 116.5 },
|
|
306
|
-
]}
|
|
307
|
-
strokeWidth={5}
|
|
308
|
-
strokeColor="#FF0000FF"
|
|
309
|
-
/>
|
|
310
|
-
|
|
311
|
-
{/* 多边形 */}
|
|
312
|
-
<Polygon
|
|
313
|
-
points={[
|
|
314
|
-
{ latitude: 39.85, longitude: 116.35 },
|
|
315
|
-
{ latitude: 39.85, longitude: 116.45 },
|
|
316
|
-
{ latitude: 39.75, longitude: 116.40 },
|
|
317
|
-
]}
|
|
318
|
-
fillColor="#880000FF"
|
|
319
|
-
strokeColor="#FFFF0000"
|
|
320
|
-
strokeWidth={2}
|
|
321
|
-
/>
|
|
322
|
-
</MapView>
|
|
323
|
-
|
|
324
|
-
<View style={styles.controls}>
|
|
325
|
-
<Button title="移动相机" onPress={handleMoveCamera} />
|
|
326
|
-
</View>
|
|
327
|
-
</View>
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
const styles = StyleSheet.create({
|
|
332
|
-
container: {
|
|
333
|
-
flex: 1,
|
|
334
|
-
},
|
|
335
|
-
map: {
|
|
336
|
-
flex: 1,
|
|
337
|
-
},
|
|
338
|
-
controls: {
|
|
339
|
-
position: 'absolute',
|
|
340
|
-
bottom: 20,
|
|
341
|
-
left: 20,
|
|
342
|
-
right: 20,
|
|
343
|
-
},
|
|
344
|
-
});
|
|
345
|
-
```
|
|
346
|
-
|
|
347
|
-
### 定位追踪应用
|
|
348
|
-
|
|
349
|
-
```tsx
|
|
350
|
-
import React, { useEffect, useState } from 'react';
|
|
351
|
-
import { View, Text, Button, StyleSheet } from 'react-native';
|
|
352
|
-
import {
|
|
353
|
-
MapView,
|
|
354
|
-
ExpoGaodeMapModule,
|
|
355
|
-
type Location,
|
|
356
|
-
} from 'expo-gaode-map';
|
|
357
|
-
|
|
358
|
-
export default function LocationApp() {
|
|
359
|
-
const [location, setLocation] = useState<Location | null>(null);
|
|
360
|
-
const [isTracking, setIsTracking] = useState(false);
|
|
361
|
-
|
|
362
|
-
useEffect(() => {
|
|
363
|
-
// 初始化 SDK
|
|
364
|
-
ExpoGaodeMapModule.initSDK({
|
|
365
|
-
androidKey: 'your-android-api-key',
|
|
366
|
-
iosKey: 'your-ios-api-key',
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
// 配置定位参数
|
|
370
|
-
ExpoGaodeMapModule.setLocatingWithReGeocode(true); // 返回地址信息
|
|
371
|
-
ExpoGaodeMapModule.setLocationMode(0); // 高精度模式
|
|
372
|
-
ExpoGaodeMapModule.setInterval(2000); // 2秒更新一次
|
|
373
|
-
|
|
374
|
-
// 监听位置更新
|
|
375
|
-
const subscription = ExpoGaodeMapModule.addLocationListener('onLocationUpdate', (loc) => {
|
|
376
|
-
console.log('位置更新:', loc);
|
|
377
|
-
setLocation(loc);
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
return () => subscription.remove();
|
|
381
|
-
}, []);
|
|
382
|
-
|
|
383
|
-
const handleStartTracking = () => {
|
|
384
|
-
ExpoGaodeMapModule.start();
|
|
385
|
-
setIsTracking(true);
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
const handleStopTracking = () => {
|
|
389
|
-
ExpoGaodeMapModule.stop();
|
|
390
|
-
setIsTracking(false);
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
const handleGetLocation = async () => {
|
|
394
|
-
try {
|
|
395
|
-
const loc = await ExpoGaodeMapModule.getCurrentLocation();
|
|
396
|
-
setLocation(loc);
|
|
397
|
-
} catch (error) {
|
|
398
|
-
console.error('获取位置失败:', error);
|
|
399
|
-
}
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
return (
|
|
403
|
-
<View style={styles.container}>
|
|
404
|
-
<MapView
|
|
405
|
-
style={styles.map}
|
|
406
|
-
myLocationEnabled={true}
|
|
407
|
-
followUserLocation={isTracking}
|
|
408
|
-
initialCameraPosition={{
|
|
409
|
-
target: {
|
|
410
|
-
latitude: location?.latitude || 39.9,
|
|
411
|
-
longitude: location?.longitude || 116.4
|
|
412
|
-
},
|
|
413
|
-
zoom: 15,
|
|
414
|
-
}}
|
|
415
|
-
/>
|
|
416
|
-
|
|
417
|
-
{location && (
|
|
418
|
-
<View style={styles.info}>
|
|
419
|
-
<Text style={styles.infoText}>
|
|
420
|
-
纬度: {location.latitude.toFixed(6)}
|
|
421
|
-
</Text>
|
|
422
|
-
<Text style={styles.infoText}>
|
|
423
|
-
经度: {location.longitude.toFixed(6)}
|
|
424
|
-
</Text>
|
|
425
|
-
<Text style={styles.infoText}>
|
|
426
|
-
精度: {location.accuracy.toFixed(2)} 米
|
|
427
|
-
</Text>
|
|
428
|
-
{location.address && (
|
|
429
|
-
<Text style={styles.infoText}>
|
|
430
|
-
地址: {location.address}
|
|
431
|
-
</Text>
|
|
432
|
-
)}
|
|
433
|
-
</View>
|
|
434
|
-
)}
|
|
435
|
-
|
|
436
|
-
<View style={styles.controls}>
|
|
437
|
-
<Button
|
|
438
|
-
title="获取位置"
|
|
439
|
-
onPress={handleGetLocation}
|
|
440
|
-
/>
|
|
441
|
-
<View style={{ height: 10 }} />
|
|
442
|
-
<Button
|
|
443
|
-
title={isTracking ? '停止追踪' : '开始追踪'}
|
|
444
|
-
onPress={isTracking ? handleStopTracking : handleStartTracking}
|
|
445
|
-
color={isTracking ? '#FF3B30' : '#007AFF'}
|
|
446
|
-
/>
|
|
447
|
-
</View>
|
|
448
|
-
</View>
|
|
449
|
-
);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
const styles = StyleSheet.create({
|
|
453
|
-
container: {
|
|
454
|
-
flex: 1,
|
|
455
|
-
},
|
|
456
|
-
map: {
|
|
457
|
-
flex: 1,
|
|
458
|
-
},
|
|
459
|
-
info: {
|
|
460
|
-
position: 'absolute',
|
|
461
|
-
top: 50,
|
|
462
|
-
left: 20,
|
|
463
|
-
right: 20,
|
|
464
|
-
backgroundColor: 'white',
|
|
465
|
-
padding: 15,
|
|
466
|
-
borderRadius: 10,
|
|
467
|
-
shadowColor: '#000',
|
|
468
|
-
shadowOffset: { width: 0, height: 2 },
|
|
469
|
-
shadowOpacity: 0.25,
|
|
470
|
-
shadowRadius: 3.84,
|
|
471
|
-
elevation: 5,
|
|
472
|
-
},
|
|
473
|
-
infoText: {
|
|
474
|
-
fontSize: 14,
|
|
475
|
-
marginBottom: 5,
|
|
476
|
-
color: '#333',
|
|
477
|
-
},
|
|
478
|
-
controls: {
|
|
479
|
-
position: 'absolute',
|
|
480
|
-
bottom: 30,
|
|
481
|
-
left: 20,
|
|
482
|
-
right: 20,
|
|
483
|
-
},
|
|
484
|
-
});
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
## 🎨 高级用法
|
|
488
|
-
|
|
489
|
-
### followUserLocation 详解
|
|
490
|
-
|
|
491
|
-
`followUserLocation` 控制地图是否自动跟随用户位置移动:
|
|
492
|
-
|
|
493
|
-
**浏览模式(默认 - `false`):**
|
|
494
|
-
```tsx
|
|
495
|
-
<MapView
|
|
496
|
-
myLocationEnabled={true}
|
|
497
|
-
followUserLocation={false} // 或省略
|
|
498
|
-
/>
|
|
499
|
-
```
|
|
500
|
-
- ✅ 显示定位点
|
|
501
|
-
- ✅ 用户可自由滑动地图
|
|
502
|
-
- ✅ 地图不会自动移动
|
|
503
|
-
|
|
504
|
-
**导航模式(`true`):**
|
|
505
|
-
```tsx
|
|
506
|
-
<MapView
|
|
507
|
-
myLocationEnabled={true}
|
|
508
|
-
followUserLocation={true}
|
|
509
|
-
/>
|
|
510
|
-
```
|
|
511
|
-
- ✅ 显示定位点
|
|
512
|
-
- ✅ 地图自动跟随用户移动
|
|
513
|
-
- ⚠️ 适合导航场景
|
|
514
|
-
|
|
515
|
-
详细说明请参考:[docs/followUserLocation.md](docs/followUserLocation.md)
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
### 颜色格式
|
|
520
|
-
|
|
521
|
-
覆盖物颜色支持两种格式:
|
|
522
|
-
|
|
523
|
-
1. **字符串格式**(ARGB):`"#AARRGGBB"`
|
|
524
|
-
```tsx
|
|
525
|
-
<Circle fillColor="#8800FF00" /> // 50% 透明绿色
|
|
526
|
-
```
|
|
527
|
-
```
|
|
528
|
-
|
|
529
|
-
### 性能优化
|
|
98
|
+
## 📚 文档导航
|
|
530
99
|
|
|
531
|
-
-
|
|
532
|
-
-
|
|
533
|
-
-
|
|
534
|
-
-
|
|
100
|
+
- [快速开始](https://TomWq.github.io/expo-gaode-map/guide/getting-started.html) - 快速上手指南
|
|
101
|
+
- [初始化指南](https://TomWq.github.io/expo-gaode-map/guide/initialization.html) - SDK 初始化和权限配置
|
|
102
|
+
- [API 文档](https://TomWq.github.io/expo-gaode-map/api/) - 完整的 API 参考
|
|
103
|
+
- [使用示例](https://TomWq.github.io/expo-gaode-map/examples/) - 详细的代码示例
|
|
104
|
+
- [架构文档](https://TomWq.github.io/expo-gaode-map/guide/architecture.html) - 项目结构说明
|
|
535
105
|
|
|
536
106
|
## 🤝 贡献
|
|
537
107
|
|
|
@@ -543,18 +113,18 @@ MIT
|
|
|
543
113
|
|
|
544
114
|
## 🔗 相关链接
|
|
545
115
|
|
|
116
|
+
- [在线文档](https://TomWq.github.io/expo-gaode-map/)
|
|
117
|
+
- [GitHub 仓库](https://github.com/TomWq/expo-gaode-map)
|
|
546
118
|
- [高德地图开放平台](https://lbs.amap.com/)
|
|
547
|
-
- [高德地图 Android SDK](https://lbs.amap.com/api/android-sdk/summary)
|
|
548
119
|
- [Expo Modules API](https://docs.expo.dev/modules/overview/)
|
|
549
|
-
- [GitHub 仓库](https://github.com/yourusername/expo-gaode-map)
|
|
550
120
|
|
|
551
121
|
## 🙏 致谢
|
|
552
122
|
|
|
553
|
-
|
|
123
|
+
本项目在开发过程中参考了以下优秀项目:
|
|
554
124
|
|
|
555
|
-
- **[react-native-amap3d](https://github.com/qiuxiang/react-native-amap3d)** - 一个优秀的 React Native
|
|
125
|
+
- **[react-native-amap3d](https://github.com/qiuxiang/react-native-amap3d)** - 一个优秀的 React Native 高德地图组件
|
|
556
126
|
|
|
557
|
-
|
|
127
|
+
感谢这些开源项目的贡献者们!
|
|
558
128
|
|
|
559
129
|
## 📮 反馈与支持
|
|
560
130
|
|
|
@@ -563,4 +133,4 @@ MIT
|
|
|
563
133
|
- 📝 提交 [GitHub Issue](https://github.com/TomWq/expo-gaode-map/issues)
|
|
564
134
|
- 💬 参与 [Discussions](https://github.com/TomWq/expo-gaode-map/discussions)
|
|
565
135
|
- ⭐ 给项目点个 Star 支持一下
|
|
566
|
-
- 💬 加入 QQ 群:952241387
|
|
136
|
+
- 💬 加入 QQ 群:952241387
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
## 🎉 v2.0.0 正式版发布
|
|
2
|
+
|
|
3
|
+
一个功能完整的高德地图 React Native 组件库,基于 Expo Modules 开发。
|
|
4
|
+
|
|
5
|
+
## ✨ 核心特性
|
|
6
|
+
|
|
7
|
+
- 🗺️ **完整的地图功能** - 多种地图类型、相机控制、手势配置
|
|
8
|
+
- 📍 **精准定位服务** - 连续定位、单次定位、逆地理编码
|
|
9
|
+
- 🎨 **丰富的覆盖物** - Marker、Circle、Polyline、Polygon、HeatMap、Cluster
|
|
10
|
+
- 💎 **完整 TypeScript 支持** - 零 any 类型,完美的类型推导
|
|
11
|
+
- 🚀 **基于 Expo Modules** - 现代化的原生模块开发体验
|
|
12
|
+
- 📱 **跨平台支持** - 同时支持 Android 和 iOS
|
|
13
|
+
- 🔄 **新旧架构兼容** - 支持 React Native Paper & Fabric
|
|
14
|
+
|
|
15
|
+
## 📦 安装
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install expo-gaode-map
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 🚀 快速开始
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { MapView, ExpoGaodeMapModule } from 'expo-gaode-map';
|
|
25
|
+
|
|
26
|
+
// 初始化
|
|
27
|
+
ExpoGaodeMapModule.initSDK({
|
|
28
|
+
androidKey: 'your-android-key',
|
|
29
|
+
iosKey: 'your-ios-key',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// 使用地图
|
|
33
|
+
<MapView
|
|
34
|
+
style={{ flex: 1 }}
|
|
35
|
+
myLocationEnabled={true}
|
|
36
|
+
/>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 📖 完整文档
|
|
40
|
+
|
|
41
|
+
**👉 [在线文档](https://TomWq.github.io/expo-gaode-map/)**
|
|
42
|
+
|
|
43
|
+
- [快速开始](https://TomWq.github.io/expo-gaode-map/guide/getting-started.html)
|
|
44
|
+
- [API 文档](https://TomWq.github.io/expo-gaode-map/api/)
|
|
45
|
+
- [使用示例](https://TomWq.github.io/expo-gaode-map/examples/)
|
|
46
|
+
|
|
47
|
+
## 🔄 从 v1.x 升级
|
|
48
|
+
|
|
49
|
+
查看 [迁移指南](https://github.com/TomWq/expo-gaode-map/blob/main/docs/MIGRATION.md)
|
|
50
|
+
|
|
51
|
+
## 📮 反馈与支持
|
|
52
|
+
|
|
53
|
+
- 📝 [提交 Issue](https://github.com/TomWq/expo-gaode-map/issues)
|
|
54
|
+
- 💬 [参与讨论](https://github.com/TomWq/expo-gaode-map/discussions)
|
|
55
|
+
- 💬 QQ 群:952241387
|
|
56
|
+
|
|
57
|
+
## 📄 许可证
|
|
58
|
+
|
|
59
|
+
MIT License
|