0

I have cluster with some features inside, and when clicking to cluster, I need to zoom to those features inside. I did everything like described in this post in answers Continue zooming in when smaller clusters are tapped and when clicking to cluster I receive the following view.

enter image description here

Here we can see that features fits the extent, but visually it is not very good: some of features(actually feature icon) are cutted off. I tried to add some padding to fit function like map.getView().fit(extent, { padding: [20, 20, 20, 20] });. But another problem has arised:

enter image description here

Not all features are zoomed in, but I want see all features opened. I also tried constrainResolution to false, but no luck. How that can be fixed, any tips are welcomed, as I am running out of ideas.

divinen
  • 81
  • 10
  • 1
    If you have two features at exactly the same location they will always be clustered in a cluster layer. The only workaround is to use separate cluster and unclustered layers and switch between them (using their `.setVisible()` method) - but then one feature could be hidden behind the other. – Mike May 11 '21 at 17:07
  • Take a look at the most recent example https://openlayers.org/en/main/examples/cluster.html Clicking on a cluster zooms in on the cluster, but that may contain many smaller clusters, Padding is definitely a good idea if you have large icons. – Mike May 11 '21 at 17:11

1 Answers1

0

You can use ol/interaction/SelectCluster to springs features apart on select. It's part of ol-ext extensions.

See example: https://viglino.github.io/ol-ext/examples/animation/map.animatedcluster.html

Viglino Jean-Marc
  • 1,371
  • 8
  • 6