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

The Style class


The Style class is used to specify the styles a vector layer should use. As mentioned a couple of times before, it's quite similar in principle to how we use CSS to style our controls. The difference is that with the vector layer we are directly embedding the style in the JavaScript code itself, using an anonymous object which is referred to as a symbolizer.

Note

When we talk about symbolizers, we're just referring to an anonymous object that defines styles (or, by some stretch, their 'symbol'). The term 'symbolizer' is maybe not the best term that could have been used, but it's part of the OpenLayers vocabulary so we need to learn it.

To create a Style object, we just pass in a symbolizer (an anonymous object) that defines the layer's style. As in the previous example:

var vector_style = new OpenLayers.Style({ 
    'fillColor': '#669933', 
    'fillOpacity': .8, 
    'strokeColor': '#aaee77', 
    'strokeWidth': 3, 
    'pointRadius': 8 
});

That's essentially all there is to...