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

Styling features using symbolizers

To see the most basic form of styling a feature, we are going to create a little map editor that allows adding new features by specifying some few style properties:

Styling features using symbolizers

Each OpenLayers.Feature.Vector instance can have a style associated with it. This style is called symbolizer, which is nothing more than a JavaScript object with some fields that specify the fill color, stroke, and so on. For example:

{ 
    fillColor: "#ee9900", 
    fillOpacity: 0.4, 
    strokeColor: "#ee9900", 
    strokeOpacity: 1, 
    strokeWidth: 1 
}

In the code, every time a feature is going to be added to the map, the code will get the fill and stroke properties from ...

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