当前位置: 首页>>代码示例>>C#>>正文


C# IMap.AddLayer方法代码示例

本文整理汇总了C#中IMap.AddLayer方法的典型用法代码示例。如果您正苦于以下问题:C# IMap.AddLayer方法的具体用法?C# IMap.AddLayer怎么用?C# IMap.AddLayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMap的用法示例。


在下文中一共展示了IMap.AddLayer方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnClick

        public override void OnClick()
        {
            try
            {
                var mxdoc = (IMxDocument)_application.Document;
                _map = mxdoc.FocusMap;

                var addWmsCForm = new AddWmsCForm();
                var result = addWmsCForm.ShowDialog(new ArcMapWindow(_application));

                if (result == DialogResult.OK)
                {
                    var tileSource = addWmsCForm.SelectedTileSource;

                    IConfig configWmsC = new ConfigWmsC(tileSource);
                    var brutileLayer = new BruTileLayer(_application,configWmsC)
                    {
                        Name = configWmsC.CreateTileSource().Schema.Name,
                        Visible = true
                    };
                    _map.AddLayer(brutileLayer);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
开发者ID:smileliaohua,项目名称:TrafficSpider,代码行数:28,代码来源:AddWmsCLayerCommand.cs

示例2: InitializeNetworkAndMap

 //初始化
 private bool InitializeNetworkAndMap(IFeatureDataset Featuredataset,System.Collections.ArrayList array1,System.Collections.ArrayList array2,int flag)
 {
     IFeatureClassContainer ipFeatureClassContainer;
     IFeatureClass ipFeatureClass;
     IGeoDataset ipGeoDataset;
     ILayer ipLayer;
     IFeatureLayer ipFeatureLayer;
     IEnvelope ipEnvelope, ipMaxEnvelope;
     double dblSearchTol;
     INetworkCollection ipNetworkCollection = Featuredataset as INetworkCollection;
     int count = ipNetworkCollection.GeometricNetworkCount;
     barrierarray1 =(System.Collections.ArrayList)array1.Clone();
     barrierarray2 = (System.Collections.ArrayList)array2.Clone();
     barrierflag = flag;
     //获取几何网络工作空间
     m_ipGeometricNetwork = ipNetworkCollection.get_GeometricNetwork(0);
     INetwork ipNetwork = m_ipGeometricNetwork.Network;
     if (m_ipMap != null)
     {
         m_ipMap = new MapClass();
         ipFeatureClassContainer = m_ipGeometricNetwork as IFeatureClassContainer;
         count = ipFeatureClassContainer.ClassCount;
         for (int i = 0; i < count; i++)
         {
             ipFeatureClass = ipFeatureClassContainer.get_Class(i);
             ipFeatureLayer = new FeatureLayerClass();
             ipFeatureLayer.FeatureClass = ipFeatureClass;
             m_ipMap.AddLayer(ipFeatureLayer);
         }
     }
     count = m_ipMap.LayerCount;
     ipMaxEnvelope = new EnvelopeClass();
     for (int i = 0; i < count; i++)
     {
         ipLayer = m_ipMap.get_Layer(i);
         ipFeatureLayer = ipLayer as IFeatureLayer;
         ipGeoDataset = ipFeatureLayer as IGeoDataset;
         ipEnvelope = ipGeoDataset.Extent;
         ipMaxEnvelope.Union(ipEnvelope);
     }
     m_ipPointToEID = new PointToEIDClass();
     m_ipPointToEID.SourceMap = m_ipMap;
     m_ipPointToEID.GeometricNetwork = m_ipGeometricNetwork;
     double dblWidth = ipMaxEnvelope.Width;
     double dblHeight = ipMaxEnvelope.Height;
     if (dblWidth > dblHeight)
         dblSearchTol = dblWidth / 100;
     else
         dblSearchTol = dblHeight / 100;
     m_ipPointToEID.SnapTolerance = dblSearchTol;
     return true;
 }
开发者ID:dengkliu,项目名称:Urban-Transportation-Navigation-System,代码行数:53,代码来源:ClsPathFinder.cs

示例3: CreateFCs

        public static void CreateFCs(IWorkspace pWs, IMap pMap)
        {
            var FC1 = CreateFeatureClass(pWs, null, "Point", CreateFields(esriGeometryType.esriGeometryPoint));
            var FC2 = CreateFeatureClass(pWs, null, "Line", CreateFields(esriGeometryType.esriGeometryPolyline));
            var FC3 = CreateFeatureClass(pWs, null, "Polygon", CreateFields(esriGeometryType.esriGeometryPolygon));

            //insert& show
            List<IGeometry> ptList = new List<IGeometry>(100);
            IPoint pt;
            for (int i = 0; i < 1000; i++)
            {
                pt = new PointClass();
                pt.PutCoords(i * 0.01, i * 0.01);
                ptList.Add(pt);
            }

            List<IGeometry> lineList = new List<IGeometry>(100);
            IPolyline pLine;
            IPoint pt1, pt2;
            for (int i = 0; i < 1000; i++)
            {
                pLine = new PolylineClass();
                pt1 = new PointClass();
                pt1.PutCoords(i * 0.01, (i + 1) * 0.01);
                pt2 = new PointClass();
                pt2.PutCoords(i * 0.01, (i + 11) * 0.01);
                pLine.FromPoint = pt1;
                pLine.ToPoint = pt2;
                lineList.Add(pLine);
            }

            List<IGeometry> polygonList = new List<IGeometry>(100);
            IPolygon pPolygon;
            IPoint pt3, pt4;
            for (int i = 0; i < 1000; i++)
            {
                pPolygon = new PolygonClass();
                IPointCollection ptColl = pPolygon as IPointCollection;
                pt1 = new PointClass();
                pt1.PutCoords(i * 0.01, (i - 2) * 0.01);
                pt2 = new PointClass();
                pt2.PutCoords((i + 1) * 0.01, (i - 2) * 0.01);
                pt3 = new PointClass();
                pt3.PutCoords((i + 1) * 0.01, (i - 3) * 0.01);
                pt4 = new PointClass();
                pt4.PutCoords(i * 0.01, (i - 3) * 0.01);
                ptColl.AddPoint(pt1);
                ptColl.AddPoint(pt2);
                ptColl.AddPoint(pt3);
                ptColl.AddPoint(pt4);
                pPolygon.Close();
                polygonList.Add(pPolygon);
            }

            InsertFeaturesUsingCursor(FC1, ptList);
            InsertFeaturesUsingCursor(FC2, lineList);
            InsertFeaturesUsingCursor(FC3, polygonList);

            IFeatureLayer pFeaturelayer = new FeatureLayerClass();
            pFeaturelayer.Name = "pt";
            pFeaturelayer.FeatureClass = FC1;
            pMap.AddLayer(pFeaturelayer);
            pFeaturelayer = new FeatureLayerClass();
            pFeaturelayer.Name = "line";
            pFeaturelayer.FeatureClass = FC2;
            pMap.AddLayer(pFeaturelayer);
            pFeaturelayer = new FeatureLayerClass();
            pFeaturelayer.Name = "polygon";
            pFeaturelayer.FeatureClass = FC3;
            pMap.AddLayer(pFeaturelayer);
        }
开发者ID:oopsliu,项目名称:qixiangju,代码行数:71,代码来源:InMemory.cs

示例4: initNetwork

        public static void initNetwork(IFeatureDataset pFeaDataset,IMap pMap,out IGeometricNetwork m_ipGeometricNetwork)
        {
            INetworkCollection pNetworkCollection;
            //IGeometricNetwork m_ipGeometricNetwork;
            INetwork pNetwork;
            IFeatureClassContainer ipFeatureClassContainer;
            IFeatureClass ipFeatureClass;
            IFeatureLayer ipFeatureLayer;
            IDataset pDataset;

            //get the network collection
            pNetworkCollection=pFeaDataset as INetworkCollection;

            if(pNetworkCollection.GeometricNetworkCount==0)
            {
                MessageBox.Show("������û������");
                m_ipGeometricNetwork=null;
                return;
            }

            m_ipGeometricNetwork=pNetworkCollection.get_GeometricNetworkByName("Water_Network");

            //m_ipGeometricNetwork.

            //Use the INetwork interface when you want to query the network for general information
            //such as the status of the network or the number of edges in your network.

            pNetwork=m_ipGeometricNetwork.Network;

            //Add each of the Feature Classes in this Geometric Network as a map Layer

            ipFeatureClassContainer=pNetworkCollection as IFeatureClassContainer;

            if(ipFeatureClassContainer.ClassCount==0)
            {
                MessageBox.Show("û������featureClass");
                m_ipGeometricNetwork=null;
                return;
            }

            for(int ii=0;ii<ipFeatureClassContainer.ClassCount;ii++)
            {

                ipFeatureClass=ipFeatureClassContainer.get_Class(ii);

                pDataset=ipFeatureClass as IDataset;

                if(pDataset.Name=="water_arc"||pDataset.Name.Equals("water_point")||pDataset.Name.Equals("Water_Network_Junctions"))
                {

                    ipFeatureLayer=new FeatureLayerClass();

                    ipFeatureLayer.FeatureClass=ipFeatureClass;

                    ipFeatureLayer.Name=pDataset.Name;

                    pMap.AddLayer(ipFeatureLayer);
                }

            }
        }
开发者ID:chinasio,项目名称:Control,代码行数:61,代码来源:SpatialHelperFunction.cs

示例5: LoadFeatureLayerByDatasetName

        public static IFeatureLayer LoadFeatureLayerByDatasetName(string dsName, IMap pMap, IWorkspace pWorkspace)
        {
            IFeatureLayer pFeatureLayerRet = null;
            try
            {
                IFeatureWorkspace pFeatureWS;
                pFeatureWS = (IFeatureWorkspace)pWorkspace;

                IFeatureClass pFeatureClass = pFeatureWS.OpenFeatureClass(dsName);

                ILayer pLayer = new FeatureLayerClass();
                pLayer.Name = dsName;
                IFeatureLayer pFeatureLayer = (IFeatureLayer)pLayer;
                pFeatureLayer.FeatureClass = pFeatureClass;

                if(pMap != null)
                    pMap.AddLayer(pLayer);

                pFeatureLayerRet = pFeatureLayer;

            }
            catch{}

            return pFeatureLayerRet;
        }
开发者ID:EAWCS1,项目名称:SUITT,代码行数:25,代码来源:ToolUtils.cs

示例6: addWMS2map

        /// <summary>Add a WMS to the map</summary>
        /// <param name="map">The map to add the wms to</param>
        /// <param name="WMSurl">the url point to the WMS</param>
        public static void addWMS2map(IMap map, string WMSurl, short transparency = 0)
        {
            IWMSGroupLayer wmsLayerGroup = new WMSMapLayerClass();
            IWMSConnectionName WMSconnName = new WMSConnectionNameClass();
            IName WMSname;
            bool succes;
            IWMSServiceDescription serviceDesc;
            IDataLayer dataLyr;
            ILayer lyr;
            IActiveView view;

            IPropertySet props = new PropertySetClass();
            props.SetProperty("URL", WMSurl);
               // props.SetProperty("VERSION", "1.3.0");

            WMSconnName.ConnectionProperties = props;
            dataLyr = (IDataLayer)wmsLayerGroup;

            WMSname = (IName)WMSconnName;
            try
            {
                succes = dataLyr.Connect(WMSname);
            }
            catch (Exception e)
            {
                MessageBox.Show("Error op wms: " + WMSurl +"\n"+ e.Message + ": " + e.StackTrace);
                return;
            }

            if (!succes)
            {
                MessageBox.Show("Kan onderstaande WMS niet openen. \n" + WMSurl);
                return;
            }

            serviceDesc = wmsLayerGroup.WMSServiceDescription;

            wmsLayerGroup.Expanded = true;
            lyr = (ILayer)wmsLayerGroup;
            lyr.Name = serviceDesc.WMSTitle;

            ILayerEffects layerEffects = (ILayerEffects)lyr;
            layerEffects.Transparency = transparency < 100 ? transparency : (short)100;

            map.AddLayer(lyr);
            view = (IActiveView)map;

            makeCompositeLayersVisibile(lyr);

            view.ContentsChanged();
        }
开发者ID:geopunt,项目名称:geopunt4arcgis,代码行数:54,代码来源:geopuntHelper.cs

示例7: addFunctionRasterToMap

        public void addFunctionRasterToMap(IMap map)
        {
            try
            {
                ofd.Title = "Add Function Model to map";
                ofd.Filter = "Function Dataset|*.fds|Batch Datasets|*.bch|NetCdf|*.nc";
                ofd.Multiselect = false;
                ofd.FilterIndex = 2;
                if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    FunctionDatasetPath = ofd.FileName;
                    int fIndex = ofd.FilterIndex;
                    string outName = "";
                    object outobj = null;
                    string outDesc = "";
                    if (fIndex == 1)
                    {
                        IRaster outRs;
                        createFunctionRaster(out outName, out outRs, out outDesc);
                        outobj = outRs;
                    }
                    else if (fIndex == 2)
                    {
                        createBatchRaster(out outName, out outobj, out outDesc);
                    }
                    else
                    {
                        createNetCdf(out outName, out outobj, out outDesc);
                    }
                    if (outobj is IFunctionRasterDataset)
                    {
                        IRasterLayer rsLyr = new RasterLayerClass();
                        rsLyr.CreateFromDataset((IRasterDataset)outobj);
                        rsLyr.Name = outName;
                        rsLyr.Visible = false;
                        map.AddLayer((ILayer)rsLyr);
                    }
                    else if (outobj is IRaster)
                    {
                        IRasterLayer rsLyr = new RasterLayerClass();
                        rsLyr.CreateFromRaster((IRaster)outobj);
                        rsLyr.Name = outName;
                        rsLyr.Visible = false;
                        map.AddLayer((ILayer)rsLyr);
                    }
                    else if (outobj is FeatureClass)
                    {
                        IFeatureLayer ftrLyr = new FeatureLayerClass();
                        ftrLyr.Name = outName;
                        ftrLyr.Visible = false;
                        ftrLyr.FeatureClass = (IFeatureClass)outobj;
                        map.AddLayer((ILayer)ftrLyr);
                    }
                    else if (outobj is Table)
                    {
                        IStandaloneTableCollection stCol = (IStandaloneTableCollection)map;
                        IStandaloneTable stTbl = new StandaloneTableClass();
                        stTbl.Table = (ITable)outobj;
                        stTbl.Name = outName;
                        stCol.AddStandaloneTable(stTbl);
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show("There was a problem parsing the model. Please check your model file");
                    }

                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Could not add output to the map:" + e.ToString(), "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
        }
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:73,代码来源:functionModel.cs

示例8: CreateRasterFromPoints

        public void CreateRasterFromPoints(IMap pMap, IFeatureLayer pp,String Path, String Name, String Field)
        {
            //1.��Shape�ļ���ȡ��FeatureClass
            //2.����FeatureClass����IFeatureClassDescriptor
            //3.����IRasterRaduis ����
            //����Cell
            //4.��ֵ�����ɱ���
            object obj = null;

            IWorkspaceFactory pShapSpace;

            pShapSpace = new ShapefileWorkspaceFactory();

            IWorkspace pW;

            pW = pShapSpace.OpenFromFile(Path, 0);

            IFeatureWorkspace pFeatureWork;

            pFeatureWork = pW as IFeatureWorkspace;

            IFeatureClass pFeatureClass = pFeatureWork.OpenFeatureClass("Name");

            IGeoDataset Geo = pFeatureClass as IGeoDataset;

            object extend = Geo.Extent;

            object o = null;

            IFeatureClassDescriptor pFeatureClassDes = new FeatureClassDescriptorClass();

            pFeatureClassDes.Create(pFeatureClass, null, Field);

            IRasterRadius pRasterrad = new RasterRadiusClass();

            pRasterrad.SetVariable(10, ref obj);

            object dCell = 0.5;//���Ը��ݲ�ͬ�ĵ�ͼ���������

            IInterpolationOp Pinterpla = new RasterInterpolationOpClass();

            IRasterAnalysisEnvironment pRasterAnaEn = Pinterpla as IRasterAnalysisEnvironment;

            pRasterAnaEn.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, ref dCell);

            pRasterAnaEn.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvValue, ref extend, ref o);

            IGeoDataset pGRaster;

            object hh = 3;

            pGRaster = Pinterpla.IDW((IGeoDataset)pFeatureClassDes , 2, pRasterrad, ref hh);

            ISurfaceOp pSurF;

            pSurF = new RasterSurfaceOpClass();

            IGeoDataset pCour;

            object  o1 = 0;

            pCour = pSurF.Contour(pGRaster, 5, ref o1);

            IFeatureLayer pLa;

            pLa = new FeatureLayerClass();

            IFeatureClass pClass = pCour as IFeatureClass;

            pLa.FeatureClass = pClass;

            pLa.Name = pClass.AliasName;

            pMap.AddLayer(pLa as ILayer);
        }
开发者ID:Krystal001025,项目名称:temp,代码行数:75,代码来源:IDW.cs

示例9: SwitchPasture

        public bool SwitchPasture(string strName)
        {
            m_activePasture = GetPastureByName(strName);
            if (m_activePasture.strPasture == string.Empty)
                return false;

            //
            m_pastureMap = new Map();
            m_pastureMap.Name = m_activePasture.strPasture;

            IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactoryClass();
            IFeatureWorkspace workspace =
                (IFeatureWorkspace)workspaceFactory.OpenFromFile(m_activePasture.strDataDir,0);

            DirectoryInfo pastureDir = new DirectoryInfo(m_activePasture.strDataDir);
            FileInfo[] files = pastureDir.GetFiles("*.shp");
            foreach (FileInfo file in files)
            {
                IFeatureLayer featureLayer = new FeatureLayerClass();
                featureLayer.Name = file.Name;
                featureLayer.Visible = true;
                featureLayer.FeatureClass = workspace.OpenFeatureClass(file.Name);

                m_pastureMap.AddLayer(featureLayer);
            }

            //////////////////////////////////////////////////////////////////////////
            if (m_activePasture.strRasLyr != string.Empty)
            {
                IWorkspaceFactory rasWksFactory = new RasterWorkspaceFactory();
                IRasterWorkspace rasWks = rasWksFactory.OpenFromFile(m_activePasture.strDataDir, 0) as IRasterWorkspace;
                IRasterDataset rasDataset = rasWks.OpenRasterDataset(m_activePasture.strRasLyr);

                IRasterLayer rasLyr = new RasterLayerClass();
                rasLyr.CreateFromDataset(rasDataset);
                LayerHelper.SetLayerColor(rasLyr);

                if (m_adminMap.LayerCount == 3)
                {
                    m_adminMap.AddLayer(rasLyr);
                    m_adminMap.MoveLayer(rasLyr,3);
                }
                else if(m_adminMap.LayerCount == 4)
                {
                    ILayer lyr = m_adminMap.get_Layer(3);
                    if (null != lyr)
                        m_adminMap.DeleteLayer(lyr);

                    m_adminMap.AddLayer(rasLyr);
                    m_adminMap.MoveLayer(rasLyr,3);
                }
            }

            //////////////////////////////////////////////////////////////////////////
            Queue<TreeNode> vistor_queue = new Queue<TreeNode>();
            vistor_queue.Enqueue(m_tree.Nodes[0]);
            while (vistor_queue.Count > 0)
            {
                TreeNode node = vistor_queue.Dequeue();
                if (node.Text == strName)
                    node.ForeColor = Color.BlueViolet;
                else
                    node.ForeColor = Color.Black;

                TreeNode child = node.FirstNode;
                while (null != child)
                {
                    vistor_queue.Enqueue(child);
                    child = child.NextNode;
                }

                return true;
            }

            return false;
        }
开发者ID:niwho,项目名称:ArcGISFundation,代码行数:76,代码来源:DataSource.cs

示例10: RefreshAdministrative

        public void RefreshAdministrative()
        {
            m_adminMap = new Map();

            m_adminMap.Name = @"行政图";

            IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactoryClass();
            IFeatureWorkspace workspace =
                (IFeatureWorkspace)workspaceFactory.OpenFromFile(m_adminDir,
                                                            m_mapcontrol.hWnd);

            int index = 0;

            DirectoryInfo adminDir = new DirectoryInfo(m_adminDir);
            FileInfo[] files = adminDir.GetFiles("*.shp");
            foreach (FileInfo file in files)
            {
                IFeatureLayer featureLayer = new FeatureLayerClass();
                featureLayer.Name = file.Name;
                featureLayer.Visible = (++index == files.Length);
                featureLayer.FeatureClass = workspace.OpenFeatureClass(file.Name);

                ILayerEffects layereffect = featureLayer as ILayerEffects;
                layereffect.Transparency = 60;

                IGeoFeatureLayer geoLayer = featureLayer as IGeoFeatureLayer;

                string strField = @"NAME";
                ITable table = featureLayer as ITable;
                IField field = null;
                for (int i = 0; i < table.Fields.FieldCount; i++)
                {
                    field = table.Fields.get_Field(i);
                    if (field.Name == @"NAME" ||
                        field.Name == @"CITY" ||
                        field.Name == @"COUNTY")
                    {
                        strField = field.Name;
                    }
                }

                LayerHelper.SetLayerAnnotation(geoLayer, strField);
                geoLayer.DisplayAnnotation = true;
                m_adminMap.AddLayer(featureLayer);
            }

            m_mapcontrol.Map = m_adminMap;
        }
开发者ID:niwho,项目名称:ArcGISFundation,代码行数:48,代码来源:DataSource.cs

示例11: loadNet

        /// <summary>
        /// 加载NetworkDataset到Map中
        /// </summary>
        /// <param name="_pMap"></param>
        /// <param name="_pNetworkDataset"></param>
        void loadNet(IMap _pMap,INetworkDataset _pNetworkDataset)
        {
            INetworkLayer pNetLayer = new NetworkLayerClass();

               pNetLayer.NetworkDataset = _pNetworkDataset;

               _pMap.AddLayer(pNetLayer as ILayer);
        }
开发者ID:esrichina,项目名称:Engine10DevApplication,代码行数:13,代码来源:MainForm.cs

示例12: LoadGeometric

        /// <summary>
        /// 将几何网络添加到地图上
        /// </summary>
        /// <param name="_pMap"></param>
        /// <param name="_pGeometricNetwork"></param>
        void LoadGeometric(IMap _pMap,IGeometricNetwork _pGeometricNetwork)
        {
            IFeatureClassContainer pFtContainer = _pGeometricNetwork as IFeatureClassContainer;

            int pCount = pFtContainer.ClassCount;

            for (int i = 0; i < pCount; i++)
            {
            IFeatureLayer pFeatureLayer = new FeatureLayerClass();

            pFeatureLayer.FeatureClass = pFtContainer.get_Class(i);

            _pMap.AddLayer(pFeatureLayer as ILayer);
            }
        }
开发者ID:esrichina,项目名称:Engine10DevApplication,代码行数:20,代码来源:MainForm.cs


注:本文中的IMap.AddLayer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。