Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • OpenLayers 2.10 Beginner's Guide
  • Toc
  • feedback
OpenLayers 2.10 Beginner's Guide

OpenLayers 2.10 Beginner's Guide

4.2 (9)
close
OpenLayers 2.10 Beginner's Guide

OpenLayers 2.10 Beginner's Guide

4.2 (9)

Overview of this book

Table of Contents (18 chapters)
close
OpenLayers 2.10
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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). The best way to further explain this is through an example. Let's take a look, then go even further in depth.

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete