[OpenLayers-Users] Disable Features Problem

Andreas Hocevar ahocevar at opengeo.org
Tue Nov 29 14:08:42 EST 2011


Hi,

try {display: "none"} instead of "none" as value for the style.

Andreas.

On Tue, Nov 29, 2011 at 1:13 PM, matth1as <mnick86 at gmail.com> wrote:
> Hi, I have a Vector Layer with Features from a GeoJSON source:
>
> sundials = new OpenLayers.Layer.Vector("KML", {
>  projection: map.displayProjection,
>  strategies: [new OpenLayers.Strategy.Fixed()],
>  protocol: new OpenLayers.Protocol.HTTP({
>  url: "nodes.gojson.php",
>  format: new OpenLayers.Format.GeoJSON({}),
> }) });
>
> The Feature's attributes contain:
>  - icon
>  - category (e.g. food, drink, sports)
>
> var vector_style = new OpenLayers.Style({
>  'externalGraphic': "img/${icon}",
>  'backgroundGraphic': "img/marker_shadow.png",
>  'backgroundXOffset': 0,
>  'backgroundYOffset': -7,
>  'pointRadius':18
> });
>
>  var vector_style_map = new OpenLayers.StyleMap({'default': vector_style});
>  sundials.styleMap = vector_style_map;
>
> So far so good, works as expected.
>
> Now I want dynamically hide / show Features based on the attribute
> "category"
>
> att = sundials.features;
> for (i = 0; i < att.length; i++)  {
>  category = att[i].attributes.category;
>  if (category == "sports") {
>  att[i].style = visibility; //visibility = "none" --> hides the features;
> visibility=null show features again
>  }
> }
> sundials.redraw();
>
> This works as expected on Firefox, but when I use IE the features doesn't
> disappear!
>
> Is there a better way to dynamically hide/show features ?!
>
>
> --
> View this message in context: http://osgeo-org.1803224.n2.nabble.com/Disable-Features-Problem-tp7042623p7042623.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>



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


More information about the Users mailing list