diff --git a/examples/style-rules.html b/examples/style-rules.html new file mode 100644 index 0000000000..db2c3e3401 --- /dev/null +++ b/examples/style-rules.html @@ -0,0 +1,43 @@ + + + OpenLayers Rule Based Style + + + + + + +

Rule Based Style

+ +

+ Use rule based styling to use different symbolizers for different + feature groups. +

+ +
+ +
+

+ This example uses four rules to render features. Rules are + based on a feature attribute and determine which symbolizer + is applied when rendering a feature. The rules in this example + change which marker is used by providing an externalGraphic + property in the symbolizer. +

+ The features are labeled with the same attribute that determines + the symbolizer used. You should be able to confirm that the + graphic color corresponds to the range of numbers given below. +

+ +

+ See the + style-rules.js source to see how this is done. +

+
+ + \ No newline at end of file diff --git a/examples/style-rules.js b/examples/style-rules.js new file mode 100644 index 0000000000..0b734abd62 --- /dev/null +++ b/examples/style-rules.js @@ -0,0 +1,99 @@ +var map; + +function init() { + map = new OpenLayers.Map("map"); + + var wms = new OpenLayers.Layer.WMS( + "OpenLayers WMS", + "http://labs.metacarta.com/wms/vmap0", + {layers: "basic"} + ); + + /** + * Create 50 vector features. Your features would typically be fetched + * from the server. These are created here to demonstrate a rule based + * style. The features are given an attribute named "foo". The value + * of this attribute is an integer that ranges from 0 to 100. + */ + var features = new Array(25); + for (var i=0; i