MapKit多个引脚相同坐标,不同信息选择
我有以下情况: - 3 个具有相同坐标但标题和信息不同的图钉 - 地图上只有一个图钉
可以在该图钉上点击多次,并且注释显示为: - 第一次点击->引脚 1 的注释 - 第二次点击->引脚 2 的注释 - 第三次点击->引脚 3 的注释 - 第四次点击 ->引脚 1 的注释
您对我应该如何实现它有什么想法吗?
I have the following situation:
- 3 pins with same coordinates but different title and info
- on map there is ony one pin
It is possible to tap multiple times on that pin and the annotation displayed to be:
- first tap -> the annotation for pin 1
- second tap -> the annotation for pin 2
- third tap -> the annotation for pin 3
- fourth tap -> the annotation for pin 1
Do you have any ideas how should I implement it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以实现
didSelectAnnotationView
委托方法,并根据最后一个“正确”选择自行选择“正确”注释。如果地图上仅有这些注释并且仅其中一组,那么您可以保留一个
int
ivar来记住最后选择的内容注释是并在委托方法中增加它。例如:
如果您还打开了
showsUserLocation
,那么您必须在该方法中添加对MKUserLocation
的检查并跳过它(如果您愿意)并继续到集群中的下一个注释。另外,如果您有多个注释簇(坐标 A 处有 3 个,坐标 B 处有 5 个,坐标 C 处有 4 个,等等),那么您需要跟踪 LastAnnotationSelected int 数组,并在方法中首先确定什么选择集群并获取要在该集群中选择的下一个注释。
You can implement the
didSelectAnnotationView
delegate method and select the "correct" annotation yourself depending on what the last "correct" selection was.If you only have these annotations on the map and only one cluster of them, then you can keep one
int
ivar that remembers what the last selected annotation was and increment it in the delegate method.For example:
If you also have
showsUserLocation
turned on, then you'll have to add a check forMKUserLocation
in that method and skip it (if you want to) and go to the next annotation in the cluster.Also, if you have multiple clusters of annotations (3 at coordinate A, 5 at coordinate B, 4 at coordinate C, etc), then you'll need to keep track of an array of lastAnnotationSelected ints and in the method, first determine what cluster was selected and get the next annotation to select in that cluster.