[OpenLayers-Users] Hide features

Andreas Hocevar ahocevar at opengeo.org
Sat Jan 3 11:30:18 EST 2009


Hi,

On Wed, Dec 3, 2008 at 10:05 PM, Heidt, Christopher M.
<CHRISTOPHER.M.HEIDT at saic.com> wrote:
> How do I hide features?
> I did it by changing my opacity to 0,
> but I need to find another way because my features can have multiple
> styles,
> and I need the feature to retain whatever style it has when hidden and
> reshown.

You just need to set the symbolizer (style) property "display" to
"none" (like in CSS).

So instead of
var symbolizer = {
    opacity: 0
}

you set

var symbolizer = {
    ...
    display: "none",
    ...
}

No other symbolizer properties will be lost (but the same is true for
your opacity hack), and the feature will not be rendered until you
delete the display property (or set it to a value other than "none").

Regards,
Andreas.


-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



More information about the Users mailing list