I need to create a REST extension that will return JSON looking like that:
"layers" : [ { "MaxScale" : 0,
"MinScale" : 0,
"defaultVisibility" : true,
"geometryType" : null,
"id" : 0,
"name" : "Name",
"parentLayerId" : -1,
"subLayerIds" : [ 1, 2 ]
},
{ "MaxScale" : 0,
"MinScale" : 0,
"defaultVisibility" : false,
"geometryType" : "esriGeometryPoint",
"id" : 1,
"name" : "NAME Offices",
"parentLayerId" : 0,
"subLayerIds" : null
}
...
As I'm able to get almost all informations that I want, I have only issue getting geometryType and defaultVisibility.I was trying to find a way by looking into DOCS, I'm sure If I will be able to get IGeometry interface I should be able to get geometry type, but how to get IGeometry interface starting from IMapServer3? Or there is other way to do it?Here is a code that is creating list of layers in JSON format:
private XxxLayerInfo[] GetLayerInfos()
{
IMapServer3 mapServer = _serverObjectHelper.ServerObject as IMapServer3;
if (mapServer == null)
throw new Exception("Unable to access xyz map server.");
IMapServerInfo msInfo = mapServer.GetServerInfo(mapServer.DefaultMapName);
IMapLayerInfos layerInfos = msInfo.MapLayerInfos;
int length = layerInfos.Count;
XxxLayerInfo[] xxxLayerInfos = new XxxLayerInfo;
for(int i = 0; i < length; i++)
{
IMapLayerInfo layerInfo = layerInfos.get_Element(i);
xxxLayerInfos = XxxLayerInfo.CreateXxxLayerInfo(layerInfo);
}
return xxxLayerInfos;
}
public static XxxLayerInfo CreateXxxLayerInfo(IMapLayerInfo mapLayerInfo)
{
var layer = new XxxLayerInfo();
layer.Id = mapLayerInfo.ID;
layer.Name = mapLayerInfo.Name;
layer.GeometryType = null; //mapLayerInfo.GeometryType - HOW TO GET this?;
layer.DefaultVisibility = false; //mapLayerInfo.DefaultVisibility - HOW TO GET this?;
layer.MinScale = mapLayerInfo.MinScale;
layer.MaxScale = mapLayerInfo.MaxScale;
layer.ParentLayerId = mapLayerInfo.ParentLayerID;
layer.SubLayers = mapLayerInfo.SubLayers;
return layer;
}
Any ideas? thanks!