O'Reilly logo

OpenLayers 2.10 by Erik Hazzard

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Attribute replacement

One easy, but powerful, thing we can do with feature styles is called attribute replacement. It's a way to use a feature's attributes in the layer's style definition, like a variable. When creating the symbolizer, you can set the value of any property in a format of:

${variable_name}

Where variable_name is the name of a property contained in a feature's attributes property. For example, let's say all our features have an attribute property called 'size' with random integer values. If we wanted to assign the pointRadius to each feature's size property, we would use:

{ 'pointRadius': ${size} }

What happens then is that when each feature is styled, the ${size} is replaced by the feature's attribute.size property (if one exists). ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required