/// <summary> /// 지도맵,레이어 초기화 /// </summary> /// <param name="obj"></param> /// <returns></returns> private async Task <string> resetAction(object obj) { //0.맵의레이어 클리어 mapControl.ClearLayers(); mapControl.Refresh(); //1.맵초기화 initMap(); //2.레이어초기화 CmmObj.initLayers(); //3.레이어스택 초기화 sts.Clear(); //4.행정구역표시 ShowShapeLayer("BML_GADM_AS", true); //열여있는 시설물정보창 닫기 popFct.IsOpen = false; //레이어div 체크해제 foreach (CheckBox cb in FmsUtil.FindVisualChildren <CheckBox>(treeLayer)) { cb.IsChecked = false; } await Task.Delay(1000); return("ok"); }
//시설물편집창 private void Button_Click(object sender, RoutedEventArgs e) { EditWinView view = new EditWinView(); if (view.ShowDialog() is bool) { //재조회 mapControl.Refresh(); //심볼초기화 CmmObj.InitUniqueValueRendererObj(); } }
/// <summary> /// Shape 레이어 보이기/끄기 - Shape버전 /// </summary> /// <param name="_mapView"></param> /// <param name="layer"></param> /// <param name="chk"></param> public FeatureLayer ShowShapeLayer(string _layerNm, bool chk) { try { // 0.해당레이어 가져오기 string filterExp = ""; string shapeNm = ""; try { string[] ary = _layerNm.Split('^'); shapeNm = ary[0]; //레이어테이블명 filterExp = "FTR_CDE='" + ary[1] + "'"; //필터표현식 } catch (Exception) { } //0.layers 체크동기화 CmmObj.layers[_layerNm].chk = chk; // 1.레이어 ON if (chk) { if (CmmObj.layers[_layerNm].FL.Name != "") { //레이어로딩 상태이면 맵에 추가만 해줌 mapControl.AddLayer(CmmObj.layers[_layerNm].FL); sts.Push(_layerNm);//레이어인덱스 가져오기위해 똑같이 스택에 저장해놓음 } else { mapControl.AddShapeFile(BizUtil.GetDataFolder("shape"), shapeNm + ".shp"); //레이어객체 저장 CmmObj.layers[_layerNm].FL = mapControl.get_Layer(0) as FeatureLayer; //스택형이므로 인덱스는 0 CmmObj.layers[_layerNm].FL.Name = CmmObj.getLayerKorNm(_layerNm); sts.Push(_layerNm); //레이어인덱스 가져오기위해 똑같이 스택에 저장해놓음 /* Renderer 적용 */ IGeoFeatureLayer pGFL = CmmObj.layers[_layerNm].FL as IGeoFeatureLayer; if ("BML_GADM_AS".Equals(_layerNm)) //행정구역 { //라인심볼 ISimpleLineSymbol lineSymbol = new SimpleLineSymbol(); lineSymbol.Color = new RgbColor() { Red = 255, Green = 0, Blue = 0 }; lineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot; lineSymbol.Width = 1.5; //Fill심볼 ISimpleFillSymbol fillSymbol = new SimpleFillSymbol(); fillSymbol.Color = new RgbColor() { Red = 255, Green = 255, Blue = 255 }; fillSymbol.Style = esriSimpleFillStyle.esriSFSHollow; fillSymbol.Outline = lineSymbol; //외각선은 라인심볼로 지정 ISimpleRenderer pSR = pGFL.Renderer as SimpleRenderer; pSR.Symbol = fillSymbol as ISymbol; //한반도영역내에 있는경우만 스케일링 IEnvelope area = CmmObj.layers[_layerNm].FL.AreaOfInterest; if (area.XMin > GisCmm.XMin && area.XMax < GisCmm.XMax && area.YMin > GisCmm.YMin && area.YMax < GisCmm.YMax) { mapControl.Extent = area; } //초기행정구역이면 스케일조정 mapControl.MapScale = 288895; } else { //레이어의 UniqueValueRenderer 적용 pGFL.Renderer = CmmObj.uniqueValueRendererObj as IFeatureRenderer; } } // 필터링 인수있으면 하위시설물으로 필터 if (!FmsUtil.IsNull(filterExp)) { //레이어필터링 IFeatureLayerDefinition flayer = CmmObj.layers[_layerNm].FL as IFeatureLayerDefinition; flayer.DefinitionExpression = filterExp; } return(CmmObj.layers[_layerNm].FL); } // 2.레이어 OFF else { if (CmmObj.layers[_layerNm].FL.Name != "") { mapControl.DeleteLayer(sts.GetStackIdx(_layerNm)); sts.Remove(sts.GetIdx(_layerNm)); } else { //로딩되지 않은상태 아무것도 안함 } return(null); } } catch (Exception ex) { MessageBox.Show("레이어가 존재하지 않습니다." + ex.Message); return(null); } }
public MapArcObjViewModel() { loadedCmd = new RelayCommand <object>(delegate(object obj) { //뷰객체를 파라미터로 전달받기 mapArcObjView = obj as UserControl; mapHost = mapArcObjView.FindName("mapHost") as WindowsFormsHost; toolbarHost = mapArcObjView.FindName("toolbarHost") as WindowsFormsHost; treeLayer = mapArcObjView.FindName("treeLayer") as TreeView; mapControl = mapHost.Child as AxMapControl; toolbarControl = toolbarHost.Child as AxToolbarControl; //0.맵 초기화 initMap(); //1.레이어초기화 CmmObj.initLayers(); //2.UniqueRenderer 초기화 CmmObj.InitUniqueValueRendererObj(); //3.행정구역경계표시 ShowShapeLayer("BML_GADM_AS", true); //맵마우스클릭 이벤트설정 mapControl.OnMouseUp += OnMouseClick; }); //레이어 ON/OFF chkCmd = new RelayCommand <object>(delegate(object obj) { Button doc = obj as Button; CheckBox chkbox = doc.Template.FindName("chkLayer", doc) as CheckBox; bool chk = (bool)chkbox.IsChecked; //ShowShapeLayer( doc.Tag.ToString(), chk); ShowShapeLayer(doc.Tag.ToString(), chk); //선택된 레이어저장 try { if (chk) { _selectedLayerNms.Add(doc.Tag.ToString()); _selectedLayerNm = doc.Tag.ToString(); } else { _selectedLayerNms.Remove(doc.Tag.ToString()); _selectedLayerNm = _selectedLayerNms.LastOrDefault(); } } catch (Exception) { } }); //GIS초기화 resetCmd = new RelayCommand <object>(async delegate(object obj) { string stat = await resetAction(obj); }); //SHP파일관리창 importCmd = new RelayCommand <object>(async delegate(object obj) { ShpMngView view = new ShpMngView(); if (view.ShowDialog() is bool) { //재조회 string stat = await resetAction(null); } }); }