[OpenLayers-Users] Zoom-based feature styling
Arnd Wippermann
arnd.wippermann at web.de
Tue Dec 29 15:50:44 EST 2009
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: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von Mak Kolybabi
Gesendet: Dienstag, 29. Dezember 2009 17:19
An: users at openlayers.org
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
More information about the Users
mailing list