开发者

Change annotations inside MapKit view

I have a lot of annotations to manage inside the mapkit view.

The rules are : 1 -only show annotations when the mapView.region.span.longitudeDelta is above 0.042 2 -only show annota开发者_如何学Pythontions inside the visible area. 3- remove the annotations when they comes out the visible area...

How I can do that ... Share your experience...

Thanks


You need a few things. One is to search your database for the pins with latitudes and longitudes inside the map's view. This is called a bounding box. The next is to remove the annotations when they move outside the visible rect of the map. Each time the map is moved, you'll have to recalculate what pins are in the box and what pins are outside but still on the map.

One hint I can give you is to divide the visible rect of the map into squares (maybe 17 x 23 squares of 20 x 20) and figure out if a pin goes into that square. If it does, mark that square as filled, and if another pin wants to go into that square, don't let it. This will allow you to filter the pins so there aren't too many on screen at one time.

It's not an easy problem, but if you do some search around you'll find your way through it. This cluster marker code for Google Maps might help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜