Select to view content in your preferred language

Display the Labels after zoom to a particular scale

744
0
10-02-2010 06:03 AM
ShreyPrasad
Deactivated User
Hello friend ,

   After the user selects the layer for which he want to view label.  The map check the scale and if it the desired scale it will display all the layers


can any one please show me how to do  it.




        private void frmLabel_Load(object sender, EventArgs e)
        {
            try
            {


                string path = "E:\\Singapore_Data.mdb";
                pPropset = new PropertySetClass();
                pPropset.SetProperty("DATABASE", path);

                wFact = new AccessWorkspaceFactoryClass();
                wSpace = wFact.Open(pPropset, 0);
                GetFeatureClassesfromWS(wSpace);

            }

            catch (Exception ex)
            {
                MessageBox.Show("" + ex);
            }
                   
        }//frmLAbel Closes





        public void GetFeatureClassesfromWS(IWorkspace wSpace)
        {
            IEnumDataset pEnumDataset;
            IDataset pDataset;
            IFeatureClass pFeatClass;
            IEnumFeatureClass pEnumFeatClass;


            pEnumDataset = wSpace.get_Datasets(esriDatasetType.esriDTFeatureClass);
            pDataset = pEnumDataset.Next();
            while (pDataset != null)
            {
                // combobox.additem pDataset.Name
                cmbLayer.Items.Add(pDataset.Name);
                pDataset = pEnumDataset.Next();
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            //if (cmbLayer.SelectedValue != null)
            //{
              
                m_pMxdocument = m_application.Document  as IMxDocument;
                pMap = m_pMxdocument.FocusMap;
                IActiveView pActiveView = (IActiveView)pMap;
                pActiveView = m_pMxdocument.ActiveView;
                if (m_pMxdocument.ActiveView.FocusMap.MapScale < 2000)
                {
                    IGeoFeatureLayer geoflay = pMap.get_Layer(3) as IGeoFeatureLayer;
                    IAnnotateLayerPropertiesCollection annopropcol;
                    IAnnotateLayerProperties annolayprop;
                    IElementCollection enumvisiblecol;
                    annopropcol = geoflay.AnnotationProperties;
                    annopropcol.QueryItem(0, out annolayprop, out enumvisiblecol, out enumvisiblecol);
                    ILabelEngineLayerProperties labengprop = annolayprop as ILabelEngineLayerProperties;

                    labengprop.Expression = "HOUSE_BLK_";  // field name
                    geoflay.DisplayAnnotation = true;
                    annolayprop.LabelWhichFeatures = esriLabelWhichFeatures.esriVisibleFeatures;
                    m_pMxdocument.ActiveView.Refresh();


                }
              
             
            //}


This the code i am using this code
0 Kudos
0 Replies