GetLayerByName() public method

Returns a layer by its name
public GetLayerByName ( string name ) : SharpMap.Layers.ILayer
name string Name of layer
return SharpMap.Layers.ILayer
Example #1
0
        public void Map_GetLayerByNameInGroupLayer()
        {
            Map m = new Map();
            VectorLayer vlay1 = new VectorLayer("1");
            VectorLayer vlay2 = new VectorLayer("2");
            VectorLayer vlay3 = new VectorLayer("3");
            m.Layers.Add(vlay1);

            LayerGroup lg = new LayerGroup("Group");
            lg.Layers.Add(vlay2);
            lg.Layers.Add(vlay3);
            m.Layers.Add(lg);


            var lay = m.GetLayerByName("1");
            Assert.IsNotNull(lay);
            Assert.AreEqual("1",lay.LayerName);
            lay = m.GetLayerByName("2");
            Assert.IsNotNull(lay);
            Assert.AreEqual("2", lay.LayerName);
            lay = m.GetLayerByName("3");
            Assert.IsNotNull(lay);
            Assert.AreEqual("3", lay.LayerName);
            lay = m.GetLayerByName("Group");
            Assert.IsNotNull(lay);
            Assert.AreEqual("Group", lay.LayerName);
            
        }
Example #2
0
        public void GetLayerByName_ReturnCorrectLayer()
        {
            Map map = new Map();
            map.Layers.Add(new VectorLayer("Layer 1"));
            map.Layers.Add(new VectorLayer("Layer 3"));
            map.Layers.Add(new VectorLayer("Layer 2"));

            ILayer layer = map.GetLayerByName("Layer 2");
            Assert.IsNotNull(layer);
            Assert.AreEqual("Layer 2", layer.LayerName);
        }