我如何知道注释是否已经在地图视图上 [英] How can I know if an annotation is already on the mapview

查看:17
本文介绍了我如何知道注释是否已经在地图视图上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当且仅当 mapview 上没有相同的 pin 时,我才尝试向 Mapview 添加注释 pin,以避免在同一位置有多个重复的注释.

I trying to add annotation pin to Mapview if and only if there is no such same pin already on mapview to avoid having multiple repeat annotations at the same location.

有人可以帮我看看吗?

推荐答案

您可以使用 mapView.view(for:) 方法.

例如

    if (self.mapView.view(for: annotation) != nil) {
        print("pin already on mapview")
    }

这篇关于我如何知道注释是否已经在地图视图上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆