1

I might be able to work this out myself but I am in a bit of a deadline rush and thought about posting this here with the chance that somebody has dealt with a similar issue before.

I am using ol.source.Cluster to create themed maps. I want to show an inset map with of the biggest cluster in detail.

1 Answer 1

4

I actually fuzzed out an answer rather quickly while I was thinking about the question to ask and decided to post the answer here as this might be helpful for someone else in the future.

var checkCluster = 0;
var clusterFeatures;
sourceCluster.forEachFeature(function (f) {
    if (f.get('features').length > checkCluster) {
        clusterFeatures = f.get('features');
        checkCluster = clusterFeatures.length;
    }
});
sourceForExtent = new ol.source.Vector();
sourceForExtent.addFeatures(clusterFeatures);
insetMap.getView().fit(
    sourceForExtent.getExtent(),
    insetMap.getSize()
);

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.