Hi,

I am declaring a layer at PageLoad in the following way:
choice_features = new OpenLayers.Layer.Vector("choice_features", { style:
v_style });

Then I am adding the layer in a different function as below:
map.addLayer(new OpenLayers.Layer.GML("choice_features",
"XML1/FeatureGML.xml")); 

But I want to check if this layer exists and remove it before adding it to
the map using the addLayer function. This will ensure that the layer is
created afresh with every fresh request.

For this I have done the following but it doesn't work:

if (map.getLayersByName("choice_features") != null) {
         
map.layers["choice_features"].removeFeatures(map.layers["choice_features"].features);
          //alert("layer removed");
            }

But I get error in the getLayersByName() function.It says object doesn't
support this property.

Can u suggest an alternative method.

Thanks.
-- 
View this message in context: 
http://n2.nabble.com/check-if-a-layer-exists-and-remove-it-tp3566636p3566636.html
Sent from the Mapserver - User mailing list archive at Nabble.com.
_______________________________________________
mapserver-users mailing list
mapserver-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to