我怎样才能减少注释的数量在地图上?在地、注释、图上、数量

2023-09-10 23:49:19 作者:围剿白日梦

我编码与大约900注释的地图视图。有这么多的注释在地图上做出的性能受到影响,所以我想将其降低到300左右的时间。注释是一个国家重新presenting商店,所以他们往往聚集了不少各地大中城市,然后在小城镇小团体的2或3。我想,以减少城市被减薄以便为2或3的基团单独留下的数字,但数字(它们以便并拢,他们提供任何有用的信息)。

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 annotations are representing shops in a country, so they tend to cluster a lot around major cities, then in small groups of 2 or 3 in smaller towns. I want to reduce the numbers so that the groups of 2 or 3 are left alone, but the numbers in the city are thinned (they're so close together that they offer no useful information).

在图像,你可以看到,有一对夫妇大集团(东京,名古屋和大阪),我要瘦出。但随着对自己或小团体的针,我要确保他们没有得到过滤。有一次,我放大,我想说明的缺失的插针。

In the image you can see that there are a couple of big groups (Tokyo, Nagoya and Osaka) which I want to thin out. But with the pins on their own or in small groups, I want to make sure they don't get filtered. Once I zoom in, I want to show the missing pins.

有谁知道一些好的code,我可以使用,使它们并拢点被消除,但那些多个S $ P $垫出来单独留?

Does anyone know of some good code that I can use, so that points which are close together are eliminated, but ones more spread out are left alone?

推荐答案

一种方法是,把一个新的脚前,检查是否有另一个脚已经放置在新的引脚的距离d。如果有,请不要将新的引脚。您需要根据当前的缩放级别有所不同ð。

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.

您可以减少引脚您考虑在边界框集中在新的引脚只销核对数量。盒子可以在一个侧面DXD度(用D基于缩放级别的不同而异)。

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).