I was trying to explore the Annotations and Labelling for features. I wanted a transmedia feature class would show the name of it when added in the map. Here is what I did in the code.

            IMxDocument mxdoc = _application.Document as IMxDocument;
            IMap map = mxdoc.FocusMap;
            IEnumLayer layers = map.Layers;
            ILayer layer = layers.Next();
            IFeatureLayer2 statesFL = null;
            while (layer != null)
                if (layer is IFeatureLayer2 && layer.Name == "NE.TRANSMEDIA")
                    statesFL = layer as IFeatureLayer2;
                layer = layers.Next();
            if (statesFL == null)
            IGeoFeatureLayer geoFeatureL = statesFL as IGeoFeatureLayer;
            IAnnotateLayerPropertiesCollection annotateLPC = geoFeatureL.AnnotationProperties;
            string name = statesFL.DisplayField.ToString();

            IAnnotateLayerProperties annotateLP = new LabelEngineLayerPropertiesClass();
            IAnnotateLayerProperties annotateLP2 = new LabelEngineLayerPropertiesClass();
            annotateLP.Class = "LowerScale";
            annotateLP.AnnotationMaximumScale = 1000;
            annotateLP.AnnotationMinimumScale = 10000;
            annotateLP2.Class = "HigherScale";
            annotateLP2.AnnotationMaximumScale = 1000;
            annotateLP2.AnnotationMinimumScale = 10000;

            ILabelEngineLayerProperties2 labelELP1 = annotateLP as ILabelEngineLayerProperties2;
            ILabelEngineLayerProperties2 labelELP2 = annotateLP2 as ILabelEngineLayerProperties2;
            labelELP1.Expression = string.Format("\"Transmedia Name: \" + [name] ");
            labelELP2.Expression = "";

It did not executed properly when I try to run it gives me the error message for High Scale. Can anyone please help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.