gpt4 book ai didi

ios - 如何更改 mapbox 注释 View ?

转载 作者:可可西里 更新时间:2023-11-01 00:39:18 24 4
gpt4 key购买 nike

我已经添加了几个带有自定义注释 View 的注释,但我只引用了标记而不是注释 View 本身。那么如何更改注释 View 元素呢?

最佳答案

您应该将注释存储在一个变量中,当您想要更改它们的 View 时,只需使用 mapView.removeAnnotation(...) 将它们从 map 中删除,然后使用 mapView.addAnnotation(...) 再次将其添加回来。

方法

func mapView(_ mapView: MGLMapView, viewFor annotation: MGLAnnotation) -> MGLAnnotationView? {
}

将被调用,您应该返回更改后的 View 。

请注意,出于性能原因,如果您有很多注释,则不应使用 addAnnotation() 或 removeAnnotation(),而应使用 addAnnotations() 和 removeAnnotations()

关于ios - 如何更改 mapbox 注释 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49163116/

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