|
|
@@ -47,10 +47,19 @@ struct ATMapPadding: Codable {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 定义线的类型枚举
|
|
|
+enum PolylineType: String, Codable {
|
|
|
+ case solid // 实线
|
|
|
+ case dashed // 虚线
|
|
|
+ case dotted // 点线
|
|
|
+ case mixed // 混合样式
|
|
|
+}
|
|
|
+
|
|
|
class ATMapPolyline: NSObject, Codable {
|
|
|
var id: String = UUID().uuidString
|
|
|
+ var lineId: String // 新增:用于记录的线ID
|
|
|
+ var lineType: PolylineType // 新增:用于记录线的样式
|
|
|
var points: [CLLocationCoordinate2D]
|
|
|
-
|
|
|
var mapPadding: ATMapPadding?
|
|
|
|
|
|
var polyline: MKPolyline {
|
|
|
@@ -58,12 +67,14 @@ class ATMapPolyline: NSObject, Codable {
|
|
|
}
|
|
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
|
- case points, mapPadding
|
|
|
+ case lineId, lineType, points, mapPadding
|
|
|
}
|
|
|
|
|
|
required init(from decoder: Decoder) throws {
|
|
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
|
|
|
|
+ lineId = try container.decode(String.self, forKey: .lineId)
|
|
|
+ lineType = try container.decode(PolylineType.self, forKey: .lineType)
|
|
|
points = try container.decode([CLLocationCoordinate2D].self, forKey: .points)
|
|
|
|
|
|
if container.contains(.mapPadding) {
|
|
|
@@ -73,11 +84,23 @@ class ATMapPolyline: NSObject, Codable {
|
|
|
|
|
|
func encode(to encoder: Encoder) throws {
|
|
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
|
+ try container.encode(lineId, forKey: .lineId)
|
|
|
+ try container.encode(lineType, forKey: .lineType)
|
|
|
try container.encode(points, forKey: .points)
|
|
|
try container.encodeIfPresent(mapPadding, forKey: .mapPadding)
|
|
|
}
|
|
|
+
|
|
|
+ // 初始化方法
|
|
|
+ init(lineId: String, lineType: PolylineType, points: [CLLocationCoordinate2D], mapPadding: ATMapPadding? = nil) {
|
|
|
+ self.lineId = lineId
|
|
|
+ self.lineType = lineType
|
|
|
+ self.points = points
|
|
|
+ self.mapPadding = mapPadding
|
|
|
+ super.init()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
class ATMapMarker: NSObject, Codable {
|
|
|
var id: String
|
|
|
var markerName: String?
|