达同一首实现了demo的地形图最近设备点路径分析,本篇新增台风轨迹,截图如下:

 

1、线段绘制

中心步骤

构建形状

  1. 创建 IPoint
    IPoint m_Point = new PointClass();
    m_Point.PutCoords(x, y);

  2. 创建 IPointCollection
    IPointCollection m_PointCollection = new PolylineClass();
    m_PointCollection.AddPoint(m_Point, ref Type.Missing, ref
    Type.Missing);

  3. 创建 IPolyline
    IPolyline m_Polyline = new PolylineClass();
    m_Polyline = m_PointCollection as IPolyline;

  4. 创建 IElement
    // Element 不能够实例化,需要因此那派生类实例化
    IElement m_Element = m_SimpleLineSymbol as IElement;
    m_Element.Geometry = m_Polyline;

安形状样式

  1. 创建 ISimpleLineSymbol
    ISimpleLineSymbol m_SimpleLineSymbol = new SimpleLineSymbolClass();

  2. 创建 ILineElement
    ILineElement m_LineElement = new LineElementClass();
    m_LineElement.Symbol = m_SimpleLineSymbol;

加载到地图
IMap m_Map = axMapControl1.Map;
IActiveView m_ActiveView = m_Map as IActiveView;
IGraphicsContainer m_Container = m_Map as IGraphicsContainer;

m_Container.AddElement(m_Element, 0);

m_Active.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null,
null);

 

 


别方法

private void DrawLine()  
{  
    ILineElement pLineElement;  
    IElement pLElement;  

    IPolyline pLine;  

    RgbColor pColor = new RgbColor();  
    pColor.Red = 0;  
    pColor.Green = 0;  
    pColor.Blue = 255;  

    ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();  
    pSimpleLineSymbol.Color = pColor;  
    pSimpleLineSymbol.Width = 5;  

    pLineElement = new LineElementClass();  
    pLineElement.Symbol = pSimpleLineSymbol;  

    pLElement = pLineElement as IElement;  

    IRubberBand pRubberBand;  
    pRubberBand = new RubberLineClass();  
    pLine = pRubberBand.TrackNew(axMapControl1.ActiveView.ScreenDisplay, null) as IPolyline;  

    pLElement.Geometry = pLine;  

    IGraphicsContainer pGraphicsContainer;  
    pGraphicsContainer = axMapControl1.ActiveView as IGraphicsContainer; //把地图的当前view作为图片的容器  

    pGraphicsContainer.AddElement(pLElement, 0);//把刚刚的element转到容器上  
    axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);  
}  

View Code


2、编辑

点编辑:

IPoint pt;  
pt = axMapControl1.ToMapPoint(e.x, e.y);  
IMarkerElement pMarkerElement;  
pMarkerElement = new MarkerElementClass();  
IElement pElement;  
pElement = pMarkerElement as IElement;  
pElement.Geometry = pt;  
pGraphicsContainer = pMap as IGraphicsContainer;  
pGraphicsContainer.AddElement((IElement)pMarkerElement, 0);  
pActiveView.Refresh(); 

 

线编辑:

IGeometry polyline;  
polyline = axMapControl1.TrackLine();  
ILineElement pLineElement;  
pLineElement = new LineElementClass();  
IElement pElement;  
pElement = pLineElement as IElement;  
pElement.Geometry = polyline;  
pGraphicsContainer = pMap as IGraphicsContainer;  
pGraphicsContainer.AddElement((IElement)pLineElement, 0);  
pActiveView.Refresh();  

 

 面编辑:

IGeometry Polygon;  
Polygon = axMapControl1.TrackPolygon();  
IPolygonElement PolygonElement;  
PolygonElement = new PolygonElementClass();  
IElement pElement;  
pElement = PolygonElement as IElement;  
pElement.Geometry = Polygon;  
pGraphicsContainer = pMap as IGraphicsContainer;  
pGraphicsContainer.AddElement((IElement)PolygonElement, 0);  
pActiveView.Refresh();  

 

 

 

ArcEngine中画shape点的另一样栽艺术

public override void OnMouseDown(int Button, int Shift, int X, int Y)  
{  

    //base.OnMouseDown(Button, Shift, X, Y);  
    IFeatureLayer pFeatureLayer = mapControl.Map.get_Layer(0) as IFeatureLayer;  
    IFeatureClass fc = pFeatureLayer.FeatureClass;  
    IFeatureClassWrite fr = fc as IFeatureClassWrite;  
    IWorkspaceEdit pWorkspaceEdit = (fc as IDataset).Workspace as IWorkspaceEdit;  

    IFeature pFeature;  
    IPoint pPoint;  
    //开始事物操作  
    pWorkspaceEdit.StartEditing(false);  

    //开始编辑  
    pWorkspaceEdit.StartEditOperation();  

    pFeature = fc.CreateFeature();  
    pPoint = new PointClass();  
    IPoint Mp = mapControl.ToMapPoint(X, Y);  
    pPoint.PutCoords(Mp.X, Mp.Y);  
    pPoint.SpatialReference = mapControl.SpatialReference;  
    pFeature.Shape = pPoint;  
    pFeature.Store();  
    mapControl.ActiveView.Refresh();  
    if (Button == 2)  
    {  
        pWorkspaceEdit.StopEditOperation();  
        pWorkspaceEdit.StopEditing(true);  
    }  
}  

 下面简单介绍有关知识点:

3、绘制Element、Symbol 在控件上

开标记预览的早晚要以ISymbol或IElement绘制到指定的控件上,下面边码边说,一起谈谈讨论:

警戒线

3.1 绘制在Panel上

ISymbol接口有Draw函数,查询该接口可以窥见,我们需要执行ISymbol.SetupDC
-> ISymbol.Draw -> ISymbol.ResetDC 这三独步骤;

先是SetupDC需要参数 hDC和IDisplayTransformation;贴代码:

例如:绘制在Panel上:

int width=Panel.Width;
int heigth=Panel.Heigth;
//绘制方法
Graphics graph=Graphics.FromHwnd(Panel.Handle);
graph.Clear(Panel.BackColor);
//分辨率
double dpi=graph.DpiX;
IEnvelope pEnve=new EnvelopeClass();
pEnve.PutCoords(0,0,width,heigth);
Ipoint pCenterPt=new PointClass;
pCenter.PutCoords(width/2,height/2);

tagRECT myRect=new tagRECT();
设置MyRect 的 top=0;bottom=heigh; left=0,right=width;

IDisplayransformation pDisTrans=new  DisplayTrabsformation();
pDisTrans.VisiableBounds=pEnve;
pDisTrans.Bounds=pEnv;
pDisTrans.Set_DeviceFrame(ref myRect);
pDisTrans.Resolution=dpi;

intPtr hdc=graph.GetHdc();
ISymbol.SetupDC(hec.ToInt32,pDisTrans);
ISymbol.Draw(pCenterPt);
ISymbol.ResetDC();

//绘制完成后 是否绘图对象 
graph.ReleaseHdc(hdc);
graph.Dispose();

Symbol的次种植艺术

IStyleGalleryItem item=new ServerStyleGalleryItemClass();

item.Item=youSymbol;//你待预览的ISymbol

stdole.IPictureDisp
pic=axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass).PriviewItem(item,100,100);

Image img=Image.FormHbitmap(new IntPtr(pic.Handle));

picPriview.Image=img;

 

警告线坐标集合:

3.2 绘制Element 在Panel控件上

中间 graph、pCenterPoint、pDisTrans 的设置方法跟方一样

坐绘制线段为例:

IDisplay pDisplay=new SimpleDisplay();

pDisplay.StartDrawing(graph.GetHdc(),ToInt32(),(short)esriScreeCache.esriNoScreeCache);

pDisplay.DisplayTransformation=pDisTrans;

pDisplay.SetSymbol(LineSymbol);//设置绘制线段的符

pDisplay.DrawPolyline(IGeometry) ;//设置绘制线段的几乎何数据

 

//在arcgis帮助中搜索吧

 

 

var lineArr24=[[127,34],[127,21],[110,15]];//24小时警戒线坐标集合
var lineArr48=[[132,34],[132,15],[105,0]];//48小时警戒线集合

参考文章

ArcGIS Engine
线段绘制研究

ArcEngine画shapefile点,线,面

ArcEngine中画shape点的任何一样种方法

Arcengine 绘制Element、Symbol
在控件上

 

 

 

线符号样式SimpleLineSymbol:

var symbol24 = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 1);
var symbol48 = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOTDOT, new dojo.Color([255,255,153]), 1);
台风操作面板

台风路径符号

点符号PictureMarkerSymbol

var TFQ_Symbol=new esri.symbol.PictureMarkerSymbol(getRootPath()+'contentweather/typhoon.png', 40, 40)

线符号SimpleLineSymbol:

var T_Symbol=new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID,
 new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
 new dojo.Color([255, 165, 0]), 0.01), new dojo.Color([255,20,147, 0.35]));
var Line_symbol= new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOTDOT, new dojo.Color([255,215,0]), 1);
扇形风圈

相关文章

网站地图xml地图