This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ArcObjects namespaces > Carto > ESRI.ArcGIS.Carto > Interfaces > ID > IDynamicLayerDescription Interface > IDynamicLayerDescription.DrawingDescription Property (ArcObjects .NET 10.5 SDK) |
Drawing Descriptions.
[Visual Basic .NET] Public Property DrawingDescription As ILayerDrawingDescription
[C#] public ILayerDrawingDescription DrawingDescription {get; set;}
[C++]
HRESULT get_DrawingDescription(
ILayerDrawingDescription** ppLayerDrawingDescription
);
[C++]
HRESULT putref_DrawingDescription(
ILayerDrawingDescription* ppLayerDrawingDescription
);
[C++]
Parameters ppLayerDrawingDescription [out, retval]
ppLayerDrawingDescription is a parameter of type ILayerDrawingDescription ppLayerDrawingDescription [in]
ppLayerDrawingDescription is a parameter of type ILayerDrawingDescription
By setting this property, a user can override how features of an existing layer in a mapservice are drawn or set the renderer for a new layer added to to a mapservice dynamically. MapServer does not allow drawing description of all types of layer to be modified. Please check IMapLayerInfo4::CanModifyDrawingDescription property to find out whether you can change the renderer.
This is important to note that this is a stateless change. MapServer does not remember this change for the next request. It only affects that particular request what that means is that once the request is processed, MapServer does not remember that change and the next request comes in, MapServer processes that with layer's original state (the way it is defined in the source map document).
To set the layer back to the original state in your application session, you can set this property to Null or get the DefaultMapDescription from the server by calling GetServerInfo function.
You can create a new a DrawingDescription object with new renderer and set that to this property. Sometimes you may want to modify symbol for only one type of feature (in case of UniqueValueRenderer) or symbol of a ClassBreak, in this case you can get the default renderer information by calling GetDefaultLayerDrawingDescription. Then modify it and set it to this property. Please note GetDefaultLayerDrawingDescription may return simplified version of the symbol or some renderer may not be even supported - read the help for more information.
MapServer also has a helper function to assist you create renderer - you can use IMapServer4::GenerateDataClasses method to get UniqueValueRenderer or ClassBreaksRenderer created by MapServer.
Example #1: set a simple render to a layer (assuming you have variables i.e. pMapServer, pMapDescription, pLayerDescription and pImageDescription are referenced correctly)
//symbol for polygon outline
IRgbColor pGreyColor=new RgbColor()
{
Red=110,
Green=110,
Blue=110
};
ISimpleLineSymbol pOutline=new SimpleLineSymbol()
{
Style=esriSimpleLineStyle.esriSLSSolid,
Width=1,
Color=pGreyColor
};
//Solid fill symbol with red fill color
IRgbColor pRedColor=new RgbColor();
pRedColor.Red=255;
ISimpleFillSymbol pSimpleFillSymbol=new SimpleFillSymbol()
{
Style=esriSimpleFillStyle.esriSFSSolid,
Color=pRedColor,
Outline=pOutline
};
ISimpleRenderer pSimpleRenderer=new SimpleRenderer();
pSimpleRenderer.Symbol=(ISymbol)pSimpleFillSymbol;
pSimpleRenderer.Label="Rivers";
//setting LayerDrawingDescription
IFeatureLayerDrawingDescription2 pFLDD=new FeatureLayerDrawingDescription() as IFeatureLayerDrawingDescription2;
pFLDD.FeatureRenderer=pSimpleRenderer as IFeatureRenderer;
((IDynamicLayerDescription)pLayerDescription).DrawingDescription=pFLDD as ILayerDrawingDescription;
IMapImage pMapImage=pMapServer.ExportMapImage(pMapDescription, pImageDescription);
Console.WriteLine(pMapImage.URL);
Example #2: changing only the DefaultSymbol for a layer (assuming you have variables i.e. pMapServer, pMapDescription, pLayerDescription, pImageDescription and strCurrentMapName are referenced correctly)
//symbol for polygon outline
IRgbColor pGreyColor=new RgbColor()
{
Red=110,
Green=110,
Blue=110
};
ISimpleLineSymbol pOutline=new SimpleLineSymbol()
{
Style=esriSimpleLineStyle.esriSLSSolid,
Width=1,
Color=pGreyColor
};
//Solid fill symbol with red fill color
IRgbColor pRedColor=new RgbColor();
pRedColor.Red=255;
ISimpleFillSymbol pSimpleFillSymbol=new SimpleFillSymbol()
{
Style=esriSimpleFillStyle.esriSFSSolid,
Color=pRedColor,
Outline=pOutline
};
//getting the default drawing description of the first layer
ILongArray pLyrIDs=new LongArray();
pLyrIDs.Add(layerID);
ILayerDrawingDescriptions pLDDs=((IMapServer3)pMapServer).GetDefaultLayerDrawingDescriptions(strCurrentMapName, pLyrIDs, null);
IFeatureLayerDrawingDescription2 pFlyrDD=pLDDs.get_Element(0) as IFeatureLayerDrawingDescription2;
//getting the renderer and changing the defaultSymbol to solid fill with red color
IUniqueValueRenderer pUVR=pFlyrDD.FeatureRenderer as IUniqueValueRenderer;
pUVR.DefaultSymbol=(ISymbol)pSimpleFillSymbol;
//setting the renderer and changing the defaultSymbol to solid fill with red color
((IDynamicLayerDescription)pLayerDescription).DrawingDescription=pFlyrDD as ILayerDrawingDescription;
IMapImage pMapImage=m_pMapServer.ExportMapImage(pMapDescription, pImageDescription);
Console.WriteLine(pMapImage.URL);