expo-gaode-map 2.0.0-alpha.6 → 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/docs/API.en.md DELETED
@@ -1,408 +0,0 @@
1
- # API Documentation
2
-
3
- English | [简体中文](./API.md)
4
-
5
- Complete API reference documentation.
6
-
7
- > ⚠️ **Permission and Privacy Compliance Warning**
8
- >
9
- > Before using map and location features, ensure:
10
- > 1. ✅ Required permission declarations configured in native projects
11
- > 2. ✅ Runtime user authorization requested
12
- > 3. ✅ Compliance with privacy laws (e.g., PIPL in China)
13
- > 4. ✅ AMap SDK privacy compliance interface configured
14
- >
15
- > For detailed configuration, see [README.md](../README.md#permission-configuration)
16
-
17
- ## Table of Contents
18
-
19
- - [MapView Props](#mapview-props)
20
- - [MapView Methods](#mapview-methods)
21
- - [Location API](#location-api)
22
- - [Type Definitions](#type-definitions)
23
-
24
- ## MapView Props
25
-
26
- ### Basic Configuration
27
-
28
- | Property | Type | Default | Description |
29
- |----------|------|---------|-------------|
30
- | `mapType` | `MapType` | `0` | Map type (0: Normal, 1: Satellite, 2: Night, 3: Navigation, 4: Bus) |
31
- | `initialCameraPosition` | `CameraPosition` | - | Initial camera position |
32
- | `style` | `ViewStyle` | - | Component style |
33
-
34
- ### Location Related
35
-
36
- > ⚠️ **Permission Required**: Location features require user authorization
37
- > - Android: `ACCESS_FINE_LOCATION` + `ACCESS_COARSE_LOCATION`
38
- > - iOS: `NSLocationWhenInUseUsageDescription` (Info.plist)
39
-
40
- | Property | Type | Default | Description |
41
- |----------|------|---------|-------------|
42
- | `myLocationEnabled` | `boolean` | `false` | Show user location |
43
- | `followUserLocation` | `boolean` | `false` | Follow user location |
44
- | `userLocationRepresentation` | `object` | - | User location style configuration |
45
-
46
- #### userLocationRepresentation Configuration
47
-
48
- | Property | Type | Platform | Default | Description |
49
- |----------|------|----------|---------|-------------|
50
- | `showsAccuracyRing` | `boolean` | All | `true` | Show accuracy ring |
51
- | `fillColor` | `string \| number` | All | - | Accuracy ring fill color |
52
- | `strokeColor` | `string \| number` | All | - | Accuracy ring stroke color |
53
- | `lineWidth` | `number` | All | `0` | Accuracy ring stroke width |
54
- | `image` | `string` | All | - | Custom location icon |
55
- | `imageWidth` | `number` | All | - | Icon width (dp/pt) |
56
- | `imageHeight` | `number` | All | - | Icon height (dp/pt) |
57
- | `showsHeadingIndicator` | `boolean` | iOS only | `true` | Show heading indicator |
58
- | `enablePulseAnimation` | `boolean` | iOS only | `true` | Enable pulse animation |
59
- | `locationDotBgColor` | `string \| number` | iOS only | `'white'` | Location dot background color |
60
- | `locationDotFillColor` | `string \| number` | iOS only | `'blue'` | Location dot fill color |
61
-
62
- ### UI Controls
63
-
64
- | Property | Type | Default | Description |
65
- |----------|------|---------|-------------|
66
- | `zoomControlsEnabled` | `boolean` | `true` | Show zoom controls (Android) |
67
- | `compassEnabled` | `boolean` | `true` | Show compass |
68
- | `scaleControlsEnabled` | `boolean` | `true` | Show scale controls |
69
-
70
- ### Gesture Controls
71
-
72
- | Property | Type | Default | Description |
73
- |----------|------|---------|-------------|
74
- | `zoomGesturesEnabled` | `boolean` | `true` | Enable zoom gestures |
75
- | `scrollGesturesEnabled` | `boolean` | `true` | Enable scroll gestures |
76
- | `rotateGesturesEnabled` | `boolean` | `true` | Enable rotate gestures |
77
- | `tiltGesturesEnabled` | `boolean` | `true` | Enable tilt gestures |
78
-
79
- ### Zoom Controls
80
-
81
- | Property | Type | Default | Description |
82
- |----------|------|---------|-------------|
83
- | `maxZoom` | `number` | `20` | Maximum zoom level (3-20) |
84
- | `minZoom` | `number` | `3` | Minimum zoom level (3-20) |
85
-
86
- ### Layer Display
87
-
88
- | Property | Type | Default | Description |
89
- |----------|------|---------|-------------|
90
- | `trafficEnabled` | `boolean` | `false` | Show traffic layer |
91
- | `buildingsEnabled` | `boolean` | `true` | Show 3D buildings |
92
- | `indoorViewEnabled` | `boolean` | `false` | Show indoor maps |
93
-
94
- ### Event Callbacks
95
-
96
- | Event | Parameters | Description |
97
- |-------|------------|-------------|
98
- | `onMapPress` | `(event: NativeSyntheticEvent<LatLng>) => void` | Map press event |
99
- | `onMapLongPress` | `(event: NativeSyntheticEvent<LatLng>) => void` | Map long press event |
100
- | `onLoad` | `(event: NativeSyntheticEvent<{}>) => void` | Map load complete event |
101
-
102
- ## MapView Methods
103
-
104
- Called via Ref:
105
-
106
- ```tsx
107
- interface MapViewRef {
108
- // Camera control
109
- moveCamera(position: CameraPosition, duration?: number): Promise<void>;
110
- setCenter(center: LatLng, animated?: boolean): Promise<void>;
111
- setZoom(zoom: number, animated?: boolean): Promise<void>;
112
- getCameraPosition(): Promise<CameraPosition>;
113
- getLatLng(point: Point): Promise<LatLng>;
114
-
115
- }
116
- ```
117
-
118
- ## Location API
119
-
120
- > ⚠️ **Permission Required**: All location APIs require location permission
121
- >
122
- > Call `checkLocationPermission()` and `requestLocationPermission()` before use
123
- >
124
- > Details: [INITIALIZATION.md](./INITIALIZATION.md)
125
-
126
- ### Location Control
127
-
128
- | Method | Parameters | Return | Description |
129
- |--------|------------|--------|-------------|
130
- | `initSDK` | `{androidKey, iosKey}` | `void` | Initialize SDK |
131
- | `start` | - | `void` | Start continuous location |
132
- | `stop` | - | `void` | Stop location |
133
- | `isStarted` | - | `Promise<boolean>` | Check if locating |
134
- | `getCurrentLocation` | - | `Promise<Location>` | Get current location |
135
-
136
- ### Location Configuration
137
-
138
- #### configure() Unified Configuration
139
-
140
- ```tsx
141
- import { configure } from 'expo-gaode-map';
142
-
143
- configure({
144
- withReGeocode: true,
145
- mode: 0,
146
- interval: 2000,
147
- // ... more options
148
- });
149
- ```
150
-
151
- #### Individual Configuration Methods
152
-
153
- > **Platform Support**: Some configuration methods are platform-specific, others will be silently ignored
154
-
155
- ##### Common Configuration (All Platforms)
156
-
157
- | Method | Parameters | Description |
158
- |--------|------------|-------------|
159
- | `setLocatingWithReGeocode` | `boolean` | Return reverse geocoding info |
160
- | `setInterval` | `number` | Location interval (ms) / distance filter (m) |
161
- | `setGeoLanguage` | `string` | Reverse geocoding language |
162
-
163
- ##### Android-Specific Configuration
164
-
165
- | Method | Parameters | Description |
166
- |--------|------------|-------------|
167
- | `setLocationMode` | `0 \| 1 \| 2` | Location mode (0: High accuracy, 1: Battery saving, 2: Device only) |
168
- | `setOnceLocation` | `boolean` | Single location |
169
- | `setSensorEnable` | `boolean` | Use device sensors |
170
- | `setWifiScan` | `boolean` | Allow WiFi scanning |
171
- | `setGpsFirst` | `boolean` | GPS priority |
172
- | `setOnceLocationLatest` | `boolean` | Wait for WiFi list refresh |
173
- | `setLocationCacheEnable` | `boolean` | Use cache strategy |
174
- | `setHttpTimeOut` | `number` | Network request timeout (ms) |
175
-
176
- ##### iOS-Specific Configuration
177
-
178
- | Method | Parameters | Description |
179
- |--------|------------|-------------|
180
- | `setLocationTimeout` | `number` | Location timeout (seconds, default 2s) |
181
- | `setReGeocodeTimeout` | `number` | Reverse geocoding timeout (seconds, default 2s) |
182
- | `setDesiredAccuracy` | `number` | Desired accuracy (0-5, default 3: 100m accuracy) |
183
- | `setDistanceFilter` | `number` | Distance filter (meters, default 10m) |
184
- | `setPausesLocationUpdatesAutomatically` | `boolean` | Auto pause location updates (default false) |
185
-
186
- **iOS Default Location Configuration:**
187
-
188
- Based on AMap official recommendations, this library uses the following default configuration for fast location:
189
- - **Accuracy**: `kCLLocationAccuracyHundredMeters` (100m accuracy, level 3)
190
- - **Location Timeout**: 2 seconds
191
- - **Reverse Geocoding Timeout**: 2 seconds
192
- - **Distance Filter**: 10 meters
193
-
194
- > **Accuracy Notes**:
195
- > - **100m Accuracy** (Recommended): Get results in 2-3 seconds, suitable for most scenarios
196
- > - **High Accuracy**: Use `setDesiredAccuracy(1)` to switch to `kCLLocationAccuracyBest`, requires `setLocationTimeout(10)` and `setReGeocodeTimeout(10)`, takes ~10 seconds for 10m accuracy
197
- > - Apple's initial location result is coarse, high accuracy requires more time
198
-
199
- **Accuracy Level Reference:**
200
-
201
- | Level | Constant | Description | Recommended Timeout |
202
- |-------|----------|-------------|---------------------|
203
- | 0 | `kCLLocationAccuracyBestForNavigation` | Best for navigation | 10s |
204
- | 1 | `kCLLocationAccuracyBest` | Best accuracy (~10m) | 10s |
205
- | 2 | `kCLLocationAccuracyNearestTenMeters` | 10m accuracy | 5s |
206
- | 3 | `kCLLocationAccuracyHundredMeters` | 100m accuracy (default) | 2-3s |
207
- | 4 | `kCLLocationAccuracyKilometer` | 1km accuracy | 1s |
208
- | 5 | `kCLLocationAccuracyThreeKilometers` | 3km accuracy | 1s |
209
-
210
- ##### Background Location Configuration (All Platforms)
211
-
212
- | Method | Parameters | Description |
213
- |--------|------------|-------------|
214
- | `setAllowsBackgroundLocationUpdates` | `boolean` | Allow background location |
215
-
216
- > **Background Location Notes**:
217
- > - **iOS**: Requires `NSLocationAlwaysAndWhenInUseUsageDescription` and `UIBackgroundModes` (including `location`) in Info.plist
218
- > - **Android**: Automatically starts foreground service, requires `ACCESS_BACKGROUND_LOCATION` permission (Android 10+)
219
- > - Background location increases battery consumption, use with caution
220
-
221
- ### Heading Updates (iOS)
222
-
223
- | Method | Description |
224
- |--------|-------------|
225
- | `startUpdatingHeading` | Start heading updates |
226
- | `stopUpdatingHeading` | Stop heading updates |
227
-
228
- ### Coordinate Conversion
229
-
230
- | Method | Parameters | Return | Description |
231
- |--------|------------|--------|-------------|
232
- | `coordinateConvert` | `coordinate, type` | `Promise<LatLng>` | Convert to AMap coordinates |
233
-
234
- ## Overlay Components
235
-
236
-
237
- ### Circle
238
-
239
- #### Properties
240
-
241
- | Property | Type | Platform | Default | Description |
242
- |----------|------|----------|---------|-------------|
243
- | `center` | `LatLng` | All | - | Circle center (required) |
244
- | `radius` | `number` | All | - | Radius (meters) |
245
- | `fillColor` | `string` | All | - | Fill color (ARGB format: `#AARRGGBB`) |
246
- | `strokeColor` | `string` | All | - | Stroke color (ARGB format: `#AARRGGBB`) |
247
- | `strokeWidth` | `number` | All | `1` | Stroke width (pt/dp) |
248
-
249
- #### Events
250
-
251
- | Event | Parameters | Description |
252
- |-------|------------|-------------|
253
- | `onPress` | `(event: NativeSyntheticEvent<{}>) => void` | Circle press |
254
-
255
- ### Polyline
256
-
257
- #### Properties
258
-
259
- | Property | Type | Platform | Default | Description |
260
- |----------|------|----------|---------|-------------|
261
- | `points` | `LatLng[]` | All | - | Polyline points (required) |
262
- | `width` | `number` | All | `5` | Line width (pt/dp) |
263
- | `color` | `string` | All | - | Line color (ARGB format: `#AARRGGBB`) |
264
- | `texture` | `string` | All | - | Texture image URL |
265
- | `dotted` | `boolean` | Android only | `false` | Draw dashed line |
266
- | `geodesic` | `boolean` | Android only | `false` | Draw geodesic line |
267
- | `zIndex` | `number` | All | `0` | Z-index |
268
-
269
- #### Events
270
-
271
- | Event | Parameters | Description |
272
- |-------|------------|-------------|
273
- | `onPress` | `(event: NativeSyntheticEvent<{}>) => void` | Polyline press |
274
-
275
- > **Texture Notes**:
276
- > - Supports network images (http/https) and local files (use `Image.resolveAssetSource()`)
277
- > - Texture tiles along the polyline direction
278
- > - Recommend larger `width` values (e.g., 20) for better texture display
279
- > - **Segment Texture Limitation**: Single Polyline can only have one texture. For different textures on segments, create multiple Polyline components
280
-
281
- ### Polygon
282
-
283
- #### Properties
284
-
285
- | Property | Type | Platform | Default | Description |
286
- |----------|------|----------|---------|-------------|
287
- | `points` | `LatLng[]` | All | - | Polygon vertices (required) |
288
- | `fillColor` | `string` | All | - | Fill color (ARGB format: `#AARRGGBB`) |
289
- | `strokeColor` | `string` | All | - | Stroke color (ARGB format: `#AARRGGBB`) |
290
- | `strokeWidth` | `number` | All | `1` | Stroke width (pt/dp) |
291
-
292
- #### Events
293
-
294
- | Event | Parameters | Description |
295
- |-------|------------|-------------|
296
- | `onPress` | `(event: NativeSyntheticEvent<{}>) => void` | Polygon press |
297
-
298
- ### Marker
299
-
300
- #### Properties
301
-
302
- | Property | Type | Platform | Default | Description |
303
- |----------|------|----------|---------|-------------|
304
- | `position` | `LatLng` | All | - | Marker position (required) |
305
- | `title` | `string` | All | - | Title |
306
- | `snippet` | `string` | All | - | Description |
307
- | `draggable` | `boolean` | All | `false` | Draggable |
308
- | `icon` | `string \| ImageSourcePropType` | All | - | Custom icon |
309
- | `iconWidth` | `number` | All | `40` | Icon width (pt/dp), only for `icon` property |
310
- | `iconHeight` | `number` | All | `40` | Icon height (pt/dp), only for `icon` property |
311
- | `customViewWidth` | `number` | All | `80` | Custom view width (pt/dp), only for `children` property |
312
- | `customViewHeight` | `number` | All | `30` | Custom view height (pt/dp), only for `children` property |
313
- | `opacity` | `number` | Android only | `1.0` | Opacity [0, 1] |
314
- | `flat` | `boolean` | Android only | `false` | Flat on map |
315
- | `zIndex` | `number` | Android only | `0` | Z-index |
316
- | `anchor` | `Point` | Android only | `{x: 0.5, y: 1.0}` | Anchor ratio |
317
- | `centerOffset` | `Point` | iOS only | - | Center offset |
318
- | `animatesDrop` | `boolean` | iOS only | `false` | Drop animation |
319
- | `pinColor` | `'red' \| 'green' \| 'purple'` | iOS only | `'red'` | Pin color |
320
-
321
- #### Events
322
-
323
- | Event | Parameters | Description |
324
- |-------|------------|-------------|
325
- | `onPress` | `(event: NativeSyntheticEvent<{}>) => void` | Marker press |
326
- | `onDragStart` | `(event: NativeSyntheticEvent<LatLng>) => void` | Drag start |
327
- | `onDrag` | `(event: NativeSyntheticEvent<LatLng>) => void` | Dragging |
328
- | `onDragEnd` | `(event: NativeSyntheticEvent<LatLng>) => void` | Drag end |
329
-
330
- > **⚠️ Important**: Event callbacks only work in **declarative usage**. Markers added via imperative API (`addMarker`) cannot trigger these events.
331
-
332
- #### Usage Notes
333
-
334
- **Custom Icon (icon property):**
335
- - **Icon Format**: Supports network images (http/https), local files (use `Image.resolveAssetSource()`)
336
- - **Size Control**: Use `iconWidth` and `iconHeight` to control icon size
337
- - **Size Unit**: Uses points (pt/dp), auto-scales on different density screens
338
- - **Anchor**: `anchor` defines icon position relative to coordinate, `{x: 0.5, y: 1.0}` means bottom-center aligned
339
-
340
- **Custom View (children property):**
341
- - **Size Control**: Use `customViewWidth` and `customViewHeight` to control custom view size
342
- - **Default Size**: 80x30 pt/dp
343
- - **Important**: `iconWidth/iconHeight` only apply to `icon` property, not `children`
344
- - Recommend explicitly setting size to ensure consistent display across devices
345
-
346
- ## Type Definitions
347
-
348
- ### MapType
349
-
350
- ```typescript
351
- enum MapType {
352
- NORMAL = 0, // Normal map
353
- SATELLITE = 1, // Satellite map
354
- NIGHT = 2, // Night map
355
- NAVI = 3, // Navigation map
356
- BUS = 4, // Bus map
357
- }
358
- ```
359
-
360
- ### CameraPosition
361
-
362
- ```typescript
363
- interface CameraPosition {
364
- target: LatLng; // Target position
365
- zoom: number; // Zoom level (3-20)
366
- tilt?: number; // Tilt angle (0-60)
367
- bearing?: number; // Rotation angle (0-360)
368
- }
369
- ```
370
-
371
- ### LatLng
372
-
373
- ```typescript
374
- interface LatLng {
375
- latitude: number; // Latitude
376
- longitude: number; // Longitude
377
- }
378
- ```
379
-
380
- ### Location
381
-
382
- ```typescript
383
- interface Location {
384
- // Basic location info
385
- latitude: number;
386
- longitude: number;
387
- accuracy: number;
388
- altitude: number;
389
- bearing: number;
390
- speed: number;
391
-
392
- // Address info (requires reverse geocoding)
393
- address?: string;
394
- province?: string;
395
- city?: string;
396
- district?: string;
397
- street?: string;
398
- streetNumber?: string;
399
- country?: string;
400
- cityCode?: string;
401
- adCode?: string;
402
- poiName?: string;
403
- aoiName?: string;
404
-
405
- // Other info
406
- provider?: string;
407
- timestamp?: number;
408
- }