evicent

Spatial Reference of ILayer C#

Discussion created by evicent on Apr 17, 2012
Latest reply on Apr 18, 2012 by kenbuja
Hi everybody!

I want to Know how can I put the Spatial Reference of the layers of a Map in a message box.

     protected override void OnClick()
        {
            IActiveView activeView = ArcMap.Document.ActiveView;
            IMap focusMap = ArcMap.Document.FocusMap;
            ILayer layer;
            IEnumLayer layermap;
            layermap = focusMap.get_Layers(null, true);             

            layer = layermap.Next();

            while (layer != null)
            {
                MessageBox.Show("The spatial reference of the map is: " + focusMap.SpatialReference.Name +
                                 "the spatial reference of the layer is :" + layer.SpatialReference.Name);
    
                layer = layermap.Next();
            }

        }



The error appears when I define the property of the layer in the Message Box.

The property or indexer 'ESRI.ArcGIS.Carto.ILayer.SpatialReference' cannot be used in this context because it lacks the get accessor

I saw a lot of material but I don´t find how can I solve it.


Thanks

Outcomes