AnsweredAssumed Answered

What replaced IMapServerObjects? How do I getMap from IServerObject or IMapServer

Question asked by lgoens on Sep 16, 2016

I inherited an older Sever Object Extension that was written for ArcGIS Server 10 and I need to reuse it now in a 10.3.1 ArcGIS Server. It's used for creating printouts (pdf) and in the code the map needs to be placed into the template. For which, there is a method to get and return the map to the template. The logic basically takes an IServerObject and casts it to an IMapServer object. The IMapServer object is then cast to IMapServerObjects. From the IMapServerObject, the Map property was returned and later inserted into the print template. I read somewhere that IMapServerObject was deprecated  and now when this code executes, the IMapServerObjects object is null... and therefore no Map to return.

 

I'm relatively unfamiliar with ArcObjects, but I feel like I'm missing something obvious. How do I get the map? I can create the IMapServer object, and it has a MapCount of 1 so it seems like it's there... just not sure how to capture it. Old code looked like this and used to work...

 

public static IMap GetMap(this IServerObject source, string mapName)
{
    if (source == null) return null;

    var mapServer = source as IMapServer;
    if (mapServer == null) return null;

    var mapServerObjects = mapServer as IMapServerObjects2;
    if (mapServerObjects == null) return null;

    IMap map = mapServerObjects.get_Map(mapName);

    return map;
}

Outcomes