[OpenLayers-Users] Changing style based on feature attributes.
kapuch
kapusta.marcin at gmail.com
Thu Jul 7 09:00:30 EDT 2011
Hi.
I was looking for answer on the mailing list but didn't find the answer.
I have clustered features and I want to use diffrent styles based on cluster
feature attribute count.
When the count attribute is more than 1 i would like to use this style:
var style = new OpenLayers.Style({
pointRadius: "${radius}",
fillColor: "#ffcc66",
fillOpacity: 0.8,
strokeColor: "#cc6633",
cursor: 'pointer',
strokeWidth: "${width}",
strokeOpacity: 0.8,
}, {
context: {
width: function(feature) {
return (feature.cluster) ? 2 : 1;
},
radius: function(feature) {
var pix = 2;
if(feature.cluster) {
pix = Math.min(feature.attributes.count, 7) + 2;
}
return pix;
}
}
});
But when the count is 1 i would like to display externalImage with this
style:
var style = new OpenLayers.Style(
{externalGraphic: 'img/marker.png',
graphicHeight: 21,
graphicWidth: 16});
Now how can I switch between those two styles based on count attribute of
the feature.
Can anybody help?
-----
eDojazd.pl
Niższe koszty dojazdów dla wszystkich i wszędzie!
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Changing-style-based-on-feature-attributes-tp6558275p6558275.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list