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 use allows us to involve the feature's attributes to select a point radius and color, creating them all together more dynamically.
How to do it...
Once we have created the HTML file with OpenLayers dependencies, start creating the
div
element that...