Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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,
                 })"loadend", this, function(){
      var my_array = maps_layer.features; //Size of this is = no.of Clusters and not features

Here is the documentation:

share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer
Thankyou..! This was what I was exactly looking for. :) – rgamber Jul 22 '12 at 18:50

Although it's an old question, i am putting here another answer/way by which I get the clustered features.

For this solution, you must first get the layer from map. Once getting layer you can access the features of this clustered layer as,
To understand its structure just log it to console and use firebug to view the log.

To make it more useful(as some features may be clustered and some may not) use the simple if condition as,

    for(var i=0;i<layer[0].features.length;i++){
        //cluster exist. play with clustered features
        //no clusters. directly access the feature


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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