expo-gaode-map-navigation 2.0.5 → 2.0.6
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 +52 -1
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapView.kt +182 -86
- package/android/src/main/java/expo/modules/gaodemap/map/ExpoGaodeMapViewModule.kt +5 -2
- package/android/src/main/java/expo/modules/gaodemap/map/managers/UIManager.kt +19 -5
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/MarkerView.kt +319 -48
- package/android/src/main/java/expo/modules/gaodemap/map/overlays/MarkerViewModule.kt +3 -3
- package/build/index.d.ts +8 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +79 -1
- package/build/index.js.map +1 -1
- package/build/map/ExpoGaodeMapModule.d.ts +4 -4
- package/build/map/ExpoGaodeMapModule.d.ts.map +1 -1
- package/build/map/ExpoGaodeMapModule.js +10 -8
- package/build/map/ExpoGaodeMapModule.js.map +1 -1
- package/build/map/ExpoGaodeMapView.d.ts.map +1 -1
- package/build/map/ExpoGaodeMapView.js +79 -17
- package/build/map/ExpoGaodeMapView.js.map +1 -1
- package/build/map/components/overlays/Cluster.d.ts.map +1 -1
- package/build/map/components/overlays/Cluster.js +12 -0
- package/build/map/components/overlays/Cluster.js.map +1 -1
- package/build/map/components/overlays/Marker.d.ts.map +1 -1
- package/build/map/components/overlays/Marker.js +70 -6
- package/build/map/components/overlays/Marker.js.map +1 -1
- package/build/map/types/common.types.d.ts +29 -5
- package/build/map/types/common.types.d.ts.map +1 -1
- package/build/map/types/common.types.js +5 -5
- package/build/map/types/common.types.js.map +1 -1
- package/build/map/types/index.d.ts +2 -1
- package/build/map/types/index.d.ts.map +1 -1
- package/build/map/types/index.js.map +1 -1
- package/build/map/types/location.types.d.ts +23 -0
- package/build/map/types/location.types.d.ts.map +1 -1
- package/build/map/types/location.types.js.map +1 -1
- package/build/map/types/map-view.types.d.ts +20 -22
- package/build/map/types/map-view.types.d.ts.map +1 -1
- package/build/map/types/map-view.types.js.map +1 -1
- package/build/map/types/overlays.types.d.ts +9 -2
- package/build/map/types/overlays.types.d.ts.map +1 -1
- package/build/map/types/overlays.types.js.map +1 -1
- package/build/map/types/route-playback.types.d.ts +12 -0
- package/build/map/types/route-playback.types.d.ts.map +1 -0
- package/build/map/types/route-playback.types.js +2 -0
- package/build/map/types/route-playback.types.js.map +1 -0
- package/build/types/route.types.d.ts +10 -1
- package/build/types/route.types.d.ts.map +1 -1
- package/build/types/route.types.js +2 -0
- package/build/types/route.types.js.map +1 -1
- package/ios/map/ExpoGaodeMapView.swift +151 -76
- package/ios/map/ExpoGaodeMapViewModule.swift +14 -1
- package/ios/map/managers/UIManager.swift +5 -4
- package/ios/map/overlays/ClusterView.swift +207 -147
- package/ios/map/overlays/ClusterViewModule.swift +5 -1
- package/ios/map/overlays/MarkerView.swift +214 -60
- package/ios/map/overlays/MarkerViewModule.swift +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import ExpoModulesCore
|
|
|
2
2
|
import AMapNaviKit
|
|
3
3
|
import MapKit
|
|
4
4
|
import CoreLocation
|
|
5
|
+
import QuartzCore
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* 高德地图视图组件
|
|
@@ -15,8 +16,8 @@ import CoreLocation
|
|
|
15
16
|
class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate, MAMultiPointOverlayRendererDelegate {
|
|
16
17
|
// MARK: - 属性
|
|
17
18
|
|
|
18
|
-
/// 地图类型 (
|
|
19
|
-
var mapType: Int =
|
|
19
|
+
/// 地图类型 (1:标准 2:卫星 3:夜间 4:导航 5:公交)
|
|
20
|
+
var mapType: Int = 1
|
|
20
21
|
/// 初始相机位置
|
|
21
22
|
var initialCameraPosition: [String: Any]?
|
|
22
23
|
/// 是否显示缩放控件
|
|
@@ -51,6 +52,19 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
|
|
|
51
52
|
var showsBuildings: Bool = false
|
|
52
53
|
/// 是否显示室内地图
|
|
53
54
|
var showsIndoorMap: Bool = false
|
|
55
|
+
/// 定位最小更新距离
|
|
56
|
+
var distanceFilter: CLLocationDistance = kCLDistanceFilterNone
|
|
57
|
+
/// 朝向最小更新角度
|
|
58
|
+
var headingFilter: CLLocationDegrees = kCLHeadingFilterNone
|
|
59
|
+
/// 相机移动事件节流间隔(毫秒)
|
|
60
|
+
var cameraEventThrottleMs: Int = 32 {
|
|
61
|
+
didSet {
|
|
62
|
+
if cameraEventThrottleMs == 0 {
|
|
63
|
+
cameraMoveDispatchWorkItem?.cancel()
|
|
64
|
+
cameraMoveDispatchWorkItem = nil
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
54
68
|
/// 自定义地图样式配置
|
|
55
69
|
var customMapStyleData: [String: Any]?
|
|
56
70
|
/// 是否启用国内外地图自动切换
|
|
@@ -59,6 +73,7 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
|
|
|
59
73
|
// MARK: - 事件派发器
|
|
60
74
|
|
|
61
75
|
let onMapPress = EventDispatcher()
|
|
76
|
+
let onPressPoi = EventDispatcher()
|
|
62
77
|
let onMapLongPress = EventDispatcher()
|
|
63
78
|
let onLoad = EventDispatcher()
|
|
64
79
|
let onLocation = EventDispatcher()
|
|
@@ -92,14 +107,10 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
|
|
|
92
107
|
|
|
93
108
|
// MARK: - 事件节流控制
|
|
94
109
|
|
|
95
|
-
/// 相机移动事件节流间隔(秒)
|
|
96
|
-
private let cameraMoveThrottleInterval: TimeInterval = 0.1
|
|
97
|
-
/// 上次触发相机移动事件的时间戳
|
|
98
|
-
private var lastCameraMoveTime: TimeInterval = 0
|
|
99
110
|
/// 缓存的相机移动事件数据
|
|
100
111
|
private var pendingCameraMoveData: [String: Any]?
|
|
101
|
-
|
|
102
|
-
private var
|
|
112
|
+
private var cameraMoveDispatchWorkItem: DispatchWorkItem?
|
|
113
|
+
private var lastCameraMoveDispatchTime: CFTimeInterval = 0
|
|
103
114
|
|
|
104
115
|
/// 缩放手势识别器(用于模拟惯性)
|
|
105
116
|
private var pinchGesture: UIPinchGestureRecognizer!
|
|
@@ -460,7 +471,7 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
|
|
|
460
471
|
return
|
|
461
472
|
}
|
|
462
473
|
|
|
463
|
-
uiManager.setMapType(
|
|
474
|
+
uiManager.setMapType(1)
|
|
464
475
|
uiManager.setShowsScale(showsScale)
|
|
465
476
|
uiManager.setShowsCompass(showsCompass)
|
|
466
477
|
uiManager.setZoomEnabled(isZoomEnabled)
|
|
@@ -468,6 +479,8 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
|
|
|
468
479
|
uiManager.setRotateEnabled(isRotateEnabled)
|
|
469
480
|
uiManager.setTiltEnabled(isTiltEnabled)
|
|
470
481
|
uiManager.setShowsUserLocation(showsUserLocation, followUser: followUserLocation)
|
|
482
|
+
mapView.distanceFilter = distanceFilter
|
|
483
|
+
mapView.headingFilter = headingFilter
|
|
471
484
|
}
|
|
472
485
|
|
|
473
486
|
/**
|
|
@@ -498,6 +511,8 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
|
|
|
498
511
|
uiManager.setShowsTraffic(showsTraffic)
|
|
499
512
|
uiManager.setShowsBuildings(showsBuildings)
|
|
500
513
|
uiManager.setShowsIndoorMap(showsIndoorMap)
|
|
514
|
+
mapView.distanceFilter = distanceFilter
|
|
515
|
+
mapView.headingFilter = headingFilter
|
|
501
516
|
if let customMapStyleData {
|
|
502
517
|
uiManager.setCustomMapStyle(customMapStyleData)
|
|
503
518
|
}
|
|
@@ -513,17 +528,20 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
|
|
|
513
528
|
*/
|
|
514
529
|
private func updateAppleMapStyle() {
|
|
515
530
|
switch mapType {
|
|
516
|
-
case
|
|
531
|
+
case 2: // 卫星
|
|
517
532
|
appleMapView.mapType = .satellite
|
|
518
533
|
appleMapView.overrideUserInterfaceStyle = .unspecified
|
|
519
|
-
case
|
|
534
|
+
case 3: // 夜间
|
|
520
535
|
// 苹果地图没有专门的夜间模式枚举,通过强制 Dark Mode 实现
|
|
521
536
|
appleMapView.mapType = .standard
|
|
522
537
|
appleMapView.overrideUserInterfaceStyle = .dark
|
|
523
|
-
case
|
|
538
|
+
case 4: // 导航
|
|
524
539
|
appleMapView.mapType = .standard
|
|
525
540
|
appleMapView.overrideUserInterfaceStyle = .unspecified
|
|
526
|
-
|
|
541
|
+
case 5: // 公交
|
|
542
|
+
appleMapView.mapType = .standard
|
|
543
|
+
appleMapView.overrideUserInterfaceStyle = .unspecified
|
|
544
|
+
default: // 标准 (1,兼容旧值 0)
|
|
527
545
|
appleMapView.mapType = .standard
|
|
528
546
|
// 标准模式下跟随系统,如果系统是深色则显示深色,否则浅色
|
|
529
547
|
appleMapView.overrideUserInterfaceStyle = .unspecified
|
|
@@ -895,10 +913,9 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
|
|
|
895
913
|
* 当视图从层级中移除并释放时自动调用
|
|
896
914
|
*/
|
|
897
915
|
deinit {
|
|
898
|
-
// 清理节流定时器
|
|
899
|
-
throttleTimer?.invalidate()
|
|
900
|
-
throttleTimer = nil
|
|
901
916
|
pendingCameraMoveData = nil
|
|
917
|
+
cameraMoveDispatchWorkItem?.cancel()
|
|
918
|
+
cameraMoveDispatchWorkItem = nil
|
|
902
919
|
if let privacyObserver {
|
|
903
920
|
NotificationCenter.default.removeObserver(privacyObserver)
|
|
904
921
|
}
|
|
@@ -948,6 +965,7 @@ class ExpoGaodeMapView: ExpoView, MAMapViewDelegate, UIGestureRecognizerDelegate
|
|
|
948
965
|
resolvedMapView.frame = bounds
|
|
949
966
|
resolvedMapView.delegate = self
|
|
950
967
|
resolvedMapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
968
|
+
resolvedMapView.touchPOIEnabled = true
|
|
951
969
|
|
|
952
970
|
mapView = resolvedMapView
|
|
953
971
|
super.addSubview(resolvedMapView)
|
|
@@ -1021,59 +1039,39 @@ extension ExpoGaodeMapView {
|
|
|
1021
1039
|
* 地图区域即将改变时触发 - 应用节流优化
|
|
1022
1040
|
*/
|
|
1023
1041
|
public func mapView(_ mapView: MAMapView, regionWillChangeAnimated animated: Bool) {
|
|
1024
|
-
//
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
"cameraPosition": cameraPosition,
|
|
1031
|
-
"latLngBounds": [
|
|
1032
|
-
"northeast": [
|
|
1033
|
-
"latitude": visibleRegion.center.latitude + visibleRegion.span.latitudeDelta / 2,
|
|
1034
|
-
"longitude": visibleRegion.center.longitude + visibleRegion.span.longitudeDelta / 2
|
|
1035
|
-
],
|
|
1036
|
-
"southwest": [
|
|
1037
|
-
"latitude": visibleRegion.center.latitude - visibleRegion.span.latitudeDelta / 2,
|
|
1038
|
-
"longitude": visibleRegion.center.longitude - visibleRegion.span.longitudeDelta / 2
|
|
1039
|
-
]
|
|
1040
|
-
]
|
|
1041
|
-
]
|
|
1042
|
-
|
|
1043
|
-
// 节流逻辑:0.1秒 内只触发一次
|
|
1044
|
-
if currentTime - lastCameraMoveTime >= cameraMoveThrottleInterval {
|
|
1045
|
-
// 超过节流时间,立即触发事件
|
|
1046
|
-
lastCameraMoveTime = currentTime
|
|
1047
|
-
onCameraMove(eventData)
|
|
1048
|
-
// 清除待处理的事件和定时器
|
|
1049
|
-
throttleTimer?.invalidate()
|
|
1050
|
-
throttleTimer = nil
|
|
1051
|
-
pendingCameraMoveData = nil
|
|
1052
|
-
} else {
|
|
1053
|
-
// 在节流时间内,缓存事件数据,使用定时器延迟触发
|
|
1054
|
-
pendingCameraMoveData = eventData
|
|
1055
|
-
throttleTimer?.invalidate()
|
|
1056
|
-
|
|
1057
|
-
let delay = cameraMoveThrottleInterval - (currentTime - lastCameraMoveTime)
|
|
1058
|
-
throttleTimer = Timer.scheduledTimer(withTimeInterval: delay, repeats: false) { [weak self] _ in
|
|
1059
|
-
guard let self = self, let data = self.pendingCameraMoveData else { return }
|
|
1060
|
-
self.lastCameraMoveTime = Date().timeIntervalSince1970
|
|
1061
|
-
self.onCameraMove(data)
|
|
1062
|
-
self.pendingCameraMoveData = nil
|
|
1063
|
-
self.throttleTimer = nil
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1042
|
+
// 保留代理实现,但不在这里分发 onCameraMove。
|
|
1043
|
+
// 持续移动过程应使用 mapViewRegionChanged。
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
public func mapViewRegionChanged(_ mapView: MAMapView) {
|
|
1047
|
+
dispatchCameraMoveEvent(buildCameraEventData(for: mapView))
|
|
1066
1048
|
}
|
|
1067
1049
|
|
|
1068
1050
|
/**
|
|
1069
1051
|
* 地图区域改变完成后触发
|
|
1070
1052
|
*/
|
|
1071
1053
|
public func mapView(_ mapView: MAMapView, regionDidChangeAnimated animated: Bool) {
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1054
|
+
flushPendingCameraMoveEvent()
|
|
1055
|
+
onCameraIdle(buildCameraEventData(for: mapView))
|
|
1056
|
+
|
|
1057
|
+
// 这里的 overlayViews 是 [UIView] 类型,可能包含 ClusterView
|
|
1058
|
+
for view in overlayViews {
|
|
1059
|
+
if let clusterView = view as? ClusterView {
|
|
1060
|
+
// 只有当 clusterView 依然在视图树中时才通知
|
|
1061
|
+
if clusterView.superview != nil && clusterView.window != nil {
|
|
1062
|
+
clusterView.mapRegionDidChange()
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1075
1066
|
|
|
1076
|
-
|
|
1067
|
+
handleMapviewRegionChange(mapView: mapView)
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
private func buildCameraEventData(for mapView: MAMapView) -> [String: Any] {
|
|
1071
|
+
let cameraPosition = cameraManager?.getCameraPosition() ?? [String: Any]()
|
|
1072
|
+
let visibleRegion = mapView.region
|
|
1073
|
+
|
|
1074
|
+
return [
|
|
1077
1075
|
"cameraPosition": cameraPosition,
|
|
1078
1076
|
"latLngBounds": [
|
|
1079
1077
|
"northeast": [
|
|
@@ -1085,25 +1083,60 @@ extension ExpoGaodeMapView {
|
|
|
1085
1083
|
"longitude": visibleRegion.center.longitude - visibleRegion.span.longitudeDelta / 2
|
|
1086
1084
|
]
|
|
1087
1085
|
]
|
|
1088
|
-
]
|
|
1086
|
+
]
|
|
1087
|
+
}
|
|
1089
1088
|
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1089
|
+
private func dispatchCameraMoveEvent(_ eventData: [String: Any]) {
|
|
1090
|
+
let throttleMs = max(cameraEventThrottleMs, 0)
|
|
1091
|
+
if throttleMs == 0 {
|
|
1092
|
+
pendingCameraMoveData = nil
|
|
1093
|
+
cameraMoveDispatchWorkItem?.cancel()
|
|
1094
|
+
cameraMoveDispatchWorkItem = nil
|
|
1095
|
+
lastCameraMoveDispatchTime = CACurrentMediaTime()
|
|
1096
|
+
onCameraMove(eventData)
|
|
1097
|
+
return
|
|
1098
1098
|
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1099
|
+
|
|
1100
|
+
pendingCameraMoveData = eventData
|
|
1101
|
+
|
|
1102
|
+
let now = CACurrentMediaTime()
|
|
1103
|
+
let throttleSeconds = Double(throttleMs) / 1000
|
|
1104
|
+
let elapsed = now - lastCameraMoveDispatchTime
|
|
1105
|
+
|
|
1106
|
+
if elapsed >= throttleSeconds {
|
|
1107
|
+
cameraMoveDispatchWorkItem?.cancel()
|
|
1108
|
+
cameraMoveDispatchWorkItem = nil
|
|
1109
|
+
flushPendingCameraMoveEvent(at: now)
|
|
1110
|
+
return
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
guard cameraMoveDispatchWorkItem == nil else {
|
|
1114
|
+
return
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
let delay = max(0, throttleSeconds - elapsed)
|
|
1118
|
+
let workItem = DispatchWorkItem { [weak self] in
|
|
1119
|
+
self?.cameraMoveDispatchWorkItem = nil
|
|
1120
|
+
self?.flushPendingCameraMoveEvent()
|
|
1121
|
+
}
|
|
1122
|
+
cameraMoveDispatchWorkItem = workItem
|
|
1123
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: workItem)
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
private func flushPendingCameraMoveEvent(at timestamp: CFTimeInterval = CACurrentMediaTime()) {
|
|
1127
|
+
guard let eventData = pendingCameraMoveData else {
|
|
1128
|
+
return
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
pendingCameraMoveData = nil
|
|
1132
|
+
lastCameraMoveDispatchTime = timestamp
|
|
1133
|
+
onCameraMove(eventData)
|
|
1101
1134
|
}
|
|
1102
1135
|
|
|
1103
1136
|
/**
|
|
1104
1137
|
* 地图单击事件
|
|
1105
1138
|
*/
|
|
1106
|
-
|
|
1139
|
+
private func handleGaodeMapTap(at coordinate: CLLocationCoordinate2D) {
|
|
1107
1140
|
// 如果正在处理 annotation 选择,跳过地图点击事件
|
|
1108
1141
|
if isHandlingAnnotationSelect {
|
|
1109
1142
|
isHandlingAnnotationSelect = false
|
|
@@ -1117,6 +1150,15 @@ extension ExpoGaodeMapView {
|
|
|
1117
1150
|
|
|
1118
1151
|
onMapPress(["latitude": coordinate.latitude, "longitude": coordinate.longitude])
|
|
1119
1152
|
}
|
|
1153
|
+
|
|
1154
|
+
public func mapView(_ mapView: MAMapView, didSingleTappedAtCoordinate coordinate: CLLocationCoordinate2D) {
|
|
1155
|
+
handleGaodeMapTap(at: coordinate)
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
// 兼容部分旧版 SDK/历史实现
|
|
1159
|
+
public func mapView(_ mapView: MAMapView, didSingleTappedAt coordinate: CLLocationCoordinate2D) {
|
|
1160
|
+
handleGaodeMapTap(at: coordinate)
|
|
1161
|
+
}
|
|
1120
1162
|
|
|
1121
1163
|
/**
|
|
1122
1164
|
* 检查点击位置是否在圆形内
|
|
@@ -1282,9 +1324,37 @@ extension ExpoGaodeMapView {
|
|
|
1282
1324
|
/**
|
|
1283
1325
|
* 地图长按事件
|
|
1284
1326
|
*/
|
|
1285
|
-
|
|
1327
|
+
private func handleGaodeMapLongPress(at coordinate: CLLocationCoordinate2D) {
|
|
1286
1328
|
onMapLongPress(["latitude": coordinate.latitude, "longitude": coordinate.longitude])
|
|
1287
1329
|
}
|
|
1330
|
+
|
|
1331
|
+
public func mapView(_ mapView: MAMapView, didLongPressedAtCoordinate coordinate: CLLocationCoordinate2D) {
|
|
1332
|
+
handleGaodeMapLongPress(at: coordinate)
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
// 兼容部分旧版 SDK/历史实现
|
|
1336
|
+
public func mapView(_ mapView: MAMapView, didLongPressedAt coordinate: CLLocationCoordinate2D) {
|
|
1337
|
+
handleGaodeMapLongPress(at: coordinate)
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
private func handleGaodePoiTouch(_ pois: [Any]?) {
|
|
1341
|
+
guard let touchedPoi = pois?.first as? MATouchPoi else {
|
|
1342
|
+
return
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
onPressPoi([
|
|
1346
|
+
"id": touchedPoi.uid ?? "",
|
|
1347
|
+
"name": touchedPoi.name ?? "",
|
|
1348
|
+
"position": [
|
|
1349
|
+
"latitude": touchedPoi.coordinate.latitude,
|
|
1350
|
+
"longitude": touchedPoi.coordinate.longitude
|
|
1351
|
+
]
|
|
1352
|
+
])
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
public func mapView(_ mapView: MAMapView!, didTouchPois pois: [Any]!) {
|
|
1356
|
+
handleGaodePoiTouch(pois)
|
|
1357
|
+
}
|
|
1288
1358
|
|
|
1289
1359
|
/**
|
|
1290
1360
|
* 创建标注视图
|
|
@@ -1360,7 +1430,12 @@ extension ExpoGaodeMapView {
|
|
|
1360
1430
|
* 标注点击事件
|
|
1361
1431
|
*/
|
|
1362
1432
|
public func mapView(_ mapView: MAMapView, didSelect view: MAAnnotationView) {
|
|
1363
|
-
guard let annotation = view.annotation
|
|
1433
|
+
guard let annotation = view.annotation else {
|
|
1434
|
+
return
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
if annotation.isKind(of: MAUserLocation.self) {
|
|
1438
|
+
mapView.deselectAnnotation(annotation, animated: false)
|
|
1364
1439
|
return
|
|
1365
1440
|
}
|
|
1366
1441
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ExpoModulesCore
|
|
2
2
|
import AMapNaviKit
|
|
3
|
+
import CoreLocation
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* 高德地图视图 Module
|
|
@@ -9,7 +10,7 @@ public class ExpoGaodeMapViewModule: Module {
|
|
|
9
10
|
Name("ExpoGaodeMapView")
|
|
10
11
|
|
|
11
12
|
View(ExpoGaodeMapView.self) {
|
|
12
|
-
Events("onMapPress", "onMapLongPress", "onLoad", "onLocation", "onCameraMove", "onCameraIdle")
|
|
13
|
+
Events("onMapPress", "onPressPoi", "onMapLongPress", "onLoad", "onLocation", "onCameraMove", "onCameraIdle")
|
|
13
14
|
|
|
14
15
|
Prop("mapType") { (view: ExpoGaodeMapView, type: Int) in
|
|
15
16
|
view.mapType = type
|
|
@@ -58,6 +59,14 @@ public class ExpoGaodeMapViewModule: Module {
|
|
|
58
59
|
Prop("myLocationEnabled") { (view: ExpoGaodeMapView, show: Bool) in
|
|
59
60
|
view.setShowsUserLocation(show)
|
|
60
61
|
}
|
|
62
|
+
|
|
63
|
+
Prop("distanceFilter") { (view: ExpoGaodeMapView, distance: Double?) in
|
|
64
|
+
view.distanceFilter = distance ?? kCLDistanceFilterNone
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
Prop("headingFilter") { (view: ExpoGaodeMapView, heading: Double?) in
|
|
68
|
+
view.headingFilter = heading ?? kCLHeadingFilterNone
|
|
69
|
+
}
|
|
61
70
|
|
|
62
71
|
Prop("followUserLocation") { (view: ExpoGaodeMapView, follow: Bool) in
|
|
63
72
|
view.setFollowUserLocation(follow)
|
|
@@ -88,6 +97,10 @@ public class ExpoGaodeMapViewModule: Module {
|
|
|
88
97
|
Prop("worldMapSwitchEnabled") { (view: ExpoGaodeMapView, enabled: Bool) in
|
|
89
98
|
view.enableWorldMapSwitch = enabled
|
|
90
99
|
}
|
|
100
|
+
|
|
101
|
+
Prop("cameraEventThrottleMs") { (view: ExpoGaodeMapView, throttleMs: Int?) in
|
|
102
|
+
view.cameraEventThrottleMs = max(throttleMs ?? 32, 0)
|
|
103
|
+
}
|
|
91
104
|
|
|
92
105
|
OnViewDidUpdateProps { (view: ExpoGaodeMapView) in
|
|
93
106
|
view.applyProps()
|
|
@@ -29,14 +29,15 @@ class UIManager: NSObject, MAMapViewDelegate {
|
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* 设置地图类型
|
|
32
|
-
* @param type
|
|
32
|
+
* @param type 1:标准 2:卫星 3:夜间 4:导航 5:公交
|
|
33
33
|
*/
|
|
34
34
|
func setMapType(_ type: Int) {
|
|
35
35
|
guard let mapView = mapView else { return }
|
|
36
36
|
switch type {
|
|
37
|
-
case
|
|
38
|
-
case
|
|
39
|
-
case
|
|
37
|
+
case 2: mapView.mapType = .satellite
|
|
38
|
+
case 3: mapView.mapType = .standardNight
|
|
39
|
+
case 4: mapView.mapType = .navi
|
|
40
|
+
case 5: mapView.mapType = .bus
|
|
40
41
|
default: mapView.mapType = .standard
|
|
41
42
|
}
|
|
42
43
|
|