Book Image

OpenLayers 2.10 Beginner's Guide

Book Image

OpenLayers 2.10 Beginner's Guide

Overview of this book

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

Rules and filters


So far, we've pretty much just been doing a one to one match on properties to specify style. With attribute replacement, we directly replace a value. With addUniqueValueRules, we see if a property is equal to something. So far, we haven't had much flexibility.

By using Rules and Filters, we can be as flexible as we want. We can do comparisons on properties, such as styling a feature a certain way if, for instance, it has a property less than or greater than some value. We can create filters to check for a multitude of different types of comparisons (greater than, less than, equal to, etc.), and have filters interact with each other.

How do they work?

A filters object belongs to a rule object. A rule object belongs to a style object. Each style object can have multiple rules, and rules can interact with each other depending on how their filters are defined.

How do we use them?

To use custom rules and filters, we just need to associate them with a style object. The general syntax...