[OpenLayers-Users] using conditional strokeWidth and external
Graphics Cluster Strategy
Mike Adair
madair at dmsolutions.ca
Thu Jun 3 09:09:52 EDT 2010
Zac,
I've done that for the color and graphic like so:
var HLDefaultStyle = new OpenLayers.Style({
fillColor: '${getStatusColor}',
graphicName: '${getStatusShape}',
pointRadius: 4
}, {
context: {
getStatusColor: function(feature) {
if(feature.attributes.count > 1) { //this means it
is clustered
return '#00CCFF';
} else {
return
feature.cluster?feature.cluster[0].attributes.statusColor:feature.attributes.statusColor;
}
},
getStatusShape: function(feature) {
if (feature.attributes.count > 1) { //this means it
is clustered
return 'circle';
} else {
var style =
feature.cluster?feature.cluster[0].attributes.markerStyle:feature.attributes.markerStyle;
switch (style) {
case "BASE": return 'invtriangle';
case "CHECK": return 'circleStrike';
default: return 'circle';
}
}
}
It should be similar to set the pointRadius and external graphic through
Style context methods.
Mike
Zac Spitzer wrote:
> Anyone got an example switching between icons ( aka externalGraphics)
> and varying sized clustered stoked circles?
>
> basically I want to switch to using icons for non clustered points
>
> If guess it's something like using context & rules in a stylemap?
>
> z
>
>
--
Michael Adair
Senior Software Architect
DM Solutions Group Inc.
Office: (613) 565-5056 x26
madair at dmsolutions.ca
http://www.dmsolutions.ca
http://research.dmsolutions.ca
More information about the Users
mailing list