[OpenLayers-Users] Labeling clustered features

Andreas Hocevar ahocevar at opengeo.org
Fri Sep 4 09:51:14 EDT 2009


Hi Florian,

if your application is based on the stragety-cluster example, then you
won't have the count in your context. If you provide a context in your
Style objedt, you don't have direct access to feature attributes. So
your context should look like this:

context: {
    radius: function(feature) {
        return Math.min(feature.attributes.count, 7) + 3;
    },
    count: function(feature) {
        return feature.attributes.count;
    }
}

Regards,
Andreas.

Florian Diederichs wrote:
> Hello,
>
> thanks for replying, i guess i should have mentioned, that i copy the
> attributes from the features to the clusters.
>
> However the attribute i wanted to use as the label is the
> 'cluster.attributes.count' which is there by default anyway, when i remember
> correctly. So in my case, the clusters do have 'feature.attributes.count' as
> a property/attribute, at least i can see it in firebug.
>
> I hope i didn't get you wrong though.
>
> Thanks in advance
> Florian
>
>   


-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.




More information about the Users mailing list