[OpenLayers-Dev] clustered icons not rendering

crb jcbeaude at yahoo.com
Tue Aug 31 12:00:07 EDT 2010


I'm using OL v2.9.1 and am using a clustered strategy for a points vector
layer. If I use the default symbolizers (circles) then it renders correctly,
but when I attempt to use icons, only the non-clustered icons are rendering. 
The default style lookup and rule also seems to be working correctly, i.e.
it's choosing the correct icon to render for non-clustered features.  A
little console debugging code shows that the radius' are being correctly
resolved and the number of clustered features seems correct.

Some code:

    
    var x = 0; // for debugging
    var y = 0; // for debugging

    var defaultStyle = new OpenLayers.Style({
        'pointRadius': "${radius}",
        'graphicYOffset': "${yOffset}",
        'cursor': "pointer"
    }, {
        context: {
            'radius': function(feature) {
                var pix = 8;
                if (feature.cluster) {
                    x += 1;
                    pix = (+feature.attributes.count + 20);  // making
clustered icons huge so they stand out for debugging purposes; more
debugging:
                    console.log("number of feature attributes: " +
feature.attributes.count);
                    console.log("radius size: " + (+feature.attributes.count
+ 20));
                    console.log("clustered: " + x + "; non-clustered: " +
y);  // end debugging
                } else {
                    y += 1;  // begin debugging
                    console.log("non-clustered: " + y + "; clustered: " +
x);
                }
                console.log("pix: " + pix);  // end debugging
                return pix;
            },
            'yOffset': function(feature) {   // not too worried about offset
just yet, just want to get clustered icons working first
                var pix2 = -16;
                if (feature.cluster) {
                    pix2 = ((+feature.attributes.count + 20) * -1);
                }
                console.log("pix2: " + pix2);
                return pix2;
            }
        }
    });

    var selectStyle = new OpenLayers.Style(...

    var styleMap = new OpenLayers.StyleMap({
        'default': defaultStyle,
        'select': selectStyle
    });

    var defaultStyleLookup = {
        0: { externalGraphic: "Map/images/blue.png" },     
        1: { externalGraphic: "Map/images/green.png" },    
        2: { externalGraphic: "Map/images/purple.png" }
    }

    styleMap.addUniqueValueRules("default", "typeid", defaultStyleLookup);

    var strategy = new OpenLayers.Strategy.Cluster(
    { 
        'distance': 40,
        'threshold': 3
    });

    var locsLayer = new OpenLayers.Layer.Vector('Monitoring Locations', 
    {
        'styleMap': styleMap,
        'strategies': [ strategy ]
    });





-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/clustered-icons-not-rendering-tp5483345p5483345.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.



More information about the Dev mailing list