[OpenLayers-Users] Disable Features Problem

matth1as mnick86 at gmail.com
Tue Nov 29 07:13:13 EST 2011


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.


More information about the Users mailing list