Help me get started... how to get access to the map and its layers from a REST SOE?

1932
2
Jump to solution
02-02-2012 09:18 AM
Highlighted
New Contributor III
OK... so I'm pretty stoked... using the templates and the samples, I have created a REST server object extension, that takes in some strings as parameters and returns a string back after I publish the map and select my custom service as a Capability.   But I'm VERY green at ArcObjects still, so help me get past this one simple concept and I think I can start to "get it"... 

In my Operation Handler, I have access to serverObjectHelper... and it has the IServerObject as it's property... if I output the "ConfigurationName" I get back the name of my MapService... which makes sense.   But what if I wanted access to the FeatureLayers contained in the map that the mapservice is based on?   What is the code (in c# preferably) to say, list out all the names of the layers in the map (or mapservice)?  

Any help would be greatly appreciated!
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
New Contributor III
So the end answer is:
for (int x = 0; x < myInfo.MapLayerInfos.Count; x++)
            {
                result.AddString("Layer" + (x+1).ToString(), myInfo.MapLayerInfos.get_Element(x).Name);
            }

More questions to come!  😄

View solution in original post

Reply
0 Kudos
2 Replies
Highlighted
New Contributor III
WOW... this stuff is amazing:

            IServerObject myMapService = serverObjectHelper.ServerObject;
            MapServer myServer = (MapServer)myMapService;
            string MapServiceName = serverObjectHelper.ServerObject.ConfigurationName.ToString();
            string MapInfo = "MAP (frame): " + myServer.DefaultMapName.ToString();
            MapInfo += " Number of Frames: " + myServer.MapCount.ToString();
            MapInfo += " Title: " + myServer.DocumentInfo.GetProperty("Title").ToString();
            IMapServerInfo myInfo = myServer.GetServerInfo(myServer.DefaultMapName);
            MapInfo += " LayerCount: " + myInfo.MapLayerInfos.Count.ToString();
            IMapLayerInfo myLayer = myInfo.MapLayerInfos.get_Element(0);
            MapInfo += " Layer_Name: " + myLayer.Name;
Reply
0 Kudos
Highlighted
New Contributor III
So the end answer is:
for (int x = 0; x < myInfo.MapLayerInfos.Count; x++)
            {
                result.AddString("Layer" + (x+1).ToString(), myInfo.MapLayerInfos.get_Element(x).Name);
            }

More questions to come!  😄

View solution in original post

Reply
0 Kudos