expo-gaode-map 0.1.6 → 1.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.
Files changed (50) hide show
  1. package/PUBLISHING.md +1 -1
  2. package/README.md +57 -9
  3. package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapModule.kt +117 -26
  4. package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapView.kt +97 -36
  5. package/android/src/main/java/expo/modules/gaodemap/managers/CameraManager.kt +27 -21
  6. package/android/src/main/java/expo/modules/gaodemap/managers/OverlayManager.kt +4 -23
  7. package/android/src/main/java/expo/modules/gaodemap/managers/UIManager.kt +30 -27
  8. package/android/src/main/java/expo/modules/gaodemap/modules/LocationManager.kt +49 -4
  9. package/android/src/main/java/expo/modules/gaodemap/modules/SDKInitializer.kt +13 -5
  10. package/android/src/main/java/expo/modules/gaodemap/overlays/CircleView.kt +0 -6
  11. package/build/ExpoGaodeMapView.js +2 -2
  12. package/build/ExpoGaodeMapView.js.map +1 -1
  13. package/build/index.d.ts +2 -0
  14. package/build/index.d.ts.map +1 -1
  15. package/build/index.js +3 -1
  16. package/build/index.js.map +1 -1
  17. package/build/modules/AMapPermissions.d.ts +27 -0
  18. package/build/modules/AMapPermissions.d.ts.map +1 -0
  19. package/build/modules/AMapPermissions.js +31 -0
  20. package/build/modules/AMapPermissions.js.map +1 -0
  21. package/build/modules/AMapView.d.ts +7 -2
  22. package/build/modules/AMapView.d.ts.map +1 -1
  23. package/build/modules/AMapView.js +15 -3
  24. package/build/modules/AMapView.js.map +1 -1
  25. package/build/types/common.types.d.ts +1 -0
  26. package/build/types/common.types.d.ts.map +1 -1
  27. package/build/types/common.types.js +1 -0
  28. package/build/types/common.types.js.map +1 -1
  29. package/docs/API.md +5 -1
  30. package/docs/ARCHITECTURE.md +421 -0
  31. package/docs/EXAMPLES.md +166 -24
  32. package/docs/INITIALIZATION.md +342 -0
  33. package/ios/ExpoGaodeMapModule.swift +95 -9
  34. package/ios/ExpoGaodeMapView.swift +88 -6
  35. package/ios/managers/CameraManager.swift +58 -0
  36. package/ios/managers/OverlayManager.swift +105 -29
  37. package/ios/managers/UIManager.swift +73 -1
  38. package/ios/modules/LocationManager.swift +109 -3
  39. package/ios/overlays/CircleView.swift +53 -0
  40. package/ios/overlays/HeatMapView.swift +27 -0
  41. package/ios/overlays/MarkerView.swift +29 -1
  42. package/ios/overlays/PolygonView.swift +51 -0
  43. package/ios/overlays/PolylineView.swift +61 -14
  44. package/ios/utils/PermissionManager.swift +58 -0
  45. package/package.json +1 -1
  46. package/src/ExpoGaodeMapView.tsx +2 -2
  47. package/src/index.ts +9 -1
  48. package/src/modules/AMapPermissions.ts +48 -0
  49. package/src/modules/AMapView.ts +15 -3
  50. package/src/types/common.types.ts +1 -0
@@ -1,49 +1,100 @@
1
1
  import MAMapKit
2
2
 
3
+ /**
4
+ * UI 和手势管理器
5
+ *
6
+ * 负责:
7
+ * - 地图类型设置
8
+ * - 控件显示控制
9
+ * - 手势交互控制
10
+ * - 图层显示管理
11
+ * - 用户位置样式配置
12
+ */
3
13
  class UIManager {
14
+ /// 弱引用地图视图,避免循环引用
4
15
  private weak var mapView: MAMapView?
5
16
 
6
17
  init(mapView: MAMapView) {
7
18
  self.mapView = mapView
8
19
  }
9
20
 
21
+ // MARK: - 地图类型
22
+
23
+ /**
24
+ * 设置地图类型
25
+ * @param type 0:标准 1:卫星 2:夜间 3:导航
26
+ */
10
27
  func setMapType(_ type: Int) {
11
28
  guard let mapView = mapView else { return }
12
29
  switch type {
13
30
  case 1: mapView.mapType = .satellite
14
31
  case 2: mapView.mapType = .standardNight
32
+ case 3: mapView.mapType = .navi
15
33
  default: mapView.mapType = .standard
16
34
  }
17
35
  }
18
36
 
37
+ // MARK: - 控件显示
38
+
39
+ /**
40
+ * 设置是否显示缩放控件
41
+ * iOS 高德地图不支持缩放控件
42
+ */
19
43
  func setShowsZoomControls(_ show: Bool) {
20
- // iOS 高德地图不支持缩放控件
44
+ // iOS 不支持
21
45
  }
22
46
 
47
+ /**
48
+ * 设置是否显示指南针
49
+ */
23
50
  func setShowsCompass(_ show: Bool) {
24
51
  mapView?.showsCompass = show
25
52
  }
26
53
 
54
+ /**
55
+ * 设置是否显示比例尺
56
+ */
27
57
  func setShowsScale(_ show: Bool) {
28
58
  mapView?.showsScale = show
29
59
  }
30
60
 
61
+ // MARK: - 手势控制
62
+
63
+ /**
64
+ * 设置是否启用缩放手势
65
+ */
31
66
  func setZoomEnabled(_ enabled: Bool) {
32
67
  mapView?.isZoomEnabled = enabled
33
68
  }
34
69
 
70
+ /**
71
+ * 设置是否启用滚动手势
72
+ */
35
73
  func setScrollEnabled(_ enabled: Bool) {
36
74
  mapView?.isScrollEnabled = enabled
37
75
  }
38
76
 
77
+ /**
78
+ * 设置是否启用旋转手势
79
+ */
39
80
  func setRotateEnabled(_ enabled: Bool) {
40
81
  mapView?.isRotateEnabled = enabled
41
82
  }
42
83
 
84
+ /**
85
+ * 设置是否启用倾斜手势
86
+ */
43
87
  func setTiltEnabled(_ enabled: Bool) {
44
88
  mapView?.isRotateCameraEnabled = enabled
45
89
  }
46
90
 
91
+ // MARK: - 用户位置
92
+
93
+ /**
94
+ * 设置是否显示用户位置
95
+ * @param show 是否显示
96
+ * @param followUser 是否跟随用户
97
+ */
47
98
  func setShowsUserLocation(_ show: Bool, followUser: Bool) {
48
99
  guard let mapView = mapView else { return }
49
100
  mapView.showsUserLocation = show
@@ -54,6 +105,10 @@ class UIManager {
54
105
  }
55
106
  }
56
107
 
108
+ /**
109
+ * 设置用户位置样式
110
+ * @param config 样式配置字典
111
+ */
57
112
  func setUserLocationRepresentation(_ config: [String: Any]) {
58
113
  guard let mapView = mapView else { return }
59
114
  let representation = MAUserLocationRepresentation()
@@ -142,6 +197,12 @@ class UIManager {
142
197
  mapView.update(representation)
143
198
  }
144
199
 
200
+ /**
201
+ * 调整图片大小
202
+ * @param image 原始图片
203
+ * @param targetSize 目标大小
204
+ * @return 调整后的图片
205
+ */
145
206
  private func resizeImage(_ image: UIImage, targetSize: CGSize) -> UIImage {
146
207
  let renderer = UIGraphicsImageRenderer(size: targetSize)
147
208
  return renderer.image { _ in
@@ -149,14 +210,25 @@ class UIManager {
149
210
  }
150
211
  }
151
212
 
213
+ // MARK: - 图层显示
214
+
215
+ /**
216
+ * 设置是否显示交通路况
217
+ */
152
218
  func setShowsTraffic(_ show: Bool) {
153
219
  mapView?.isShowTraffic = show
154
220
  }
155
221
 
222
+ /**
223
+ * 设置是否显示建筑物
224
+ */
156
225
  func setShowsBuildings(_ show: Bool) {
157
226
  mapView?.isShowsBuildings = show
158
227
  }
159
228
 
229
+ /**
230
+ * 设置是否显示室内地图
231
+ */
160
232
  func setShowsIndoorMap(_ show: Bool) {
161
233
  mapView?.isShowsIndoorMap = show
162
234
  }
@@ -2,10 +2,23 @@ import Foundation
2
2
  import AMapLocationKit
3
3
  import CoreLocation
4
4
 
5
+ /**
6
+ * 定位管理器
7
+ *
8
+ * 负责:
9
+ * - 连续定位和单次定位
10
+ * - 定位配置管理
11
+ * - 方向传感器管理
12
+ * - 定位结果回调
13
+ */
5
14
  class LocationManager: NSObject, AMapLocationManagerDelegate {
15
+ /// 高德定位管理器实例
6
16
  var locationManager: AMapLocationManager?
17
+ /// 定位是否已启动
7
18
  private var isLocationStarted = false
19
+ /// 定位更新回调
8
20
  var onLocationUpdate: (([String: Any]) -> Void)?
21
+ /// 方向更新回调
9
22
  var onHeadingUpdate: (([String: Any]) -> Void)?
10
23
 
11
24
  override init() {
@@ -13,36 +26,76 @@ class LocationManager: NSObject, AMapLocationManagerDelegate {
13
26
  initLocationManager()
14
27
  }
15
28
 
29
+ // MARK: - 定位控制
30
+
31
+ /**
32
+ * 开始连续定位
33
+ */
16
34
  func start() {
17
35
  locationManager?.startUpdatingLocation()
18
36
  isLocationStarted = true
19
37
  }
20
38
 
39
+ /**
40
+ * 停止定位
41
+ */
21
42
  func stop() {
22
43
  locationManager?.stopUpdatingLocation()
23
44
  isLocationStarted = false
24
45
  }
25
46
 
47
+ /**
48
+ * 检查定位是否已启动
49
+ * @return 是否正在定位
50
+ */
26
51
  func isStarted() -> Bool {
27
52
  return isLocationStarted
28
53
  }
29
54
 
55
+ // MARK: - 定位配置
56
+
57
+ /**
58
+ * 设置是否返回逆地理信息
59
+ * @param isReGeocode 是否返回逆地理信息
60
+ */
30
61
  func setLocatingWithReGeocode(_ isReGeocode: Bool) {
31
62
  locationManager?.locatingWithReGeocode = isReGeocode
32
63
  }
33
64
 
65
+ /**
66
+ * 设置定位距离过滤器(米)
67
+ * @param distance 最小距离变化才触发定位更新
68
+ */
34
69
  func setDistanceFilter(_ distance: Double) {
35
70
  locationManager?.distanceFilter = distance
36
71
  }
37
72
 
73
+ /**
74
+ * 设置定位超时时间(秒)
75
+ * @param timeout 超时时间
76
+ */
38
77
  func setLocationTimeout(_ timeout: Int) {
39
78
  locationManager?.locationTimeout = timeout
40
79
  }
41
80
 
81
+ /**
82
+ * 设置逆地理超时时间(秒)
83
+ * @param timeout 超时时间
84
+ */
42
85
  func setReGeocodeTimeout(_ timeout: Int) {
43
86
  locationManager?.reGeocodeTimeout = timeout
44
87
  }
45
88
 
89
+ /**
90
+ * 设置定位精度
91
+ * @param accuracy 精度级别
92
+ * - 0: 最适合导航
93
+ * - 1: 最佳精度
94
+ * - 2: 10米精度
95
+ * - 3: 100米精度
96
+ * - 4: 1公里精度
97
+ * - 5: 3公里精度
98
+ */
46
99
  func setDesiredAccuracy(_ accuracy: Int) {
47
100
  let accuracyValue: CLLocationAccuracy
48
101
  switch accuracy {
@@ -57,13 +110,29 @@ class LocationManager: NSObject, AMapLocationManagerDelegate {
57
110
  locationManager?.desiredAccuracy = accuracyValue
58
111
  }
59
112
 
113
+ /**
114
+ * 设置是否自动暂停定位更新
115
+ * @param pauses 是否自动暂停
116
+ */
60
117
  func setPausesLocationUpdatesAutomatically(_ pauses: Bool) {
61
118
  locationManager?.pausesLocationUpdatesAutomatically = pauses
62
119
  }
63
120
 
121
+ /**
122
+ * 设置是否允许后台定位
123
+ * @param allows 是否允许后台定位
124
+ */
64
125
  func setAllowsBackgroundLocationUpdates(_ allows: Bool) {
65
126
  locationManager?.allowsBackgroundLocationUpdates = allows
66
127
  }
128
+
129
+ /**
130
+ * 设置逆地理语言
131
+ * @param language 语言类型
132
+ * - 0: 默认
133
+ * - 1: 中文
134
+ * - 2: 英文
135
+ */
67
136
  func setGeoLanguage(_ language: Int) {
68
137
  switch language {
69
138
  case 0: locationManager?.reGeocodeLanguage = .default
@@ -73,32 +142,53 @@ class LocationManager: NSObject, AMapLocationManagerDelegate {
73
142
  }
74
143
  }
75
144
 
145
+ // MARK: - 方向传感器
76
146
 
147
+ /**
148
+ * 开始更新设备方向
149
+ */
77
150
  func startUpdatingHeading() {
78
151
  locationManager?.startUpdatingHeading()
79
152
  }
80
153
 
154
+ /**
155
+ * 停止更新设备方向
156
+ */
81
157
  func stopUpdatingHeading() {
82
158
  locationManager?.stopUpdatingHeading()
83
159
  }
84
160
 
161
+ // MARK: - 生命周期
162
+
163
+ /**
164
+ * 销毁定位管理器
165
+ */
85
166
  func destroy() {
86
167
  locationManager?.stopUpdatingLocation()
87
168
  locationManager = nil
88
169
  }
89
170
 
171
+ /**
172
+ * 初始化定位管理器
173
+ */
90
174
  private func initLocationManager() {
91
175
  locationManager = AMapLocationManager()
92
176
  locationManager?.delegate = self
93
177
  locationManager?.desiredAccuracy = kCLLocationAccuracyBest
94
178
  locationManager?.distanceFilter = 10
95
- locationManager?.locationTimeout = 2
96
- locationManager?.reGeocodeTimeout = 2
179
+ locationManager?.locationTimeout = 1
180
+ locationManager?.reGeocodeTimeout = 1
97
181
  locationManager?.locatingWithReGeocode = true
98
182
  }
99
183
 
100
184
  // MARK: - AMapLocationManagerDelegate
101
185
 
186
+ /**
187
+ * 定位更新回调
188
+ * @param manager 定位管理器
189
+ * @param location 位置信息
190
+ * @param reGeocode 逆地理信息
191
+ */
102
192
  func amapLocationManager(_ manager: AMapLocationManager!, didUpdate location: CLLocation!, reGeocode: AMapLocationReGeocode!) {
103
193
  var locationData: [String: Any] = [
104
194
  "latitude": location.coordinate.latitude,
@@ -110,6 +200,7 @@ class LocationManager: NSObject, AMapLocationManagerDelegate {
110
200
  "timestamp": location.timestamp.timeIntervalSince1970 * 1000
111
201
  ]
112
202
 
203
+ // 添加逆地理信息
113
204
  if let reGeocode = reGeocode {
114
205
  locationData["address"] = reGeocode.formattedAddress
115
206
  locationData["province"] = reGeocode.province
@@ -125,6 +216,11 @@ class LocationManager: NSObject, AMapLocationManagerDelegate {
125
216
  onLocationUpdate?(locationData)
126
217
  }
127
218
 
219
+ /**
220
+ * 方向更新回调
221
+ * @param manager 定位管理器
222
+ * @param heading 方向信息
223
+ */
128
224
  func amapLocationManager(_ manager: AMapLocationManager!, didUpdate heading: CLHeading!) {
129
225
  let headingData: [String: Any] = [
130
226
  "heading": heading.trueHeading,
@@ -134,11 +230,21 @@ class LocationManager: NSObject, AMapLocationManagerDelegate {
134
230
  onHeadingUpdate?(headingData)
135
231
  }
136
232
 
233
+ /**
234
+ * 需要定位权限回调
235
+ * @param manager 定位管理器
236
+ * @param locationManager 系统定位管理器
237
+ */
137
238
  func amapLocationManager(_ manager: AMapLocationManager!, doRequireLocationAuth locationManager: CLLocationManager!) {
138
239
  locationManager.requestAlwaysAuthorization()
139
240
  }
140
241
 
242
+ /**
243
+ * 定位失败回调
244
+ * @param manager 定位管理器
245
+ * @param error 错误信息
246
+ */
141
247
  func amapLocationManager(_ manager: AMapLocationManager!, didFailWithError error: Error!) {
142
- print("定位失败: \(error.localizedDescription)")
248
+ // 定位失败 - 静默处理
143
249
  }
144
250
  }
@@ -1,15 +1,31 @@
1
1
  import ExpoModulesCore
2
2
  import MAMapKit
3
3
 
4
+ /**
5
+ * 圆形覆盖物视图
6
+ *
7
+ * 负责:
8
+ * - 在地图上绘制圆形
9
+ * - 管理圆形的样式(填充色、边框色、边框宽度)
10
+ * - 响应属性变化并更新渲染
11
+ */
4
12
  class CircleView: ExpoView {
13
+ /// 圆心坐标
5
14
  var circleCenter: [String: Double] = [:]
15
+ /// 半径(米)
6
16
  var radius: Double = 0
17
+ /// 填充颜色
7
18
  var fillColor: Any?
19
+ /// 边框颜色
8
20
  var strokeColor: Any?
21
+ /// 边框宽度
9
22
  var strokeWidth: Float = 0
10
23
 
24
+ /// 地图视图弱引用
11
25
  private var mapView: MAMapView?
26
+ /// 圆形覆盖物对象
12
27
  var circle: MACircle?
28
+ /// 圆形渲染器
13
29
  private var renderer: MACircleRenderer?
14
30
 
15
31
  required init(appContext: AppContext? = nil) {
@@ -17,6 +33,10 @@ class CircleView: ExpoView {
17
33
  circle = MACircle()
18
34
  }
19
35
 
36
+ /**
37
+ * 设置地图实例
38
+ * @param map 地图视图
39
+ */
20
40
  func setMap(_ map: MAMapView) {
21
41
  self.mapView = map
22
42
  if let circle = circle {
@@ -24,6 +44,9 @@ class CircleView: ExpoView {
24
44
  }
25
45
  }
26
46
 
47
+ /**
48
+ * 更新圆形覆盖物
49
+ */
27
50
  private func updateCircle() {
28
51
  guard let latitude = circleCenter["latitude"],
29
52
  let longitude = circleCenter["longitude"] else { return }
@@ -31,6 +54,10 @@ class CircleView: ExpoView {
31
54
  circle?.radius = radius
32
55
  }
33
56
 
57
+ /**
58
+ * 获取圆形渲染器
59
+ * @return 渲染器实例
60
+ */
34
61
  func getRenderer() -> MAOverlayRenderer {
35
62
  if renderer == nil, let circle = circle {
36
63
  renderer = MACircleRenderer(circle: circle)
@@ -43,6 +70,7 @@ class CircleView: ExpoView {
43
70
 
44
71
  /**
45
72
  * 设置中心点
73
+ * @param center 中心点坐标 {latitude, longitude}
46
74
  */
47
75
  func setCenter(_ center: [String: Double]) {
48
76
  circleCenter = center
@@ -50,27 +78,52 @@ class CircleView: ExpoView {
50
78
  updateCircle()
51
79
  }
52
80
 
81
+ /**
82
+ * 设置半径
83
+ * @param radius 半径(米)
84
+ */
53
85
  func setRadius(_ radius: Double) {
54
86
  self.radius = radius
55
87
  renderer = nil
56
88
  updateCircle()
57
89
  }
58
90
 
91
+ /**
92
+ * 设置填充颜色
93
+ * @param color 颜色值
94
+ */
59
95
  func setFillColor(_ color: Any?) {
60
96
  fillColor = color
61
97
  renderer = nil
62
98
  updateCircle()
63
99
  }
64
100
 
101
+ /**
102
+ * 设置边框颜色
103
+ * @param color 颜色值
104
+ */
65
105
  func setStrokeColor(_ color: Any?) {
66
106
  strokeColor = color
67
107
  renderer = nil
68
108
  updateCircle()
69
109
  }
70
110
 
111
+ /**
112
+ * 设置边框宽度
113
+ * @param width 宽度值
114
+ */
71
115
  func setStrokeWidth(_ width: Float) {
72
116
  strokeWidth = width
73
117
  renderer = nil
74
118
  updateCircle()
75
119
  }
120
+
121
+ /**
122
+ * 析构时移除圆形
123
+ */
124
+ deinit {
125
+ if let mapView = mapView, let circle = circle {
126
+ mapView.remove(circle)
127
+ }
128
+ }
76
129
  }
@@ -1,12 +1,25 @@
1
1
  import ExpoModulesCore
2
2
  import MAMapKit
3
3
 
4
+ /**
5
+ * 热力图视图
6
+ *
7
+ * 负责:
8
+ * - 在地图上显示热力图
9
+ * - 管理热力图数据和样式
10
+ * - 支持半径和透明度配置
11
+ */
4
12
  class HeatMapView: ExpoView {
13
+ /// 热力图数据点数组
5
14
  var data: [[String: Any]] = []
15
+ /// 热力图半径
6
16
  var radius: Int = 50
17
+ /// 透明度
7
18
  var opacity: Double = 0.6
8
19
 
20
+ /// 地图视图弱引用
9
21
  private var mapView: MAMapView?
22
+ /// 热力图图层
10
23
  private var heatmapOverlay: MAHeatMapTileOverlay?
11
24
 
12
25
  required init(appContext: AppContext? = nil) {
@@ -15,6 +28,7 @@ class HeatMapView: ExpoView {
15
28
 
16
29
  /**
17
30
  * 设置地图实例
31
+ * @param map 地图视图
18
32
  */
19
33
  func setMap(_ map: MAMapView) {
20
34
  self.mapView = map
@@ -23,6 +37,7 @@ class HeatMapView: ExpoView {
23
37
 
24
38
  /**
25
39
  * 设置热力图数据
40
+ * @param data 数据点数组,每个点包含 latitude、longitude
26
41
  */
27
42
  func setData(_ data: [[String: Any]]) {
28
43
  self.data = data
@@ -31,6 +46,7 @@ class HeatMapView: ExpoView {
31
46
 
32
47
  /**
33
48
  * 设置热力图半径
49
+ * @param radius 半径值(像素)
34
50
  */
35
51
  func setRadius(_ radius: Int) {
36
52
  self.radius = radius
@@ -39,6 +55,7 @@ class HeatMapView: ExpoView {
39
55
 
40
56
  /**
41
57
  * 设置透明度
58
+ * @param opacity 透明度值 (0.0-1.0)
42
59
  */
43
60
  func setOpacity(_ opacity: Double) {
44
61
  self.opacity = opacity
@@ -91,8 +108,18 @@ class HeatMapView: ExpoView {
91
108
  heatmapOverlay = nil
92
109
  }
93
110
 
111
+ /**
112
+ * 从父视图移除时清理热力图
113
+ */
94
114
  override func removeFromSuperview() {
95
115
  super.removeFromSuperview()
96
116
  removeHeatMap()
97
117
  }
118
+
119
+ /**
120
+ * 析构时移除热力图
121
+ */
122
+ deinit {
123
+ removeHeatMap()
124
+ }
98
125
  }
@@ -1,13 +1,27 @@
1
1
  import ExpoModulesCore
2
2
  import MAMapKit
3
3
 
4
+ /**
5
+ * 标记点视图
6
+ *
7
+ * 负责:
8
+ * - 在地图上显示标记点
9
+ * - 管理标记点属性(位置、标题、描述)
10
+ * - 支持拖拽功能
11
+ */
4
12
  class MarkerView: ExpoView {
13
+ /// 标记点位置
5
14
  var position: [String: Double] = [:]
15
+ /// 标题
6
16
  var title: String = ""
17
+ /// 描述
7
18
  var markerDescription: String = ""
19
+ /// 是否可拖拽
8
20
  var draggable: Bool = false
9
21
 
22
+ /// 地图视图弱引用
10
23
  private var mapView: MAMapView?
24
+ /// 标记点对象
11
25
  private var annotation: MAPointAnnotation?
12
26
 
13
27
  required init(appContext: AppContext? = nil) {
@@ -16,6 +30,7 @@ class MarkerView: ExpoView {
16
30
 
17
31
  /**
18
32
  * 设置地图实例
33
+ * @param map 地图视图
19
34
  */
20
35
  func setMap(_ map: MAMapView) {
21
36
  self.mapView = map
@@ -23,7 +38,7 @@ class MarkerView: ExpoView {
23
38
  }
24
39
 
25
40
  /**
26
- * 更新标记
41
+ * 更新标记点
27
42
  */
28
43
  private func updateAnnotation() {
29
44
  guard let mapView = mapView,
@@ -49,6 +64,7 @@ class MarkerView: ExpoView {
49
64
 
50
65
  /**
51
66
  * 设置位置
67
+ * @param position 位置坐标 {latitude, longitude}
52
68
  */
53
69
  func setPosition(_ position: [String: Double]) {
54
70
  self.position = position
@@ -57,6 +73,7 @@ class MarkerView: ExpoView {
57
73
 
58
74
  /**
59
75
  * 设置标题
76
+ * @param title 标题文本
60
77
  */
61
78
  func setTitle(_ title: String) {
62
79
  self.title = title
@@ -65,6 +82,7 @@ class MarkerView: ExpoView {
65
82
 
66
83
  /**
67
84
  * 设置描述
85
+ * @param description 描述文本
68
86
  */
69
87
  func setDescription(_ description: String) {
70
88
  self.markerDescription = description
@@ -73,9 +91,19 @@ class MarkerView: ExpoView {
73
91
 
74
92
  /**
75
93
  * 设置是否可拖拽
94
+ * @param draggable 是否可拖拽
76
95
  */
77
96
  func setDraggable(_ draggable: Bool) {
78
97
  self.draggable = draggable
79
98
  // iOS 高德地图标记默认不可拖拽,需要自定义实现
80
99
  }
100
+
101
+ /**
102
+ * 析构时移除标记点
103
+ */
104
+ deinit {
105
+ if let mapView = mapView, let annotation = annotation {
106
+ mapView.removeAnnotation(annotation)
107
+ }
108
+ }
81
109
  }