怎么实现在ArcGIS Engine中画图
2个回答
2016-07-17
展开全部
在AE中这叫点选查询,其中你可以用你自己的坐标来替换下面的IMappMap=axMapControl1.Map;IActiveViewpActiveView=pMapasIActiveView;IFeatureLayerpFeatureLayer=pMap.get_Layer(0)asIFeatureLayer;IFeatureClasspFeatureClass=pFeatureLayer.FeatureClass;//设置点击点的位置IPointpoint=pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x,e.y);ITopologicalOperatorpTOpo=pointasITopologicalOperator;doublelength;length=ConvertPixelsToMapUnits(pActiveView,4);IGeometrypBuffer=pTOpo.Buffer(length);IGeometrypGeomentry=pBuffer.Envelope;//空间滤过器ISpatialFilterpSpatialFilter=newSpatialFilter();pSpatialFilter.Geometry=pGeomentry;//根据被选择要素的不同,设置不同的空间滤过关系switch(pFeatureClass.ShapeType){caseesriGeometryType.esriGeometryPoint:pSpatialFilter.SpatialRel=esriSpatialRelEnum.esriSpatialRelContains;break;caseesriGeometryType.esriGeometryPolyline:pSpatialFilter.SpatialRel=esriSpatialRelEnum.esriSpatialRelCrosses;break;caseesriGeometryType.esriGeometryPolygon:pSpatialFilter.SpatialRel=esriSpatialRelEnum.esriSpatialRelIntersects;break;}IFeatureSelectionpFSelection=pFeatureLayerasIFeatureSelection;pFSelection.SelectFeatures(pSpatialFilter,esriSelectionResultEnum.esriSelectionResultNew,false);ISelectionSetpSelectionset=pFSelection.SelectionSet;ICursorpCursor;pSelectionset.Search(null,true,outpCursor);IFeatureCursorpFeatCursor=pCursorasIFeatureCursor;IFeaturepFeature=pFeatCursor.NextFeature();while(pFeature!=null){pMap.SelectFeature(pFeatureLayer,pFeature);pFeature=pFeatCursor.NextFeature();pFeture.get_value("");//在这里你可以写上想要获取的属性的字段}pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphicSelection,null,null);上述的自定义函数是将距离的转换privatedoubleConvertPixelsToMapUnits(IActiveViewpActiveView,doublepixelUnits){//UsestheratioofthesizeofthemapinpixelstomapunitstodotheconversionIPointp1=pActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds.UpperLeft;IPointp2=pActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds.UpperRight;intx1,x2,y1,y2;pActiveView.ScreenDisplay.DisplayTransformation.FromMapPoint(p1,outx1,outy1);pActiveView.ScreenDisplay.DisplayTransformation.FromMapPoint(p2,outx2,outy2);doublepixelExtent=x2-x1;doublerealWorldDisplayExtent=pActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds.Width;doublesizeOfOnePixel=realWorldDisplayExtent/pixelExtent;returnpixelUnits*sizeOfOnePixel;}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
博思aippt
2024-07-20 广告
2024-07-20 广告
博思AIPPT是基于ai制作PPT的智能在线工具,它提供了4种AI制作PPT的方式,包括AI生成大纲、AI直接生成PPT、文本生成PPT、AI提炼文档生成PPT,一站式集成多种AI生成PPT的方式,可满足办公用户的不同需求和使用场景。ai生...
点击进入详情页
本回答由博思aippt提供
展开全部
画点
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();
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();
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询