vickarasu

Overlapping features and labels

Discussion created by vickarasu on Sep 26, 2011
I need to avoid the overlapping of a point feature layer with the labels of another layers, so I wrote the following code, but it does not work properly. When I set the minimum or maximum scale where the labels of the points are goint to be visible, the labels of the other layers overlap with the point layer. Any help would be appreciated. Thanks in advance!

public static IGeoFeatureLayer GeneraEtiquetas(ILayer pLayer,string ScriptExpresion, string SQLexpresion, double escalaMinima,double escalaMaxima, IFontDisp fuente, IRgbColor color,
            bool sombreado, IMask pMask, esriBasicOverposterWeight labelWeight,esriBasicOverposterWeight featureWeight, bool pintarEtiquetas)
        {
            try
            {
                IGeoFeatureLayer pGeoFeatureLayer = (IGeoFeatureLayer)pLayer;
                pGeoFeatureLayer.AnnotationProperties.Clear();

                ILabelEngineLayerProperties pLabelEngineProperties = new LabelEngineLayerPropertiesClass();
                IFormattedTextSymbol pFTextSymbol = new TextSymbolClass();
                pFTextSymbol.Color = color;
                pFTextSymbol.Font = fuente;

                if (sombreado && pMask == null)
                {
                    IRgbColor pColorSombreado = new RgbColorClass();
                    pColorSombreado.Red = 128;
                    pColorSombreado.Green = 128;
                    pColorSombreado.Blue = 128;
                    pFTextSymbol.ShadowColor = (IColor)pColorSombreado;

                    pFTextSymbol.ShadowXOffset = 1.5;
                    pFTextSymbol.ShadowYOffset = -1.5;
                }

                pLabelEngineProperties.Symbol = (ITextSymbol)pFTextSymbol;

                if (sombreado && pMask != null)
                {
                    pLabelEngineProperties.Symbol = (ITextSymbol)pMask;
                }

                pLabelEngineProperties.BasicOverposterLayerProperties.LabelWeight = labelWeight;
                pLabelEngineProperties.BasicOverposterLayerProperties.FeatureWeight = featureWeight;

                IAnnotateLayerProperties pAnnotateLayerProperties = (IAnnotateLayerProperties)pLabelEngineProperties;
                pAnnotateLayerProperties.DisplayAnnotation = pintarEtiquetas;
                pAnnotateLayerProperties.FeatureLayer = pGeoFeatureLayer;
                //pAnnotateLayerProperties.LabelWhichFeatures = esriLabelWhichFeatures.esriVisibleFeatures;

                pAnnotateLayerProperties.AnnotationMinimumScale = escalaMinima;
                pAnnotateLayerProperties.AnnotationMaximumScale = escalaMaxima;
                pAnnotateLayerProperties.UseOutput = true;

                pLabelEngineProperties.Expression = ScriptExpresion;
                pAnnotateLayerProperties.WhereClause = SQLexpresion;

                pGeoFeatureLayer.AnnotationProperties.Add(pAnnotateLayerProperties);
                pGeoFeatureLayer.DisplayAnnotation = pintarEtiquetas;

.....

Outcomes