expo-gaode-map 2.0.0-alpha.5 → 2.0.0-alpha.7

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.
@@ -1,423 +0,0 @@
1
- # Project Architecture Documentation
2
-
3
- English | [简体中文](./ARCHITECTURE.md)
4
-
5
- This document details the code structure and file responsibilities of the expo-gaode-map project.
6
-
7
- ## Directory Structure Overview
8
-
9
- ```
10
- expo-gaode-map/
11
- ├── src/ # TypeScript source code
12
- ├── ios/ # iOS native code
13
- ├── android/ # Android native code
14
- ├── docs/ # Documentation
15
- └── example/ # Example application
16
- ```
17
-
18
- ---
19
-
20
- ## iOS Code Structure
21
-
22
- ```
23
- ios/
24
- ├── ExpoGaodeMapModule.swift # Expo module definition
25
- ├── ExpoGaodeMapView.swift # Map view component
26
- ├── ExpoGaodeMap.podspec # CocoaPods configuration
27
- ├── managers/ # Manager classes
28
- │ ├── CameraManager.swift # Camera control manager
29
- │ ├── UIManager.swift # UI and gesture manager
30
- │ └── OverlayManager.swift # Overlay manager
31
- ├── modules/ # Feature modules
32
- │ ├── LocationManager.swift # Location manager
33
- │ └── ColorParser.swift # Color parser utility
34
- ├── utils/ # Utility classes
35
- │ └── PermissionManager.swift # Permission manager
36
- └── overlays/ # Overlay views
37
- ├── CircleView.swift # Circle overlay
38
- ├── MarkerView.swift # Marker
39
- ├── PolylineView.swift # Polyline
40
- ├── PolygonView.swift # Polygon
41
- ├── HeatMapView.swift # Heat map
42
- ├── MultiPointView.swift # Multi-point
43
- └── ClusterView.swift # Cluster
44
- ```
45
-
46
- ### iOS File Descriptions
47
-
48
- #### Core Files
49
-
50
- - **ExpoGaodeMapModule.swift**
51
- - Expo module entry point
52
- - Register map view and overlay views
53
- - Define SDK initialization methods
54
- - Define location-related methods
55
- - Manage location listener lifecycle
56
-
57
- - **ExpoGaodeMapView.swift**
58
- - Main map view implementation
59
- - Manage map properties (type, camera position, etc.)
60
- - Handle map events (press, long press, etc.)
61
- - Coordinate managers
62
- - Manage child views (overlays)
63
-
64
- - **ExpoGaodeMap.podspec**
65
- - CocoaPods dependency configuration
66
- - Define iOS SDK version requirements
67
- - Specify AMap SDK dependencies
68
-
69
- #### Manager Classes (managers/)
70
-
71
- - **CameraManager.swift**
72
- - Camera position control
73
- - Zoom level management
74
- - Map center point setting
75
- - Tilt and rotation control
76
- - Screen/geographic coordinate conversion
77
-
78
- - **UIManager.swift**
79
- - Map type setting (normal/satellite/night/navigation)
80
- - UI control display (zoom, compass, scale)
81
- - Gesture control (zoom, scroll, rotate, tilt)
82
- - User location display and styling
83
- - Layer display (traffic, buildings, indoor maps)
84
-
85
- - **OverlayManager.swift**
86
- - Circle overlay management
87
- - Marker management
88
- - Polyline management (texture support)
89
- - Polygon management
90
- - Overlay renderers
91
- - Texture image loading
92
-
93
- #### Feature Modules (modules/)
94
-
95
- - **LocationManager.swift**
96
- - Continuous and single location
97
- - Location configuration (accuracy, interval, mode)
98
- - Reverse geocoding
99
- - Heading sensor
100
- - Location result formatting
101
-
102
- - **ColorParser.swift**
103
- - Color value parsing
104
- - Support multiple color formats
105
-
106
- #### Utility Classes (utils/)
107
-
108
- - **PermissionManager.swift**
109
- - Location permission request
110
- - Permission status query
111
- - Permission change listener
112
-
113
- #### Overlay Views (overlays/)
114
-
115
- - **CircleView.swift**
116
- - Circle overlay view implementation
117
- - Support fill color, stroke color, stroke width
118
-
119
- - **MarkerView.swift**
120
- - Marker view implementation
121
- - Support title, description, draggable
122
-
123
- - **PolylineView.swift**
124
- - Polyline view implementation
125
- - Support line width, color, texture
126
-
127
- - **PolygonView.swift**
128
- - Polygon view implementation
129
- - Support fill color, stroke color, stroke width
130
-
131
- - **HeatMapView.swift**
132
- - Heat map view implementation
133
- - Support radius, opacity configuration
134
-
135
- - **MultiPointView.swift**
136
- - Multi-point view implementation
137
- - High-performance point rendering
138
-
139
- - **ClusterView.swift**
140
- - Cluster view implementation
141
- - Auto-cluster nearby points
142
-
143
- ---
144
-
145
- ## Android Code Structure
146
-
147
- ```
148
- android/
149
- └── src/main/java/expo/modules/gaodemap/
150
- ├── ExpoGaodeMapModule.kt # Expo module definition
151
- ├── ExpoGaodeMapView.kt # Map view component
152
- ├── managers/ # Manager classes
153
- │ ├── CameraManager.kt # Camera control manager
154
- │ ├── UIManager.kt # UI and gesture manager
155
- │ └── OverlayManager.kt # Overlay manager
156
- ├── modules/ # Feature modules
157
- │ ├── SDKInitializer.kt # SDK initialization
158
- │ └── LocationManager.kt # Location manager
159
- ├── utils/ # Utility classes
160
- │ └── ColorParser.kt # Color parser utility
161
- └── overlays/ # Overlay views
162
- ├── CircleView.kt # Circle overlay
163
- ├── MarkerView.kt # Marker
164
- ├── PolylineView.kt # Polyline
165
- ├── PolygonView.kt # Polygon
166
- ├── HeatMapView.kt # Heat map
167
- ├── MultiPointView.kt # Multi-point
168
- └── ClusterView.kt # Cluster
169
- ```
170
-
171
- ### Android File Descriptions
172
-
173
- #### Core Files
174
-
175
- - **ExpoGaodeMapModule.kt**
176
- - Expo module entry point
177
- - Register map view and overlay views
178
- - Define SDK initialization methods
179
- - Define location-related methods
180
- - Define permission management methods
181
- - Manage location listener lifecycle
182
-
183
- - **ExpoGaodeMapView.kt**
184
- - Main map view implementation
185
- - Manage map properties (type, camera position, etc.)
186
- - Handle map events (press, long press, load)
187
- - Coordinate managers
188
- - Manage child views (overlays)
189
- - Handle lifecycle and memory management
190
-
191
- #### Manager Classes (managers/)
192
-
193
- - **CameraManager.kt**
194
- - Camera position control
195
- - Zoom level management (including max/min limits)
196
- - Map center point setting
197
- - Tilt and rotation control
198
- - Screen/geographic coordinate conversion
199
- - Animated camera movement
200
-
201
- - **UIManager.kt**
202
- - Map type setting (normal/satellite/night/navigation/bus)
203
- - UI control display (zoom, compass, scale)
204
- - Gesture control (zoom, scroll, rotate, tilt)
205
- - User location display and styling
206
- - Custom location icon (network image support)
207
- - Layer display (traffic, buildings, indoor maps)
208
-
209
- - **OverlayManager.kt**
210
- - Circle overlay management
211
- - Marker management
212
- - Polyline management (texture support)
213
- - Polygon management
214
- - Overlay property updates
215
- - Texture image loading (network and local)
216
-
217
- #### Feature Modules (modules/)
218
-
219
- - **SDKInitializer.kt**
220
- - SDK initialization
221
- - Privacy compliance settings
222
- - API Key configuration
223
- - Version info retrieval
224
-
225
- - **LocationManager.kt**
226
- - Continuous and single location
227
- - Location configuration (accuracy, interval, mode)
228
- - Reverse geocoding
229
- - Coordinate conversion
230
- - Location result formatting
231
- - Resource cleanup
232
-
233
- #### Utility Classes (utils/)
234
-
235
- - **ColorParser.kt**
236
- - Color value parsing
237
- - Support multiple color formats (hex, integer)
238
- - Transparency handling
239
-
240
- #### Overlay Views (overlays/)
241
-
242
- - **CircleView.kt**
243
- - Circle overlay view implementation
244
- - Support fill color, stroke color, stroke width
245
- - Dynamic property updates
246
-
247
- - **MarkerView.kt**
248
- - Marker view implementation
249
- - Support title, description, draggable
250
- - Custom icon
251
-
252
- - **PolylineView.kt**
253
- - Polyline view implementation
254
- - Support line width, color
255
- - Texture support
256
-
257
- - **PolygonView.kt**
258
- - Polygon view implementation
259
- - Support fill color, stroke color, stroke width
260
- - Z-Index layer control
261
-
262
- - **HeatMapView.kt**
263
- - Heat map view implementation
264
- - Support radius, opacity configuration
265
- - High-performance heat rendering
266
-
267
- - **MultiPointView.kt**
268
- - Multi-point view implementation
269
- - High-performance point rendering
270
- - Custom point style
271
-
272
- - **ClusterView.kt**
273
- - Cluster view implementation
274
- - Auto-cluster nearby points
275
- - Configurable cluster radius and minimum count
276
-
277
- ---
278
-
279
- ## TypeScript Code Structure
280
-
281
- ```
282
- src/
283
- ├── index.ts # Main export file
284
- ├── ExpoGaodeMapModule.ts # Native module import
285
- ├── ExpoGaodeMapView.tsx # Map view component
286
- ├── ExpoGaodeMap.types.ts # Type definition export
287
- ├── components/ # React components
288
- │ └── overlays/ # Overlay components
289
- │ ├── index.ts # Overlay exports
290
- │ ├── Circle.tsx # Circle component
291
- │ ├── Marker.tsx # Marker component
292
- │ ├── Polyline.tsx # Polyline component
293
- │ ├── Polygon.tsx # Polygon component
294
- │ ├── HeatMap.tsx # Heat map component
295
- │ ├── MultiPoint.tsx # Multi-point component
296
- │ └── Cluster.tsx # Cluster component
297
- ├── modules/ # Feature modules
298
- │ ├── AMapSDK.ts # SDK module
299
- │ ├── AMapLocation.ts # Location module
300
- │ └── AMapView.ts # Map view module (deprecated)
301
- └── types/ # TypeScript type definitions
302
- ├── index.ts # Type exports
303
- ├── common.types.ts # Common types
304
- ├── map-view.types.ts # Map view types
305
- ├── location.types.ts # Location types
306
- ├── overlays.types.ts # Overlay types
307
- └── sdk.types.ts # SDK types
308
- ```
309
-
310
- ### TypeScript File Descriptions
311
-
312
- #### Core Files
313
-
314
- - **index.ts**
315
- - Main export file
316
- - Export all public APIs
317
-
318
- - **ExpoGaodeMapModule.ts**
319
- - Native module import
320
- - Event type definitions
321
-
322
- - **ExpoGaodeMapView.tsx**
323
- - Map view React component
324
- - Wrap native view
325
- - Provide imperative API (ref)
326
-
327
- - **ExpoGaodeMap.types.ts**
328
- - Re-export all types
329
- - Provide convenient type imports
330
-
331
- #### Components (components/)
332
-
333
- Overlay components provide declarative API, used as MapView children.
334
-
335
- #### Modules (modules/)
336
-
337
- - **AMapSDK.ts**
338
- - SDK initialization
339
- - Version retrieval
340
-
341
- - **AMapLocation.ts**
342
- - Location configuration
343
- - Location listeners
344
- - Location retrieval
345
-
346
- #### Types (types/)
347
-
348
- Define all TypeScript types, including:
349
- - Map configuration
350
- - Camera position
351
- - Overlay properties
352
- - Location results
353
- - Event callbacks
354
-
355
- ---
356
-
357
- ## Architecture Design Principles
358
-
359
- ### 1. Separation of Concerns
360
-
361
- - **Module**: Module definition and method registration
362
- - **View**: View creation and property management
363
- - **Manager**: Specific feature implementation
364
- - **Overlay**: Overlay rendering
365
-
366
- ### 2. Cross-Platform Consistency
367
-
368
- - iOS and Android provide same API
369
- - TypeScript layer unified encapsulation
370
- - Differences handled in native layer
371
-
372
- ### 3. Memory Management
373
-
374
- - Use weak references to avoid circular references
375
- - Timely cleanup of listeners and resources
376
- - Main thread operations use Handler/DispatchQueue
377
-
378
- ### 4. Error Handling
379
-
380
- - Promise for async operations
381
- - Unified error codes and messages
382
- - Detailed error logging
383
-
384
- ### 5. Performance Optimization
385
-
386
- - Main thread scheduling for UI operations
387
- - Background thread for image loading
388
- - On-demand overlay rendering
389
-
390
- ---
391
-
392
- ## Development Guide
393
-
394
- ### Adding New Features
395
-
396
- 1. Implement feature in native layer (iOS and Android)
397
- 2. Register methods in Module
398
- 3. Wrap API in TypeScript layer
399
- 4. Add type definitions
400
- 5. Update documentation
401
-
402
- ### Debugging Tips
403
-
404
- - Use logs to view call flow
405
- - Check main thread operations
406
- - Verify memory leaks
407
- - Test edge cases
408
-
409
- ### Code Standards
410
-
411
- - Use detailed comments
412
- - Follow platform naming conventions
413
- - Keep code clean
414
- - Write unit tests
415
-
416
- ---
417
-
418
- ## Related Documentation
419
-
420
- - [README.md](../README.md) - Quick start and basic usage
421
- - [API.md](./API.en.md) - Complete API documentation
422
- - [EXAMPLES.md](./EXAMPLES.en.md) - Example code
423
- - [INITIALIZATION.md](./INITIALIZATION.en.md) - Initialization guide