openlayers 3 , clustering polygons or linestings

2019-08-05 13:10发布

i've been searching for a way to cluster polygons using openlayers 3 but no luck. i've read that clustering only works with points so i'm thinking about editing the ol.source.cluster . so had anyone done it, or got any other solutions?

Kind regards

1条回答
2楼-- · 2019-08-05 14:04

As of openlayers 3.15.0, it is possible to cluster all geometry types using an optional function, geometryFunction. From http://openlayers.org/en/v3.15.0/apidoc/ol.source.Cluster.html:

Function that takes an ol.Feature as argument and returns an ol.geom.Point as cluster calculation point for the feature. When a feature should not be considered for clustering, the function should return null. See ol.geom.Polygon#getInteriorPoint for a way to get a cluster calculation point for polygons.

查看更多
登录 后发表回答