Objective c 如何在iOS的Mapbox中将属性添加到MGLAnnotation
如何添加自定义属性,如“作业”或“级别”等Objective c 如何在iOS的Mapbox中将属性添加到MGLAnnotation,objective-c,swift,mapbox,Objective C,Swift,Mapbox,如何添加自定义属性,如“作业”或“级别”等 当前内置的只允许标题、描述和位置。您必须对MGLAnnotation进行子类化,并添加自定义属性,如下所示: class MyAnnotation: NSObject, MGLAnnotation { var coordinate: CLLocationCoordinate2D var title: String? var subtitle: String? // Custom properties var
当前内置的只允许标题、描述和位置。您必须对
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
}
}
您必须子类化
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
}
}