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

OpenLayers.Rule class

When you want to be very specific about the types of styles that get applied to feature objects, the best way to do it is by using the Rule class. When you create a rule object, you specify a Filter object, a symbolizer to apply to the feature if the rule matches, and an optional name property which specifies an arbitrary name for the rule.

Rule objects are applied to style objects, and you can have virtually as many rules on a style object as you want. The syntax for creating a rule object, as mentioned previously, is:

var my_rule = new OpenLayers.Rule({
  filter: new OpenLayers.Filter({}),
  symbolizer: { key:values }
});
style_object.addRules([my_rule]);

As we saw in the previous example, it's not too hard to create and apply ...

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