O'Reilly logo

OpenLayers Cookbook by Antonio Santiago Perez

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

Improving style using StyleMap and the replacement of feature's attributes

We can summarize that there are two ways to style a feature. The first is applying a symbolizer hash directly to the feature (see the Styling features using symbolizers recipe). The second is applying the style to the layer so every feature contained in it becomes styled.

The second one is the preferred way in many situations. It is a generic way to style all the features in a layer by setting some styles and rules.

This recipe shows how we can use the StyleMap instances and how easily we can style all the points of a layer without applying a style on each feature. The output of this recipe should look similar to the following screenshot:

In addition, the technique we will ...

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