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

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

问题描述

我尝试在且仅当mapview上没有相同的图钉时才将注释图钉添加到Mapview中,以避免在同一位置出现多个重复注释.

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天全站免登陆