消除MKMapView中的Pin重叠 [英] Eliminate Pin Overlap in the MKMapView

查看:119
本文介绍了消除MKMapView中的Pin重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用基于MKMapView的应用程序。我需要澄清一下是否有可能消除MKMapView中的引脚OverLap?。因为在某些地方有大量的针脚显示。我很难确定销钉。

I am working with MKMapView Based application. I need a clarification that is 'Is it possible to eliminate the pin OverLap in the MKMapView?. Because at some places there are large number of pins displaying. It is difficult to me to identify the pins.

如果有任何已知选项可以解决此问题,请帮助我。

Please help me if is there any known option to resolve this.

谢谢你,
S。

Thank you, S.

推荐答案

如果您有Apple开发者帐户,我强烈建议您从 2011年WWDC大会会议,题为使用MapKit在地理位置上可视化信息。其中一个细分专门介绍了如何从大型数据集中聚类内容,以便根据不同缩放级别的密度对引脚进行分组或取消组合。

If you have an Apple Developer Account, I would strongly recommend getting the Session 111 video from the 2011 WWDC Conference Sessions, entitled "Visualizing Information Geographically with MapKit". One of the segments specifically covers how to cluster content from large data sets to allow you to group or ungroup pins based on density at various zoom levels.

他们的示例非常简单,但问题的核心是你想用一个引脚替换一组重叠的引脚,当你放大单个引脚时会分裂回各个引脚。

Their example is elegantly simple, but at the heart of the problem you want to replace a group of overlapping pins with a single pin and as you zoom in the single pin will split back into the individual pins.

如何以及何时决定将事情分组可能会有很大差异。 Apple的解决方案只是将地图细分为网格,任何超过1个引脚的框都会产生一个组。您还可以采用算法方法,例如使用非常简单的kMeansCluster算法,您可以通过算法提供所有注释,并从逻辑上组织另一方获得一组组。

How and when you decide to group things can be varied considerably. Apple's solution simply subdivides the map into a grid and any box that has more than 1 pin results in a group. You could also take an algorithmic approach such as using a kMeansCluster algorithm which is incredibly simple and you could feed all of your annotations through the algorithm and get an array of groups out the other side logically organized.

从那里开始跟踪所有单个引脚以及放大和缩小时它们的分组方式。您只会为每个组或剩余的任何单个引脚显示单个注释。当地图放大和缩小时,也可以设置过渡动画,这样你就可以在视觉上强化正在发生的事情。

From there it's a matter of keeping track of all the individual pins and how they are grouped as you zoom in and out. You will only display a single annotation for each group or any individual pins that are left over. It's also possible to animate the transitions as the map zooms in and out so you can visually reinforce what is happening.

我自己的技术与Apple的方法关系太密切了发布在这里,所以我希望你能访问上面几乎涵盖所有这些观点的视频。

My own technique is too closely related to Apple's approach for me to post here so I'm hoping you can access the above video which covers almost all of these points.

这篇关于消除MKMapView中的Pin重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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