How to show single annotation pin for a region when i have multiple coordinates for that region?

南笙酒味 提交于 2020-01-02 09:23:50

问题


I am working on the map application and as per requirement i need to show a single pin for a single region even if it has multiple user coordinates when its completely zoomed out but when its zoomed in to the map then i should display all the pins as per its coordinates. I have given example below to explain my problem. I have city New York on this city I have 100 pins on my mapview when I am zooming out of my map it should show me only one annotation pin on the place of 100 pins but when I am zooming in then it should show again 100 pin on map. Does any one knows about this. I need suggestion. Please note that I am getting all the locations from web services except my current location. This should not be affecting application so that application shouldn't become slow.

Please suggest some solution.


回答1:


The Apple WWDC 2011 video, "Visualizing information geographically with MapKit", https://developer.apple.com/videos/wwdc/2011/ shows how to cluster map annotations - it's exactly what you need.




回答2:


Of course there is a control for that...
Take a look at OpenClusterMapView, it should be exactly what you need.




回答3:


There is no API for this.

You will need to manage the pins yourself. As a user zooms in on the map, you will need to decide at what point to remove the aggregated pin and add the individual pins. Inversely, as a user zooms out you will need to remove the individual pins and replace with the aggregated pin.

Might be a good idea to use a custom pin for the aggregated pin to suggest that it represents multiple pins.

I think this link might help you know the current zoom level:

Zoom and Region

Link to a similar question:

Pin Overlap



来源:https://stackoverflow.com/questions/8665002/how-to-show-single-annotation-pin-for-a-region-when-i-have-multiple-coordinates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!