[OpenLayers-Dev] Problem with cluster strategy

Tim Schaub tschaub at opengeo.org
Mon Dec 1 13:12:18 EST 2008


Hey-

Eric Lemoine wrote:
> Hi Jérome
> 
> What about registering a beforefeaturesadded listener and having this
> listener calculate the max value? That should do the trick...
> 
> Eric
> 
> 2008/11/26, Jerome Freyre <jerome.freyre at hispeed.ch>:
>> Hi Ivan,
>>
>> Ok for the sample but the main goal of my post was a suggestion to display
>> correctly the cluster on a map.
>>
>> I think that the sample is not a correct representation of the reality.
>>
>> The addition of a function that get the max value present permit to display
>> correctly the cluster and have a radius that correspond to the reality.
>>
>> In the sample formula, if you have a cluster that aggregate 100 features and
>> an other that aggregate 20 feature they will be displayed with the same
>> radius.
>>
>> With my function the radius will be correctly adapted and we have a correct
>> representation of the reality
>>

The job of the cluster strategy is to cluster features.  It does not 
deal with the display of those clusters.  That is up to you.

If you want to render a feature with a point radius that is derived from 
some feature attribute, you would create a style with a symbolizer that 
looked something like this:

var symbolizer = {
     pointRadius: "${count}"
};

Assuming your features have an attribute called "count" and you want 
that to be the pixel radius of your rendered features.

If you want to create a symbolizer with properties that are not based on 
literal feature attributes, you can use an arbitrary function to derive 
properties based on any property of a feature.

Again, none of this has to do with the cluster strategy.  For an example 
of features styled based on a literal feature attribute and based on an 
arbitrary function, see 
http://openlayers.org/dev/examples/styles-context.html

Not sure if any of this will help you achieve the "correct 
representation of the reality," but you do have quite a bit of control 
over how your features are styled.

Tim


>> Sincerly,
>> Jérome
>>
>>
>>
>> Ivan Grcic-2 wrote:
>>> HI Jerome,
>>>
>>> Function Math.min(feature.attributes.count, 7) + 3 was just a sample
>>> in the demo. You can use whatever function you need, just take care to
>>> make it as simple as possible, because it runs trought it for every
>>> feature in cluster.
>>>
>>> Cheers, Ivan
>>> --
>>> Ivan Grcic
>>> _______________________________________________
>>> Dev mailing list
>>> Dev at openlayers.org
>>> http://openlayers.org/mailman/listinfo/dev
>>>
>>>
>> --
>> View this message in context:
>> http://www.nabble.com/Problem-with-cluster-strategy-tp20701364p20702430.html
>> Sent from the OpenLayers Dev mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> Dev mailing list
>> Dev at openlayers.org
>> http://openlayers.org/mailman/listinfo/dev
>>
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev


-- 
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.



More information about the Dev mailing list