2016-09-01 7 views
0

사용자가 콤보 상자에서 레이어 이름을 선택하는 사용자 지정 레이어에 피쳐 유형을 점, 선 또는 다각형으로 추가해야합니다. 순간 이 모든 기능은 단지 어떻게 Dotspatial의 사용자 지정 레이어에 기능을 추가 할 수 있습니까?

를 만든 마지막 층에 삽입하는 것은 내 코드입니다 :

public void test(Coordinate coord,string ftype) 
{ 

     foreach (var item in map1.Layers) 
     { 
      if (item.LegendText ==ftype) 
      { 
       int selectedIndex = map1.Layers.IndexOf(item); 
       ((Legend)map1.Legend).ClearSelection(); 
       map1.Layers[selectedIndex].IsSelected = true; 
       map1.Layers.SelectedLayer = map1.Layers[selectedIndex]; 
       map1.Legend.RefreshNodes(); 
       label1.Text = Convert.ToString(selectedIndex); 
      } 

     } 
     DotSpatial.Topology.Point point = new DotSpatial.Topology.Point(coord); 
     IFeatureSet ifs = new FeatureSet(FeatureType.Point); 
     IFeature currentFeature = ifs.AddFeature(point); 
     DotSpatial.Symbology.CharacterSymbol pcs = new DotSpatial.Symbology.CharacterSymbol('o', "Webdings", Color.Black, 32); 
     DotSpatial.Symbology.PointCategory pc = new DotSpatial.Symbology.PointCategory(pcs); 
     pc.Symbolizer.ScaleMode = ScaleMode.Simple; 
     pointScheme.AddCategory(pc); 
     mpl.Symbology = pointScheme; 
     mpl.ApplyScheme(pointScheme); 
     _tempLayer = mpl; 
     map1.MapFrame.DrawingLayers.Add(mpl); 
     map1.MapFrame.Invalidate(); 
     map1.Invalidate(); 
     pointID++; 
     map1.FunctionMode = FunctionMode.None; 

    }` 

답변

0

나는 우리가 Mappointlayer을 변경하려면해야 그것을 발견

첫번째 같이 IndexOf 층을 발견 의해 selectedIndex = map1.Layers.IndexOf (item); 지도 지점 레이어에 설정

   mpl= (MapPointLayer)map1.Layers[selectedIndex];