OpenLayers.Style - OpenLayers

# OpenLayers. Style

This class represents a UserStyle obtained from a SLD, containing styling rules.

Summary

OpenLayers. Style | This class represents a UserStyle obtained from a SLD, containing styling rules.
Properties |
name | {String}
title | {String} Title of this style (set if included in SLD)
description | {String} Description of this style (set if abstract is included in SLD)
layerName | {String} name of the layer that this style belongs to, usually according to the NamedLayer attribute of an SLD document.
isDefault | {Boolean}
rules | {Array(OpenLayers.Rule)}
context | {Object} An optional object with properties that symbolizers’ property values should be evaluated against.
defaultStyle | {Object} hash of style properties to use as default for merging rule-based style symbolizers onto.
propertyStyles | {Hash of Boolean} cache of style properties that need to be parsed for propertyNames.
Constructor |
OpenLayers. Style | Creates a UserStyle.
Functions |
destroy | nullify references to prevent circular references and memory leaks
createSymbolizer | creates a style by applying all feature-dependent rules to the base style.
applySymbolizer |
createLiterals | creates literals for all style properties that have an entry in <this.propertyStyles>.
findPropertyStyles | Looks into all rules for this style and the defaultStyle to collect all the style hash property names containing ${...}
addPropertyStyles |
addRules | Adds rules to this style.
setDefaultStyle | Sets the default style for this style object.
getSymbolizerPrefix | Returns the correct symbolizer prefix according to the geometry type of the passed geometry
createLiteral | converts a style value holding a combination of PropertyName and Literal into a Literal, taking the property values from the passed features.
Constants |
OpenLayers. Style. SYMBOLIZER_PREFIXES | {Array} prefixes of the sld symbolizers.

### Properties

### name

{String}

### title

{String} Title of this style (set if included in SLD)

### description

{String} Description of this style (set if abstract is included in SLD)

### layerName

{String} name of the layer that this style belongs to, usually according to the NamedLayer attribute of an SLD document.

### isDefault

{Boolean}

### rules

{Array(OpenLayers.Rule)}

### context

{Object} An optional object with properties that symbolizers’ property values should be evaluated against. If no context is specified, feature.attributes will be used

### defaultStyle

{Object} hash of style properties to use as default for merging rule-based style symbolizers onto. If no rules are defined, createSymbolizer will return this style.

### propertyStyles

{Hash of Boolean} cache of style properties that need to be parsed for propertyNames. Property names are keys, values won’t be used.

### Constructor

### OpenLayers. Style

Creates a UserStyle.

#### Parameters

style | {Object} Optional hash of style properties that will be used as default style for this style object. This style applies if no rules are specified. Symbolizers defined in rules will extend this default style.
options | {Object} An optional object with properties to set on the userStyle

#### Return

{OpenLayers.Style}

### Functions

### destroy

> destroy: function()

nullify references to prevent circular references and memory leaks

### createSymbolizer

> createSymbolizer: function( | feature | )

creates a style by applying all feature-dependent rules to the base style.

#### Parameters

feature | {OpenLayers.Feature} feature to evaluate rules for

#### Returns

{Object} symbolizer hash

### applySymbolizer

> applySymbolizer: function( | rule,
> | style,
> | feature | )

#### Parameters

rule | {OpenLayers.Rule}
style | {Object}
feature | {<OpenLayer.Feature.Vector>}

#### Returns

{Object} A style with new symbolizer applied.

### createLiterals

> createLiterals: function( | style,
> | feature | )

creates literals for all style properties that have an entry in <this.propertyStyles>.

#### Parameters

style | {Object} style to create literals for. Will be modified inline.
feature | {Object}

#### Returns

{Object} the modified style

### findPropertyStyles

> findPropertyStyles: function()

Looks into all rules for this style and the defaultStyle to collect all the style hash property names containing ${...} strings that have to be replaced using the createLiteral method before returning them.

#### Returns

{Object} hash of property names that need createLiteral parsing. The name of the property is the key, and the value is true;

### addPropertyStyles

> addPropertyStyles: function( | propertyStyles,
> | symbolizer | )

#### Parameters

propertyStyles | {Object} hash to add new property styles to. Will be modified inline
symbolizer | {Object} search this symbolizer for property styles

#### Returns

{Object} propertyStyles hash

### addRules

> addRules: function( | rules | )

Adds rules to this style.

#### Parameters

rules | {Array(OpenLayers.Rule)}

### setDefaultStyle

> setDefaultStyle: function( | style | )

Sets the default style for this style object.

#### Parameters

style | {Object} Hash of style properties

### getSymbolizerPrefix

> getSymbolizerPrefix: function( | geometry | )

Returns the correct symbolizer prefix according to the geometry type of the passed geometry

#### Parameters

geometry {OpenLayers.Geometry}

#### Returns

{String} key of the according symbolizer

### createLiteral

> OpenLayers.Style.createLiteral = function( | value,
> | context,
> | feature | )

converts a style value holding a combination of PropertyName and Literal into a Literal, taking the property values from the passed features.

#### Parameters

value | {String} value to parse. If this string contains a construct like “foo ${bar}”, then “foo “ will be taken as literal, and “${bar}” will be replaced by the value of the “bar” attribute of the passed feature.
context | {Object} context to take attribute values from
feature | {OpenLayers.Feature.Vector} The feature that will be passed to OpenLayers.String.format for evaluating functions in the context.

#### Returns

{String} the parsed value. In the example of the value parameter above, the result would be “foo valueOfBar”, assuming that the passed feature has an attribute named “bar” with the value “valueOfBar”.

### Constants

### OpenLayers. Style. SYMBOLIZER_PREFIXES

{Array} prefixes of the sld symbolizers. These are the same as the main geometry types

Contains convenience functions for string manipulation.
This class represents an SLD Rule, as being used for rule-based SLD styling.

> destroy: function()

nullify references to prevent circular references and memory leaks

> createSymbolizer: function( | feature | )

creates a style by applying all feature-dependent rules to the base style.

> applySymbolizer: function( | rule,
> | style,
> | feature | )

> createLiterals: function( | style,
> | feature | )

creates literals for all style properties that have an entry in this.propertyStyles.

> findPropertyStyles: function()

Looks into all rules for this style and the defaultStyle to collect all the style hash property names containing ${...}

> addPropertyStyles: function( | propertyStyles,
> | symbolizer | )

> addRules: function( | rules | )

Adds rules to this style.

> setDefaultStyle: function( | style | )

Sets the default style for this style object.

> getSymbolizerPrefix: function( | geometry | )

Returns the correct symbolizer prefix according to the geometry type of the passed geometry

> OpenLayers.Style.createLiteral = function( | value,
> | context,
> | feature | )

converts a style value holding a combination of PropertyName and Literal into a Literal, taking the property values from the passed features.
Creates a UserStyle.
Features are combinations of geography and attributes.
A Geometry is a description of a geographic object.

> format: function( | template,
> | context,
> | args | )

Given a string with tokens in the form ${token}, return a string with tokens replaced with properties from the given context object.
Close