|
@@ -47,35 +47,31 @@ struct ATMapPadding: Codable {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 定义线的类型枚举
|
|
|
|
|
-enum PolylineType: String, Codable {
|
|
|
|
|
- case solid // 实线
|
|
|
|
|
- case dashed // 虚线
|
|
|
|
|
- case dotted // 点线
|
|
|
|
|
- case mixed // 混合样式
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
class ATMapPolyline: NSObject, Codable {
|
|
class ATMapPolyline: NSObject, Codable {
|
|
|
var id: String = UUID().uuidString
|
|
var id: String = UUID().uuidString
|
|
|
- var lineId: String // 新增:用于记录的线ID
|
|
|
|
|
- var lineType: PolylineType // 新增:用于记录线的样式
|
|
|
|
|
|
|
+ var lineId: String // 新增:用于记录的线ID
|
|
|
|
|
+ var lineType: String // 新增:用于记录线的样式 normal error selected color
|
|
|
var points: [CLLocationCoordinate2D]
|
|
var points: [CLLocationCoordinate2D]
|
|
|
var mapPadding: ATMapPadding?
|
|
var mapPadding: ATMapPadding?
|
|
|
|
|
+ var color : String ///轨迹的颜色
|
|
|
|
|
+ var width: Double /// 轨迹的宽度
|
|
|
|
|
|
|
|
var polyline: MKPolyline {
|
|
var polyline: MKPolyline {
|
|
|
return MKPolyline(coordinates: points, count: points.count)
|
|
return MKPolyline(coordinates: points, count: points.count)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
enum CodingKeys: String, CodingKey {
|
|
|
- case lineId, lineType, points, mapPadding
|
|
|
|
|
|
|
+ case lineId, lineType, points, mapPadding,color,width
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
required init(from decoder: Decoder) throws {
|
|
required init(from decoder: Decoder) throws {
|
|
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
|
|
|
|
|
|
lineId = try container.decode(String.self, forKey: .lineId)
|
|
lineId = try container.decode(String.self, forKey: .lineId)
|
|
|
- lineType = try container.decode(PolylineType.self, forKey: .lineType)
|
|
|
|
|
|
|
+ lineType = try container.decode(String.self, forKey: .lineType)
|
|
|
points = try container.decode([CLLocationCoordinate2D].self, forKey: .points)
|
|
points = try container.decode([CLLocationCoordinate2D].self, forKey: .points)
|
|
|
|
|
+ color = try container.decode(String.self, forKey:.color)
|
|
|
|
|
+ width = try container.decode(Double.self, forKey: .width)
|
|
|
|
|
|
|
|
if container.contains(.mapPadding) {
|
|
if container.contains(.mapPadding) {
|
|
|
mapPadding = try container.decodeIfPresent(ATMapPadding.self, forKey: .mapPadding)
|
|
mapPadding = try container.decodeIfPresent(ATMapPadding.self, forKey: .mapPadding)
|
|
@@ -91,11 +87,13 @@ class ATMapPolyline: NSObject, Codable {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 初始化方法
|
|
// 初始化方法
|
|
|
- init(lineId: String, lineType: PolylineType, points: [CLLocationCoordinate2D], mapPadding: ATMapPadding? = nil) {
|
|
|
|
|
|
|
+ init(lineId: String, lineType: String, points: [CLLocationCoordinate2D], mapPadding: ATMapPadding? = nil,color : String,width : Double) {
|
|
|
self.lineId = lineId
|
|
self.lineId = lineId
|
|
|
self.lineType = lineType
|
|
self.lineType = lineType
|
|
|
self.points = points
|
|
self.points = points
|
|
|
self.mapPadding = mapPadding
|
|
self.mapPadding = mapPadding
|
|
|
|
|
+ self.color = color
|
|
|
|
|
+ self.width = width
|
|
|
super.init()
|
|
super.init()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|