[GIS] Getting OpenLayers Vector features vs clusters

openlayers-2

I am using OpenLayers Vector with a cluster strategy. When I use Vector.features to get the features returned as a list, it returns an array of clusters and not the array of features. This makes the features unable to be addressed individually. Does anyone know how can I get the features list while using the clustering strategy? Any help is appreciated.

(Eg. If there are 5 features in my KML which are clustered as 1, then I get vector.features.length=1. I need the original features list which will have a length of 5)

Below is the implementation of my Vector:

var maps_layer = new OpenLayers.Layer.Vector("KML", {
                     strategies: [new OpenLayers.Strategy.Cluster()],
                     protocol: new OpenLayers.Protocol.HTTP({
                        url: "kml/maps.kml",
                        format: new OpenLayers.Format.KML({
                           extractStyles: true, 
                           extractAttributes: true,
                        })
                    })
                 })

thesis.events.register("loadend", this, function(){
      var my_array = maps_layer.features; //Size of this is = no.of Clusters and not features
});

Here is the documentation: http://dev.openlayers.org/docs/files/OpenLayers/Layer/Vector-js.html

Best Answer

You should use features property of cluster strategy object. In this example you can fetch all features of layer using the following syntax: map.layers[1].strategies[1].features.length.