Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

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`m using OpenLayers to show POIs on a map. These POIs are loaded from a textfile and I`m using a Vector Layer to get it onto the map - works great. Now I want to use the cluster strategy to have points clustered to one when the user is zooming out and the points get to close (see this great tutorial). Works, too. But only for a static image. I want to get the image that is defined in the textfile, but I`m not able to get this. The text file is in the normal format for OpenLayers.Format.Text. The image is defined in the column named icon and as I told, it is shown when not using clustering. According to the Source code of OpenLayers.Format.Text.js the value of the column icon should be stored in the externalGraphic-property. But this doesn`t seem to be the case. Here`s my code to try to get the Image:

var clusterStyle = new OpenLayers.Style({
    externalGraphic: "${icon}",
    graphicWidth: 24,
graphicHeight: 24,
    description: "${description}"
}, {
    context: {
        icon: function (feature) {
    return feature.externalGraphic;

I`ve also tried other constructs like




to get the icon, but neither worked. So where is the icon stored, how to access it? Is there a qay to iterate the attributes-object? I`m using OpenLayers 2.12

share|improve this question
up vote 3 down vote accepted

Well, I found the solution myself - it was not a mistake in the code lines I`ve posted. The problem were silly parameters passed to the strategy-constructor: I used the following code to create the cluster strategy:

var clusterStrategy = new OpenLayers.Strategy.Cluster({ distance: 15, threshold: 1 });

The problem was to set the threshold to 1. That erased (or overlapped, whatever) the icon. So I`ve set the threshold to 2 and then it worked as described in the amazing tutorial from the openflight-project that I`ve posted in the question.

share|improve this answer
works for KML layers as well. U ROK! – tony gil Mar 8 '13 at 21:53

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.