ios sdk MKMapView overlapping pins?

后端 未结 1 485
没有蜡笔的小新
没有蜡笔的小新 2021-01-22 08:19

I have map view and many pins on it.
When the map view is zoomed out, I group overlapping pins into 1 (and show in label total count of pins in it).
But what to do, if m

1条回答
  •  不思量自难忘°
    2021-01-22 08:45

    In a slightly different solution to the same problem, the demo in the WWDC 2011 #111 - Visualizing Information Geographically with MapKit video (the demo is a little more than 18 min into the video) illustrates an example of how you can prevent overlapping annotations (including some nice animation revealing and hiding more detailed annotations as you zoom in and out).

    What they do is to break the mapview into a grid of a particular size (I think they use 60px), and if they are too close, they pick one for that grid and hide the others. They also do a graceful hiding of the annotations as you zoom out (so you can see the annotations that are being hidden fly into the visible annotation for that group). As you zoom in the annotations are unhidden, you see it fly out of the one central annotation for that grid.

    0 讨论(0)
提交回复
热议问题