Hi, Have a look at this example
http://openlayers.org/dev/examples/styles-context.html The context option of an OpenLayers.Style object offers the possibility to style features by own declared functions. Arnd -----Ursprüngliche Nachricht----- Von: [email protected] [mailto:[email protected]] Im Auftrag von Mak Kolybabi Gesendet: Dienstag, 29. Dezember 2009 17:19 An: [email protected] Betreff: [OpenLayers-Users] Zoom-based feature styling I expect that there's an easy way to do this, but it so far eludes me. I have an OpenLayers.Layer.Vector object called "icons". Each feature in this layer has two attributes that I need to worry about: type and zoom. There are fifty different types, and five different zooms, so far. I already have type-based styling using: new OpenLayers.Rule({ filter: new OpenLayers.Filter.Comparison({ type: OpenLayers.Filter.Comparison.EQUAL_TO, property: "type", value: "type_1" }), symbolizer: { externalGraphic: "/path/to/images/1.png", graphicHeight: 25, graphicWidth: 25, graphicOpacity: 1.0 } })); I realize I could use max/minScaleDenominator to restrict zooms, but 5x50 rules is excessive. What I'm looking for is something like: new OpenLayers.Rule({ filter: new OpenLayers.Filter.Logical({ filters: [ new OpenLayers.Filter.Comparison({ type: OpenLayers.Filter.Comparison.EQUAL_TO, property: "type", value: "type_1" }), new OpenLayers.Filter.Comparison({ type: OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO, property: "zoom", value: map.zoom }) ], type: OpenLayers.Filter.Logical.AND }), symbolizer: { externalGraphic: "/path/to/images/1.png", graphicHeight: 25, graphicWidth: 25, graphicOpacity: 1.0 } })); Except where map.zoom is dynamically evaluated, instead of it being evaluated only when the style is created. Any ideas or suggestions are appreciated. -- Mak Kolybabi Programmer Telenium Inc. 204-957-2821 _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
