레이어 유형에 따라 아래 UID Value를 변경하면 된다. 아래는 레이어 유형별 UID Value이다.
IDataLayer는 GroupLayer를 제외한 FeatureLayers, FDOGraphicsLayers (Annotation), TinLayer, RasterLayer, CoverageAnnotationLayer를 포함한다.
//※ GUIDs //{6CA416B1-E160-11D2-9F4E-00C04F6BC78E} IDataLayer //{E156D7E5-22AF-11D3-9F99-00C04F6BC78E} IGeoFeatureLayer //{34B2EF81-F4AC-11D1-A245-080009B6F22B} IGraphicsLayer //{5CEAE408-4C0A-437F-9DB3-054D83919850} IFDOGraphicsLayer //{0C22A4C7-DAFD-11D2-9F46-00C04F6BC78E} ICoverageAnnotationLayer //{EDAD6644-1810-11D1-86AE-0000F8751720} IGroupLayer public ILayer GetLayerByName(IMap ipMap, string layerName) { if (ipMap.LayerCount == 0) return null; ESRI.ArcGIS.esriSystem.UID uid = new UIDClass(); uid.Value = "{6CA416B1-E160-11D2-9F4E-00C04F6BC78E}"; try { IEnumLayer ipEnumLayer = ipMap.get_Layers(uid, true); ipEnumLayer.Reset(); ILayer ipCurLayer = ipEnumLayer.Next(); while (ipCurLayer != null) { if ((string.Compare(ipCurLayer.Name, layerName, true) == 0)) { return ipCurLayer; } ipCurLayer = ipEnumLayer.Next(); } } catch (Exception Ex) { System.Diagnostics.Debug.WriteLine(Ex.Message); } return null; }
댓글 없음:
댓글 쓰기