ArcMap One function is label features, which means that the specified field values in the layer can be displayed as labels in the main window. After features, right-click the layer and you will find a gray feature name, convertlabelstoannotation. This function is provided in AE, However, you cannot find the location where the field value is set. Create a note layer and generate a note based on the field values specified in the layer. Is a feature point conversion. It may be less efficient than the interfaces provided by AE. I will not use that interface, so I can barely use it. In this regard, the most difficult thing is to create a new note layer. There are many attributes that need to be set, which is troublesome. below is the code Private void converttoannotationlayer (IMAP pmap, ilayer player, string fieldname, esrigeometrytype) ...{ Ifeaturelayer pfeatlayer = player as ifeaturelayer;
Int I = pfeatlayer. featureclass. findfield ("shape "); Ifield pshapefield = pfeatlayer. featureclass. Fields. get_field (I ); Idataset pdataset = pfeatlayer. featureclass as idataset; Iworkspace PWS = pdataset. workspace; Ifeatureworkspace pfeatws = PWS as ifeatureworkspace;
Igeofeaturelayer pgeofeatlayer = pfeatlayer as igeofeaturelayer; Ifields pfields = pgeofeatlayer. featureclass. fields;
Iannotationlayerfactory pannolayerfact = new fdographicslayerfactoryclass (); Igraphicslayerscale pgraphyscale = new graphicslayerscaleclass (); Pgraphyscale. referencescale = 200000; Pgraphyscale. Units = esriunits. esrimeters; Iannotationlayer pannolayer = NULL;
Isymbolcollection2 psymcoll = new symbolcollectionclass (); Iformattedtextsymbol ptextsymbol = new textsymbolclass (); Irgbcolor prgb = new rgbcolorclass (); Prgb. Red = 0; Prgb. Blue = 0; Prgb. Green = 0; Ptextsymbol. Color = prgb;
/** // * Ptextsymbol. font = */
M_fontdisp.size = 8; Ptextsymbol. font = m_fontdisp; Ptextsymbol. horizontalalignment = esritexthorizontalalignment. esrithacenter; Ptextsymbol. verticalalignment = esritextverticalalignment. esritvabaseline; Ptextsymbol. characterspacing = 100; Ptextsymbol. characterwidth = 50; Ptextsymbol. wordspacing = 100;
// Iboundsproperties pboundprop = ptextsymbol as iboundsproperties; /** // * Pboundprop. fixedsize = false ;*/ // Pboundprop. fixedaspectratio = true; Isymbol psymbol = ptextsymbol as isymbol; Isymbolidentifier2 psymident2; Psymcoll. addsymbol (psymbol, fieldname, out psymident2 ); Isymbolcollection psymcoll1 = psymcoll as isymbolcollection;
Ioverposterproperties poverpost = new basicoverposterpropertiesclass ();
Iannotatelayerpropertiescollection pannopropcoll = new annotatelayerpropertiescollectionclass (); Iannotatelayerproperties pannoprop; Ilabelenginelayerproperties2 plabelengine = new labelenginelayerpropertiesclass (); Plabelengine. annotationclassid = 0; Plabelengine. symbol = ptextsymbol; Plabelengine. symbolid = psymident2.id; Pannoprop = plabelengine as iannotatelayerproperties; Pannoprop. Class = player. Name + fieldname; Pannoprop. labelwhichfeatures = esrilabelwhichfeatures. esriallfeatures; Pannoprop. Priority = 0; Iactiveview pactview = pmap as iactiveview; Pannoprop. graphicscontainer = pactview. graphicscontainer; Pannoprop. featurelayer = pfeatlayer; Pannoprop. featurelinked = true; Pannoprop. annotationmaximumscale = 10000000000000000000; Pannoprop. annotationminimumscale = 0.00000000001; Pannopropcoll. Add (pannoprop ); Try ...{ Pannolayer = pannolayerfact. createannotationlayer (pfeatws, pfeatlayer. featureclass. featuredataset, player. Name + "_ A _" + fieldname, pshapefield. geometrydef, Null, pannopropcoll, pgraphyscale, psymcoll1, false, true, poverpost ,"");
} Catch (exception S) ...{ String MEs = S. message; } If (pannolayer = NULL) Return; Int num = pfields. findfield (fieldname ); Converttoannotatebyfeature (player, num, ref pannolayer ); Pmap. addlayer (pannolayer as ilayer ); } |