This class represents a UserStyle obtained from a SLD, containing styling rules.
ALKMaps. | This class represents a UserStyle obtained from a SLD, containing styling rules. |
Properties | |
id | {String} A unique id for this session. |
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(ALKMaps.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. |
defaultsPerSymbolizer | {Boolean} If set to true, the defaultStyle will extend the symbolizer of every rule. |
propertyStyles | {Hash of Boolean} cache of style properties that need to be parsed for propertyNames. |
Constructor | |
ALKMaps. | 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 |
clone | Clones this style. |
createLiteral | converts a style value holding a combination of PropertyName and Literal into a Literal, taking the property values from the passed features. |
Constants | |
ALKMaps. | {Array} prefixes of the sld symbolizers. |
{String} name of the layer that this style belongs to, usually according to the NamedLayer attribute of an SLD document.
{Array(ALKMaps.Rule)}
{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. If defaultsPerSymbolizer is set to true, the defaultStyle will only be taken into account if there are rules defined.
{Boolean} If set to true, the defaultStyle will extend the symbolizer of every rule. Properties of the defaultStyle will also be used to set missing symbolizer properties if the symbolizer has stroke, fill or graphic set to true. Default is false.
Creates a UserStyle.
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 style. |
rules | {Array(ALKMaps.Rule)} List of rules to be added to the style. |
createSymbolizer: function( feature )
creates a style by applying all feature-dependent rules to the base style.
feature | {ALKMaps.Feature} feature to evaluate rules for |
{Object} symbolizer hash
applySymbolizer: function( rule, style, feature )
rule | {ALKMaps.Rule} |
style | {Object} |
feature | {<OpenLayer.Feature.Vector>} |
{Object} A style with new symbolizer applied.
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.
{Object} hash of property names that need createLiteral parsing. The name of the property is the key, and the value is true;
getSymbolizerPrefix: function( geometry )
Returns the correct symbolizer prefix according to the geometry type of the passed geometry
geometry | {ALKMaps.Geometry} |
{String} key of the according symbolizer
ALKMaps.Style.createLiteral = function( value, context, feature, property )
converts a style value holding a combination of PropertyName and Literal into a Literal, taking the property values from the passed features.
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 | {ALKMaps.Feature.Vector} optional feature to pass to ALKMaps.String.format for evaluating functions in the context. |
property | {String} optional, name of the property for which the literal is being created for evaluating functions in the context. |
{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”.
nullify references to prevent circular references and memory leaks
destroy: function()
creates a style by applying all feature-dependent rules to the base style.
createSymbolizer: function( feature )
applySymbolizer: function( rule, style, feature )
creates literals for all style properties that have an entry in this.propertyStyles.
createLiterals: function( style, feature )
Looks into all rules for this style and the defaultStyle to collect all the style hash property names containing ${...}
findPropertyStyles: function()
addPropertyStyles: function( propertyStyles, symbolizer )
Adds rules to this style.
addRules: function( rules )
Sets the default style for this style object.
setDefaultStyle: function( style )
Returns the correct symbolizer prefix according to the geometry type of the passed geometry
getSymbolizerPrefix: function( geometry )
Clones this style.
clone: function()
converts a style value holding a combination of PropertyName and Literal into a Literal, taking the property values from the passed features.
ALKMaps.Style.createLiteral = function( value, context, feature, property )
Given a string with tokens in the form ${token}, return a string with tokens replaced with properties from the given context object.
format: function( template, context, args )