如何添加自定义属性,例如“作业”或“等级”等?
目前,builtins仅允许标题,描述和位置。
答案 0 :(得分:2)
您必须继承MGLAnnotation
并添加自定义属性,如下所示:
class MyAnnotation: NSObject, MGLAnnotation {
var coordinate: CLLocationCoordinate2D
var title: String?
var subtitle: String?
// Custom properties
var job: Job?
var level: Level?
init(coordinate: CLLocationCoordinate2D, title: String?, subtitle: String?) {
self.coordinate = coordinate
self.title = title
self.subtitle = subtitle
}
}