expo-gaode-map 1.1.7 → 2.0.0-alpha.1

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.
Files changed (121) hide show
  1. package/README.en.md +32 -46
  2. package/README.md +51 -71
  3. package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapView.kt +37 -237
  4. package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapViewModule.kt +1 -49
  5. package/android/src/main/java/expo/modules/gaodemap/managers/CameraManager.kt +30 -7
  6. package/android/src/main/java/expo/modules/gaodemap/managers/UIManager.kt +1 -0
  7. package/android/src/main/java/expo/modules/gaodemap/modules/LocationManager.kt +10 -1
  8. package/android/src/main/java/expo/modules/gaodemap/overlays/CircleView.kt +38 -14
  9. package/android/src/main/java/expo/modules/gaodemap/overlays/CircleViewModule.kt +3 -3
  10. package/android/src/main/java/expo/modules/gaodemap/overlays/ClusterView.kt +8 -1
  11. package/android/src/main/java/expo/modules/gaodemap/overlays/HeatMapView.kt +4 -1
  12. package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerView.kt +322 -93
  13. package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerViewModule.kt +11 -3
  14. package/android/src/main/java/expo/modules/gaodemap/overlays/MultiPointView.kt +4 -1
  15. package/android/src/main/java/expo/modules/gaodemap/overlays/PolygonView.kt +25 -11
  16. package/android/src/main/java/expo/modules/gaodemap/overlays/PolygonViewModule.kt +3 -3
  17. package/android/src/main/java/expo/modules/gaodemap/overlays/PolylineView.kt +20 -10
  18. package/android/src/main/java/expo/modules/gaodemap/overlays/PolylineViewModule.kt +6 -2
  19. package/build/ExpoGaodeMap.types.d.ts +27 -6
  20. package/build/ExpoGaodeMap.types.d.ts.map +1 -1
  21. package/build/ExpoGaodeMap.types.js +3 -0
  22. package/build/ExpoGaodeMap.types.js.map +1 -1
  23. package/build/ExpoGaodeMapModule.d.ts +157 -10
  24. package/build/ExpoGaodeMapModule.d.ts.map +1 -1
  25. package/build/ExpoGaodeMapModule.js +4 -0
  26. package/build/ExpoGaodeMapModule.js.map +1 -1
  27. package/build/ExpoGaodeMapView.d.ts +1 -17
  28. package/build/ExpoGaodeMapView.d.ts.map +1 -1
  29. package/build/ExpoGaodeMapView.js +4 -209
  30. package/build/ExpoGaodeMapView.js.map +1 -1
  31. package/build/components/overlays/Circle.d.ts +10 -1
  32. package/build/components/overlays/Circle.d.ts.map +1 -1
  33. package/build/components/overlays/Circle.js +11 -86
  34. package/build/components/overlays/Circle.js.map +1 -1
  35. package/build/components/overlays/Cluster.d.ts.map +1 -1
  36. package/build/components/overlays/Cluster.js.map +1 -1
  37. package/build/components/overlays/Marker.d.ts +13 -1
  38. package/build/components/overlays/Marker.d.ts.map +1 -1
  39. package/build/components/overlays/Marker.js +51 -115
  40. package/build/components/overlays/Marker.js.map +1 -1
  41. package/build/components/overlays/Polygon.d.ts +7 -15
  42. package/build/components/overlays/Polygon.d.ts.map +1 -1
  43. package/build/components/overlays/Polygon.js +10 -80
  44. package/build/components/overlays/Polygon.js.map +1 -1
  45. package/build/components/overlays/Polyline.d.ts +7 -14
  46. package/build/components/overlays/Polyline.d.ts.map +1 -1
  47. package/build/components/overlays/Polyline.js +9 -66
  48. package/build/components/overlays/Polyline.js.map +1 -1
  49. package/build/index.d.ts +1 -4
  50. package/build/index.d.ts.map +1 -1
  51. package/build/index.js +2 -10
  52. package/build/index.js.map +1 -1
  53. package/build/types/index.d.ts +1 -1
  54. package/build/types/index.d.ts.map +1 -1
  55. package/build/types/index.js.map +1 -1
  56. package/build/types/map-view.types.d.ts +0 -76
  57. package/build/types/map-view.types.d.ts.map +1 -1
  58. package/build/types/map-view.types.js.map +1 -1
  59. package/build/types/overlays.types.d.ts +11 -16
  60. package/build/types/overlays.types.d.ts.map +1 -1
  61. package/build/types/overlays.types.js.map +1 -1
  62. package/docs/API.en.md +1 -21
  63. package/docs/API.md +84 -56
  64. package/docs/EXAMPLES.en.md +0 -48
  65. package/docs/EXAMPLES.md +49 -102
  66. package/docs/INITIALIZATION.md +59 -71
  67. package/docs/MIGRATION.md +423 -0
  68. package/ios/ExpoGaodeMapView.swift +317 -258
  69. package/ios/ExpoGaodeMapViewModule.swift +3 -50
  70. package/ios/managers/CameraManager.swift +23 -2
  71. package/ios/managers/UIManager.swift +10 -5
  72. package/ios/modules/LocationManager.swift +10 -0
  73. package/ios/overlays/CircleView.swift +98 -19
  74. package/ios/overlays/CircleViewModule.swift +21 -0
  75. package/ios/overlays/ClusterView.swift +33 -4
  76. package/ios/overlays/HeatMapView.swift +16 -4
  77. package/ios/overlays/MarkerView.swift +235 -146
  78. package/ios/overlays/MarkerViewModule.swift +7 -3
  79. package/ios/overlays/MultiPointView.swift +30 -1
  80. package/ios/overlays/PolygonView.swift +63 -12
  81. package/ios/overlays/PolygonViewModule.swift +17 -0
  82. package/ios/overlays/PolylineView.swift +95 -25
  83. package/ios/overlays/PolylineViewModule.swift +17 -8
  84. package/ios/utils/PermissionManager.swift +9 -14
  85. package/package.json +4 -3
  86. package/src/ExpoGaodeMap.types.ts +28 -3
  87. package/src/ExpoGaodeMapModule.ts +201 -12
  88. package/src/ExpoGaodeMapView.tsx +11 -225
  89. package/src/components/overlays/Circle.tsx +12 -104
  90. package/src/components/overlays/Cluster.tsx +0 -1
  91. package/src/components/overlays/Marker.tsx +63 -138
  92. package/src/components/overlays/Polygon.tsx +12 -92
  93. package/src/components/overlays/Polyline.tsx +11 -77
  94. package/src/index.ts +4 -29
  95. package/src/types/index.ts +1 -1
  96. package/src/types/map-view.types.ts +1 -69
  97. package/src/types/overlays.types.ts +11 -16
  98. package/android/src/main/java/expo/modules/gaodemap/managers/OverlayManager.kt +0 -574
  99. package/build/modules/AMapLocation.d.ts +0 -78
  100. package/build/modules/AMapLocation.d.ts.map +0 -1
  101. package/build/modules/AMapLocation.js +0 -132
  102. package/build/modules/AMapLocation.js.map +0 -1
  103. package/build/modules/AMapPermissions.d.ts +0 -29
  104. package/build/modules/AMapPermissions.d.ts.map +0 -1
  105. package/build/modules/AMapPermissions.js +0 -23
  106. package/build/modules/AMapPermissions.js.map +0 -1
  107. package/build/modules/AMapSDK.d.ts +0 -22
  108. package/build/modules/AMapSDK.d.ts.map +0 -1
  109. package/build/modules/AMapSDK.js +0 -25
  110. package/build/modules/AMapSDK.js.map +0 -1
  111. package/build/modules/AMapView.d.ts +0 -44
  112. package/build/modules/AMapView.d.ts.map +0 -1
  113. package/build/modules/AMapView.js +0 -65
  114. package/build/modules/AMapView.js.map +0 -1
  115. package/ios/managers/OverlayManager.swift +0 -522
  116. package/src/modules/AMapLocation.ts +0 -165
  117. package/src/modules/AMapPermissions.ts +0 -41
  118. package/src/modules/AMapSDK.ts +0 -31
  119. package/src/modules/AMapView.ts +0 -72
  120. package/test/ClockMapView.tsx +0 -532
  121. package/test/useMap.ts +0 -1360
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
- initSDK,
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
@@ -15,13 +15,15 @@
15
15
  - ✅ 丰富的覆盖物(Circle、Marker、Polyline、Polygon)
16
16
  - ✅ 完整的 TypeScript 类型定义(零 any 类型)
17
17
  - ✅ 模块化架构设计
18
- - ✅ 同时支持声明式组件和命令式 API
18
+ - ✅ 同时支持声明式组件和命令式 API(注意:命令式 API 将在未来的版本删除,建议使用声明式组件)
19
19
  - ✅ 跨平台支持(Android、iOS)
20
20
  - ✅ 支持自定义样式和事件监听
21
21
  - ✅ 同时支持 React Native 新旧架构(Paper & Fabric)
22
22
 
23
23
  ## 📦 安装
24
24
 
25
+ ### 稳定版本(推荐)
26
+
25
27
  ```bash
26
28
  npm install expo-gaode-map
27
29
  # 或
@@ -30,6 +32,31 @@ 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
+ - ⚠️ **不向后兼容**,需要按照 [迁移指南](docs/MIGRATION.md) 更新代码
55
+
56
+ **版本对比:**
57
+ - `1.x`(稳定版):`import { initSDK, start, stop } from 'expo-gaode-map'`
58
+ - `2.0`(测试版):`import { ExpoGaodeMapModule } from 'expo-gaode-map'`
59
+
33
60
  ### Expo 项目
34
61
 
35
62
  如果你使用的是 Expo 管理的项目(使用 `expo prebuild` 或开发构建),安装后需要重新构建原生代码:
@@ -87,10 +114,7 @@ npx react-native run-android
87
114
  import { useEffect, useState } from 'react';
88
115
  import {
89
116
  MapView,
90
- initSDK,
91
- checkLocationPermission,
92
- requestLocationPermission,
93
- getCurrentLocation,
117
+ ExpoGaodeMapModule,
94
118
  } from 'expo-gaode-map';
95
119
 
96
120
  export default function App() {
@@ -99,20 +123,20 @@ export default function App() {
99
123
  useEffect(() => {
100
124
  const initialize = async () => {
101
125
  // 1. 初始化 SDK
102
- initSDK({
126
+ ExpoGaodeMapModule.initSDK({
103
127
  androidKey: 'your-android-api-key',
104
128
  iosKey: 'your-ios-api-key',
105
129
  });
106
130
 
107
131
  // 2. 检查并请求权限
108
- const status = await checkLocationPermission();
132
+ const status = await ExpoGaodeMapModule.checkLocationPermission();
109
133
  if (!status.granted) {
110
- await requestLocationPermission();
134
+ await ExpoGaodeMapModule.requestLocationPermission();
111
135
  }
112
136
 
113
137
  // 3. 获取位置并设置地图
114
138
  try {
115
- const location = await getCurrentLocation();
139
+ const location = await ExpoGaodeMapModule.getCurrentLocation();
116
140
  setInitialPosition({
117
141
  target: { latitude: location.latitude, longitude: location.longitude },
118
142
  zoom: 15
@@ -202,6 +226,7 @@ export default function MapScreen() {
202
226
  - [使用示例](docs/EXAMPLES.md) - 详细的代码示例
203
227
  - [初始化指南](docs/INITIALIZATION.md) - SDK 初始化和权限管理
204
228
  - [架构文档](docs/ARCHITECTURE.md) - 项目结构和文件说明
229
+ - [迁移指南](docs/MIGRATION.md) - v1.x 到 v2.0 的迁移指南
205
230
 
206
231
  ## ⚠️ 注意事项
207
232
 
@@ -210,22 +235,23 @@ export default function MapScreen() {
210
235
  ```tsx
211
236
  import React, { useRef, useEffect } from 'react';
212
237
  import { View, StyleSheet, Button } from 'react-native';
213
- import {
214
- MapView,
215
- initSDK,
238
+ import {
239
+ MapView,
240
+ ExpoGaodeMapModule,
216
241
  Circle,
217
242
  Marker,
218
243
  Polyline,
219
244
  Polygon,
220
- type MapViewRef
245
+ type MapViewRef
221
246
  } from 'expo-gaode-map';
222
247
 
223
248
  export default function App() {
224
249
  const mapRef = useRef<MapViewRef>(null);
225
250
 
226
251
  useEffect(() => {
227
- initSDK({
252
+ ExpoGaodeMapModule.initSDK({
228
253
  androidKey: 'your-android-api-key',
254
+ iosKey: 'your-ios-api-key',
229
255
  });
230
256
  }, []);
231
257
 
@@ -322,16 +348,9 @@ const styles = StyleSheet.create({
322
348
  ```tsx
323
349
  import React, { useEffect, useState } from 'react';
324
350
  import { View, Text, Button, StyleSheet } from 'react-native';
325
- import {
351
+ import {
326
352
  MapView,
327
- initSDK,
328
- start,
329
- stop,
330
- getCurrentLocation,
331
- addLocationListener,
332
- setLocatingWithReGeocode,
333
- setLocationMode,
334
- setInterval,
353
+ ExpoGaodeMapModule,
335
354
  type Location,
336
355
  } from 'expo-gaode-map';
337
356
 
@@ -341,17 +360,18 @@ export default function LocationApp() {
341
360
 
342
361
  useEffect(() => {
343
362
  // 初始化 SDK
344
- initSDK({
363
+ ExpoGaodeMapModule.initSDK({
345
364
  androidKey: 'your-android-api-key',
365
+ iosKey: 'your-ios-api-key',
346
366
  });
347
367
 
348
368
  // 配置定位参数
349
- setLocatingWithReGeocode(true); // 返回地址信息
350
- setLocationMode(0); // 高精度模式
351
- setInterval(2000); // 2秒更新一次
369
+ ExpoGaodeMapModule.setLocatingWithReGeocode(true); // 返回地址信息
370
+ ExpoGaodeMapModule.setLocationMode(0); // 高精度模式
371
+ ExpoGaodeMapModule.setInterval(2000); // 2秒更新一次
352
372
 
353
373
  // 监听位置更新
354
- const subscription = addLocationListener((loc) => {
374
+ const subscription = ExpoGaodeMapModule.addListener('onLocationUpdate', (loc) => {
355
375
  console.log('位置更新:', loc);
356
376
  setLocation(loc);
357
377
  });
@@ -360,18 +380,18 @@ export default function LocationApp() {
360
380
  }, []);
361
381
 
362
382
  const handleStartTracking = () => {
363
- start();
383
+ ExpoGaodeMapModule.start();
364
384
  setIsTracking(true);
365
385
  };
366
386
 
367
387
  const handleStopTracking = () => {
368
- stop();
388
+ ExpoGaodeMapModule.stop();
369
389
  setIsTracking(false);
370
390
  };
371
391
 
372
392
  const handleGetLocation = async () => {
373
393
  try {
374
- const loc = await getCurrentLocation();
394
+ const loc = await ExpoGaodeMapModule.getCurrentLocation();
375
395
  setLocation(loc);
376
396
  } catch (error) {
377
397
  console.error('获取位置失败:', error);
@@ -493,40 +513,6 @@ const styles = StyleSheet.create({
493
513
 
494
514
  详细说明请参考:[docs/followUserLocation.md](docs/followUserLocation.md)
495
515
 
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
516
 
531
517
 
532
518
  ### 颜色格式
@@ -537,12 +523,6 @@ const clearAll = async () => {
537
523
  ```tsx
538
524
  <Circle fillColor="#8800FF00" /> // 50% 透明绿色
539
525
  ```
540
-
541
- 2. **数字格式**(命令式 API):`0xAARRGGBB`
542
- ```tsx
543
- await mapRef.current?.addCircle('circle1', {
544
- fillColor: 0x8800FF00, // 50% 透明绿色
545
- });
546
526
  ```
547
527
 
548
528
  ### 性能优化