【问题标题】:ArcMap C# drawing polylines in selected layerArcMap C# 在选定图层中绘制折线
【发布时间】:2013-12-25 00:11:12
【问题描述】:
public void OnMouseDown(int Button, int Shift, int X, int Y)
{
  IMxDocument mxDoc = m_App.Document as IMxDocument;
  IActiveView activeView = mxDoc.FocusMap as IActiveView;
  IScreenDisplay screenDisplay = activeView.ScreenDisplay;

  ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass();
  IRgbColor rgbColor = new RgbColorClass();
  rgbColor.Red = 255;
  lineSymbol.Color = rgbColor;

  IRubberBand rubberLine = new RubberLineClass();
  IPolyline newPolyline = (IPolyline)rubberLine.TrackNew(screenDisplay, (ISymbol)lineSymbol);

  screenDisplay.StartDrawing(screenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
  screenDisplay.SetSymbol((ISymbol)lineSymbol);
  screenDisplay.DrawPolyline(newPolyline);
  screenDisplay.FinishDrawing();    
}

这是绘制折线的功能。但我希望折线会自动存储在“线”层中,这可能吗?

【问题讨论】:

    标签: c# arcgis polyline arcmap


    【解决方案1】:

    你的问题有点不清楚。您的“线条”图层是否已经存在?

    如果您希望您的图层成为要素图层而不是图形图层,则在工作空间中创建要素类,然后像这样将您的线对象添加到其中(对不起,它在 vb.net 中):

    Dim pFeature as IFeature
    pFeature = pFeatureClass.CreateFeature()
    pFeature.Shape = newPolyline
    pFeature.Store()
    

    然后从您的要素类创建一个要素图层并将其添加到地图中:

    Dim pFeatureLayer as IFeatureLayer
    pFeatureLayer.FeatureClass = pFeatureClass
    pFeatureLayer.Name = "Lines"
    Dim pMap as IMap = pMxDoc.FocusMap
    pMap.AddLayer(pFeatureLayer)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多