expo-gaode-map 1.0.2 → 1.0.4
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.md +1 -0
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapModule.kt +87 -5
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapView.kt +132 -1
- package/android/src/main/java/expo/modules/gaodemap/managers/OverlayManager.kt +271 -6
- package/android/src/main/java/expo/modules/gaodemap/overlays/CircleView.kt +40 -51
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerView.kt +3 -0
- package/android/src/main/java/expo/modules/gaodemap/overlays/PolygonView.kt +22 -2
- package/android/src/main/java/expo/modules/gaodemap/overlays/PolylineView.kt +83 -17
- package/build/ExpoGaodeMapView.d.ts +46 -1
- package/build/ExpoGaodeMapView.d.ts.map +1 -1
- package/build/ExpoGaodeMapView.js +134 -1
- package/build/ExpoGaodeMapView.js.map +1 -1
- package/build/components/overlays/Circle.d.ts +0 -20
- package/build/components/overlays/Circle.d.ts.map +1 -1
- package/build/components/overlays/Circle.js +28 -45
- package/build/components/overlays/Circle.js.map +1 -1
- package/build/components/overlays/Marker.d.ts +2 -16
- package/build/components/overlays/Marker.d.ts.map +1 -1
- package/build/components/overlays/Marker.js +60 -37
- package/build/components/overlays/Marker.js.map +1 -1
- package/build/components/overlays/Polygon.d.ts +1 -0
- package/build/components/overlays/Polygon.d.ts.map +1 -1
- package/build/components/overlays/Polygon.js +38 -47
- package/build/components/overlays/Polygon.js.map +1 -1
- package/build/components/overlays/Polyline.d.ts +1 -0
- package/build/components/overlays/Polyline.d.ts.map +1 -1
- package/build/components/overlays/Polyline.js +38 -12
- package/build/components/overlays/Polyline.js.map +1 -1
- package/build/types/map-view.types.d.ts +42 -0
- 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 +31 -1
- package/build/types/overlays.types.d.ts.map +1 -1
- package/build/types/overlays.types.js.map +1 -1
- package/docs/API.md +121 -7
- package/docs/EXAMPLES.md +86 -2
- package/docs/INITIALIZATION.md +14 -4
- package/expo-module.config.json +1 -1
- package/ios/ExpoGaodeMapModule.swift +132 -18
- package/ios/ExpoGaodeMapView.swift +361 -12
- package/ios/managers/OverlayManager.swift +188 -12
- package/ios/modules/LocationManager.swift +3 -0
- package/ios/overlays/CircleView.swift +41 -12
- package/ios/overlays/MarkerView.swift +55 -3
- package/ios/overlays/PolygonView.swift +27 -5
- package/ios/overlays/PolylineView.swift +37 -4
- package/ios/utils/ColorParser.swift +0 -5
- package/ios/utils/PermissionManager.swift +62 -7
- package/package.json +1 -1
- package/src/ExpoGaodeMapView.tsx +194 -1
- package/src/components/overlays/Circle.tsx +31 -48
- package/src/components/overlays/Marker.tsx +69 -42
- package/src/components/overlays/Polygon.tsx +46 -49
- package/src/components/overlays/Polyline.tsx +46 -15
- package/src/types/map-view.types.ts +35 -0
- package/src/types/overlays.types.ts +36 -1
package/docs/INITIALIZATION.md
CHANGED
|
@@ -216,9 +216,10 @@ export default function App() {
|
|
|
216
216
|
- ✅ 提供默认位置作为后备方案
|
|
217
217
|
|
|
218
218
|
3. **地图渲染**:
|
|
219
|
-
- ✅
|
|
219
|
+
- ✅ **重要**: 等待 `initialPosition` 设置后再渲染 MapView
|
|
220
220
|
- ✅ 使用 `initialCameraPosition` 设置初始位置
|
|
221
|
-
-
|
|
221
|
+
- ⚠️ **iOS 注意**: 如果在获取位置前就渲染地图,会先显示默认位置(北京)再跳转,造成闪烁
|
|
222
|
+
- ✅ Android 和 iOS 都会在地图显示时直接定位到指定位置
|
|
222
223
|
|
|
223
224
|
## 常见问题
|
|
224
225
|
|
|
@@ -264,11 +265,18 @@ await mapRef.current?.moveCamera({
|
|
|
264
265
|
|
|
265
266
|
### Q: 如何配置定位参数?
|
|
266
267
|
|
|
267
|
-
**A:** 使用 `configure`
|
|
268
|
+
**A:** 使用 `configure` 函数,**必须在 `initSDK` 之后调用**:
|
|
268
269
|
|
|
269
270
|
```tsx
|
|
270
|
-
import { configure } from 'expo-gaode-map';
|
|
271
|
+
import { initSDK, configure } from 'expo-gaode-map';
|
|
271
272
|
|
|
273
|
+
// 1. 先初始化 SDK
|
|
274
|
+
initSDK({
|
|
275
|
+
androidKey: 'your-android-api-key',
|
|
276
|
+
iosKey: 'your-ios-api-key',
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
// 2. 再配置定位参数
|
|
272
280
|
configure({
|
|
273
281
|
withReGeocode: true, // 返回地址信息
|
|
274
282
|
mode: 0, // 高精度模式
|
|
@@ -276,6 +284,8 @@ configure({
|
|
|
276
284
|
});
|
|
277
285
|
```
|
|
278
286
|
|
|
287
|
+
> ⚠️ **重要**: `configure` 必须在 `initSDK` 之后调用,否则配置可能不生效。
|
|
288
|
+
|
|
279
289
|
### Q: Android 和 iOS 的初始化有区别吗?
|
|
280
290
|
|
|
281
291
|
**A:** 初始化流程相同,但有以下差异:
|
package/expo-module.config.json
CHANGED
|
@@ -180,6 +180,69 @@ public class ExpoGaodeMapModule: Module {
|
|
|
180
180
|
self.getLocationManager().stopUpdatingHeading()
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
/**
|
|
184
|
+
* 设置逆地理语言 (iOS 实现)
|
|
185
|
+
*/
|
|
186
|
+
Function("setGeoLanguage") { (language: Int) in
|
|
187
|
+
self.getLocationManager().setGeoLanguage(language)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* 设置是否单次定位 (Android 专用,iOS 空实现)
|
|
192
|
+
*/
|
|
193
|
+
Function("setOnceLocation") { (_: Bool) in
|
|
194
|
+
// iOS 不支持此配置
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* 设置是否使用设备传感器 (Android 专用,iOS 空实现)
|
|
199
|
+
*/
|
|
200
|
+
Function("setSensorEnable") { (_: Bool) in
|
|
201
|
+
// iOS 不支持此配置
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* 设置是否允许 WIFI 扫描 (Android 专用,iOS 空实现)
|
|
206
|
+
*/
|
|
207
|
+
Function("setWifiScan") { (_: Bool) in
|
|
208
|
+
// iOS 不支持此配置
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* 设置是否 GPS 优先 (Android 专用,iOS 空实现)
|
|
213
|
+
*/
|
|
214
|
+
Function("setGpsFirst") { (_: Bool) in
|
|
215
|
+
// iOS 不支持此配置
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* 设置是否等待 WIFI 列表刷新 (Android 专用,iOS 空实现)
|
|
220
|
+
*/
|
|
221
|
+
Function("setOnceLocationLatest") { (_: Bool) in
|
|
222
|
+
// iOS 不支持此配置
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* 设置是否使用缓存策略 (Android 专用,iOS 空实现)
|
|
227
|
+
*/
|
|
228
|
+
Function("setLocationCacheEnable") { (_: Bool) in
|
|
229
|
+
// iOS 不支持此配置
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 设置网络请求超时时间 (Android 专用,iOS 空实现)
|
|
234
|
+
*/
|
|
235
|
+
Function("setHttpTimeOut") { (_: Int) in
|
|
236
|
+
// iOS 不支持此配置
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* 设置定位协议 (未实现)
|
|
241
|
+
*/
|
|
242
|
+
Function("setLocationProtocol") { (_: Int) in
|
|
243
|
+
// 未实现
|
|
244
|
+
}
|
|
245
|
+
|
|
183
246
|
// ==================== 权限管理 ====================
|
|
184
247
|
|
|
185
248
|
/**
|
|
@@ -204,10 +267,21 @@ public class ExpoGaodeMapModule: Module {
|
|
|
204
267
|
}
|
|
205
268
|
|
|
206
269
|
self.permissionManager?.requestPermission { granted, status in
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
270
|
+
print("🔐 [PermissionManager] 权限回调: granted=\(granted), status=\(status)")
|
|
271
|
+
|
|
272
|
+
// 无论结果如何,都延迟后再次检查最终状态
|
|
273
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
|
274
|
+
let finalStatus = CLLocationManager.authorizationStatus()
|
|
275
|
+
let finalGranted = finalStatus == .authorizedAlways || finalStatus == .authorizedWhenInUse
|
|
276
|
+
let finalStatusString = self.getAuthorizationStatusString(finalStatus)
|
|
277
|
+
|
|
278
|
+
print("🔐 [PermissionManager] 最终状态: granted=\(finalGranted), status=\(finalStatusString)")
|
|
279
|
+
|
|
280
|
+
promise.resolve([
|
|
281
|
+
"granted": finalGranted,
|
|
282
|
+
"status": finalStatusString
|
|
283
|
+
])
|
|
284
|
+
}
|
|
211
285
|
}
|
|
212
286
|
}
|
|
213
287
|
|
|
@@ -221,7 +295,7 @@ public class ExpoGaodeMapModule: Module {
|
|
|
221
295
|
|
|
222
296
|
View(ExpoGaodeMapView.self) {
|
|
223
297
|
// 事件 - 使用 Expo 的事件命名约定
|
|
224
|
-
Events("onMapPress", "onMapLongPress", "onLoad")
|
|
298
|
+
Events("onMapPress", "onMapLongPress", "onLoad", "onMarkerPress", "onMarkerDragStart", "onMarkerDrag", "onMarkerDragEnd", "onCirclePress", "onPolygonPress", "onPolylinePress")
|
|
225
299
|
|
|
226
300
|
// 地图类型
|
|
227
301
|
Prop("mapType") { (view: ExpoGaodeMapView, type: Int) in
|
|
@@ -390,13 +464,41 @@ public class ExpoGaodeMapModule: Module {
|
|
|
390
464
|
view.setTitle(title)
|
|
391
465
|
}
|
|
392
466
|
|
|
393
|
-
Prop("
|
|
394
|
-
view.setDescription(
|
|
467
|
+
Prop("snippet") { (view: MarkerView, snippet: String) in
|
|
468
|
+
view.setDescription(snippet)
|
|
395
469
|
}
|
|
396
470
|
|
|
397
471
|
Prop("draggable") { (view: MarkerView, draggable: Bool) in
|
|
398
472
|
view.setDraggable(draggable)
|
|
399
473
|
}
|
|
474
|
+
|
|
475
|
+
Prop("icon") { (view: MarkerView, source: [String: Any]?) in
|
|
476
|
+
view.setIcon(source)
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
Prop("iconWidth") { (view: MarkerView, width: Double) in
|
|
480
|
+
view.iconWidth = width
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
Prop("iconHeight") { (view: MarkerView, height: Double) in
|
|
484
|
+
view.iconHeight = height
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
Prop("centerOffset") { (view: MarkerView, offset: [String: Double]) in
|
|
488
|
+
view.setCenterOffset(offset)
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
Prop("animatesDrop") { (view: MarkerView, animate: Bool) in
|
|
492
|
+
view.setAnimatesDrop(animate)
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
Prop("pinColor") { (view: MarkerView, color: String) in
|
|
496
|
+
view.setPinColor(color)
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
Prop("canShowCallout") { (view: MarkerView, show: Bool) in
|
|
500
|
+
view.setCanShowCallout(show)
|
|
501
|
+
}
|
|
400
502
|
}
|
|
401
503
|
|
|
402
504
|
// Circle - 圆形
|
|
@@ -411,16 +513,16 @@ public class ExpoGaodeMapModule: Module {
|
|
|
411
513
|
view.setRadius(radius)
|
|
412
514
|
}
|
|
413
515
|
|
|
414
|
-
Prop("fillColor") { (view: CircleView, color:
|
|
516
|
+
Prop("fillColor") { (view: CircleView, color: String) in
|
|
415
517
|
view.setFillColor(color)
|
|
416
518
|
}
|
|
417
519
|
|
|
418
|
-
Prop("strokeColor") { (view: CircleView, color:
|
|
520
|
+
Prop("strokeColor") { (view: CircleView, color: String) in
|
|
419
521
|
view.setStrokeColor(color)
|
|
420
522
|
}
|
|
421
523
|
|
|
422
|
-
Prop("strokeWidth") { (view: CircleView, width:
|
|
423
|
-
view.setStrokeWidth(width)
|
|
524
|
+
Prop("strokeWidth") { (view: CircleView, width: Double) in
|
|
525
|
+
view.setStrokeWidth(Float(width))
|
|
424
526
|
}
|
|
425
527
|
}
|
|
426
528
|
|
|
@@ -432,17 +534,29 @@ public class ExpoGaodeMapModule: Module {
|
|
|
432
534
|
view.setPoints(points)
|
|
433
535
|
}
|
|
434
536
|
|
|
435
|
-
Prop("
|
|
436
|
-
view.setStrokeWidth(width)
|
|
537
|
+
Prop("width") { (view: PolylineView, width: Double) in
|
|
538
|
+
view.setStrokeWidth(Float(width))
|
|
437
539
|
}
|
|
438
540
|
|
|
439
|
-
Prop("
|
|
541
|
+
Prop("strokeWidth") { (view: PolylineView, width: Double) in
|
|
542
|
+
view.setStrokeWidth(Float(width))
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
Prop("color") { (view: PolylineView, color: String) in
|
|
546
|
+
view.setStrokeColor(color)
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
Prop("strokeColor") { (view: PolylineView, color: String) in
|
|
440
550
|
view.setStrokeColor(color)
|
|
441
551
|
}
|
|
442
552
|
|
|
443
553
|
Prop("texture") { (view: PolylineView, url: String?) in
|
|
444
554
|
view.setTexture(url)
|
|
445
555
|
}
|
|
556
|
+
|
|
557
|
+
Prop("dotted") { (view: PolylineView, dotted: Bool) in
|
|
558
|
+
view.setDotted(dotted)
|
|
559
|
+
}
|
|
446
560
|
}
|
|
447
561
|
|
|
448
562
|
// Polygon - 多边形
|
|
@@ -453,16 +567,16 @@ public class ExpoGaodeMapModule: Module {
|
|
|
453
567
|
view.setPoints(points)
|
|
454
568
|
}
|
|
455
569
|
|
|
456
|
-
Prop("fillColor") { (view: PolygonView, color:
|
|
570
|
+
Prop("fillColor") { (view: PolygonView, color: String) in
|
|
457
571
|
view.setFillColor(color)
|
|
458
572
|
}
|
|
459
573
|
|
|
460
|
-
Prop("strokeColor") { (view: PolygonView, color:
|
|
574
|
+
Prop("strokeColor") { (view: PolygonView, color: String) in
|
|
461
575
|
view.setStrokeColor(color)
|
|
462
576
|
}
|
|
463
577
|
|
|
464
|
-
Prop("strokeWidth") { (view: PolygonView, width:
|
|
465
|
-
view.setStrokeWidth(width)
|
|
578
|
+
Prop("strokeWidth") { (view: PolygonView, width: Double) in
|
|
579
|
+
view.setStrokeWidth(Float(width))
|
|
466
580
|
}
|
|
467
581
|
}
|
|
468
582
|
|