Adding point, line, polygon, text, and raster symbolizer constructors. This paves the way for rendering multiple symbolizers per rule. The SLD parser now successfully round-trips documents with multiple symbolizers and multiple FeatureTypeStyle elements (through the symbolizer zIndex property). The Style2 (yes, ack) constructor is used to represent a collection of rules with multiple symbolizers. Style2 objects are currently only used by the SLD parser if the multipleSymbolizer property is set to true. Future enhancements to the renderers can be made to account for multiple symbolizers. r=ahocevar (closes #2760).
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10560 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
56
tests/Style2.html
Normal file
56
tests/Style2.html
Normal file
@@ -0,0 +1,56 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_constructor(t) {
|
||||
t.plan(4);
|
||||
|
||||
var rules = [
|
||||
new OpenLayers.Rule({
|
||||
symbolizer: {fillColor: "red"},
|
||||
filter: new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.EQUAL_TO,
|
||||
property: "type",
|
||||
value: "fire engine"
|
||||
})
|
||||
}),
|
||||
new OpenLayers.Rule({
|
||||
symbolizer: {fillColor: "yellow"},
|
||||
filter: new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.EQUAL_TO,
|
||||
property: "type",
|
||||
value: "sports car"
|
||||
})
|
||||
})
|
||||
];
|
||||
var style = new OpenLayers.Style2({rules: rules});
|
||||
t.ok(style instanceof OpenLayers.Style2, "correct type");
|
||||
t.eq(style.rules.length, 2, "correct number of rules added");
|
||||
t.ok(style.rules[0] === rules[0], "correct first rule added");
|
||||
t.ok(style.rules[1] === rules[1], "correct second rule added");
|
||||
}
|
||||
|
||||
function test_destroy(t) {
|
||||
t.plan(1);
|
||||
|
||||
var style = new OpenLayers.Style2({
|
||||
rules: [
|
||||
new OpenLayers.Rule({
|
||||
symbolizers: [
|
||||
new OpenLayers.Symbolizer.Point({
|
||||
fillColor: "fuchsia"
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
});
|
||||
style.destroy();
|
||||
t.ok(!style.rules, "rules array gone");
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user