How can I reduce the number of annotations on a map?

后端 未结 6 1470
时光说笑
时光说笑 2020-12-13 11:03

I\'m coding a map view with around 900 annotations. Having this many annotations on a map make the performance suffer, so I\'d like to reduce it to about 300 at a time. The

6条回答
  •  一整个雨季
    2020-12-13 11:04

    One approach is that before placing a new pin, check if there's another pin already placed within distance d of the new pin. If there is, don't place the new pin. You need to vary d based on the current zoom level.

    You can reduce the number of pins you check against by considering only pins in a bounding box centered on the new pin. The box could be d x d degrees on a side (with d varying based on zoom level).

提交回复
热议问题