gpt4 book ai didi

objective-c - 如何在 Mapbox for iOS 中向 MGLAnnotation 添加属性

转载 作者:行者123 更新时间:2023-11-28 12:11:36 25 4
gpt4 key购买 nike

如何添加自定义属性,例如“工作”或“级别”等?

目前内置仅允许标题、描述和位置。

最佳答案

您必须子类化 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
}
}

关于objective-c - 如何在 Mapbox for iOS 中向 MGLAnnotation 添加属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48331319/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com