vickarasu

Coordinate system of an arcgis server map

Discussion created by vickarasu on Apr 26, 2011
Latest reply on Apr 26, 2011 by vickarasu
I would like to know how can I get the coordinate system of a map or a dataframe when a mapserver is loaded in an axmapcontrol. I try to get it with IMapServerObjects interface, but when I do QI with the MapServer object it crashes.

Any help or idea would be useful. Thank you very much

This is the code I use:

                try
                {
                    ILayerFactory pLayerFactory = new MapServerLayerFactoryClass();

                    IName pName;
                    IMapServer pMapServer;
                   
                    IAGSEnumServerObjectName enumSOName = AGSConnection.ServerObjectNames;
                    IAGSServerObjectName SOName = enumSOName.Next();
                    while (SOName != null)
                    {
                        if (SOName.Name == tabla && pLayerFactory.get_CanCreate(SOName))
                        {
                            pName = (IName)SOName;
                            pMapServer =(IMapServer)pName.Open();
                            IMapServerLayer pMapServerLayer = new MapServerLayerClass();
                            pMapServerLayer.ServerConnect(SOName, pMapServer.DefaultMapName);

                            IMapServerObjects pMapServerObjects = (IMapServerObjects)pMapServer;
-ERROR

pMapServerObjects.get_Map(pMapServer.DefaultMapName).SpatialReference.ToString();

                            pLayer = (ILayer)pMapServerLayer;

                            return;
                        }
                        SOName = enumSOName.Next();
                    }
                }
                catch (Exception Err)
                {
                    Logger.Logger.EscrituraLog("Error", Err.Message + " - " + Err.TargetSite);
                }

Outcomes