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) {
if(feature.cluster)
{
feature.externalGraphic="/img/clusterimage.png";
}
return feature.externalGraphic;
}...
I`ve also tried other constructs like
feature.cluster[0].attributes['icon']
or
feature.externalGraphic=feature.cluster[0].attributes['icon']
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