gpt4 book ai didi

ios - Mapbox iOS - 显示多个标注

转载 作者:行者123 更新时间:2023-11-29 05:08:18 26 4
gpt4 key购买 nike

我想在 Mapbox 中一次显示多个注释(注意:不是 MKMap)。尽管可以添加多个注释,但似乎没有显示多个注释的方法。

例如

mapView.addAnnotations(<annotationsArray>)

尽管有如下方法,但它不显示注释。

mapView.showAnnotations(<annotationsArray>, animated: true)

我希望它显示多个实例,如下图所示。即我想在 map 中为用户添加的每个点显示几个“Hello World”注释。

enter image description here

Mapbox 中是否有类似的方法可以在 Swift 中显示多个注释?

最佳答案

使用它来显示多个注释:

func setAnnotations() {
var index = 0
for placeModel in self.placesList! {
let marker = MyMGLPointAnnotation()
marker.willUseImage = true
marker.id = placeModel.id
marker.type = placeModel.type
if let img = placeModel.images.first {
marker.imgURL = img.thumbnail
}
marker.coordinate = CLLocationCoordinate2D(latitude: placeModel.location?.latitude ?? 0, longitude: placeModel.location?.longitude ?? 0)
marker.title = placeModel.name.withoutHtmlTags
marker.subtitle = placeModel.descr.htmlToString

//DispatchQueue.main.async {
self.mapView.setCenter(CLLocationCoordinate2D(latitude: latitude, longitude: longitude), zoomLevel: 12, animated: false)

self.mapView.addAnnotation(marker)
}
}

您可以显示注释的多个实例,但对于选择,您可以逐一点击,它将显示标题,如您共享的图像。

编辑:您可以创建自定义 xib 负载作为注释来显示标题。

检查:https://github.com/mapbox/ios-sdk-examples/blob/0e2c8ce878de500f36c4168f7a1e62041c8adbdf/Examples/Swift/AnnotationViewsAndImagesExample.swift

https://docs.mapbox.com/ios/maps/examples/annotation-view-image/

关于ios - Mapbox iOS - 显示多个标注,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59947479/

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