关于argis的问题, 如何在winform中的地图上绘制一个圆形的阴影区域呢? 类似于百度地图api的Circle区域 private void Test()
{
IGraphicsContainer pGraphicsContainer;
IMap pMap = axMapControl1.Map;
IActiveView pActiveView = axMapControl1.ActiveView; IGeometry Polygon;
Polygon = axMapControl1.TrackPolygon();
IPolygonElement PolygonElement;
PolygonElement = new PolygonElementClass(); IElement pElement;
pElement = PolygonElement as IElement;
pElement.Geometry = Polygon;// 这里报错: 未将对象引用到对象的实例, Polygon为null
pGraphicsContainer = pMap as IGraphicsContainer;
pGraphicsContainer.AddElement((IElement)PolygonElement, 0);
pActiveView.Refresh();
}试着修改了一下, 成了下面的样子, 没有报错,但也没有绘制(这是当然的,因为就没有设置绘制的相关属性) private void Test()
{
IGraphicsContainer pGraphicsContainer;
IMap pMap = axMapControl1.Map;
IActiveView pActiveView = axMapControl1.ActiveView; IGeometry Polygon;
Polygon = new PolygonClass();
IPolygonElement PolygonElement;
PolygonElement = new PolygonElementClass(); IElement pElement;
pElement = PolygonElement as IElement;
pElement.Geometry = Polygon;// 这里报错: 未将对象引用到对象的实例, Polygon为null
pGraphicsContainer = pMap as IGraphicsContainer;
pGraphicsContainer.AddElement((IElement)PolygonElement, 0);
pActiveView.Refresh();
}然后试着设置Polygon的属性, Demension, Envelope, GeometryType, IsEmpty都是只读属性, 只有一个SpaticalReference是读写属性Spatical意思是空间, Reference意思应该是引用. 引用空间? 不懂.试着折腾了一番, 成了下面一堆 private void Test()
{
IGraphicsContainer pGraphicsContainer;
IMap pMap = axMapControl1.Map;
IActiveView pActiveView = axMapControl1.ActiveView; IGeometry Polygon;
Polygon = new PolygonClass();
Polygon.SpatialReference = axMapControl1.Map as ISpatialReference;
IPolygonElement PolygonElement;
PolygonElement = new PolygonElementClass(); IElement pElement;
pElement = PolygonElement as IElement;
pElement.Geometry = Polygon;// 这里报错: 未将对象引用到对象的实例, Polygon为null
pGraphicsContainer = pMap as IGraphicsContainer;
pGraphicsContainer.AddElement((IElement)PolygonElement, 0);
pActiveView.Refresh();
}没有办法, 求救!! 需要在空白的axMapControl空间上绘制一个圆形阴影区域, 可以定义圆心和半径, 如果可以的话同时能够定义透明度
{
IGraphicsContainer pGraphicsContainer;
IMap pMap = axMapControl1.Map;
IActiveView pActiveView = axMapControl1.ActiveView; IGeometry Polygon;
Polygon = axMapControl1.TrackPolygon();
IPolygonElement PolygonElement;
PolygonElement = new PolygonElementClass(); IElement pElement;
pElement = PolygonElement as IElement;
pElement.Geometry = Polygon;// 这里报错: 未将对象引用到对象的实例, Polygon为null
pGraphicsContainer = pMap as IGraphicsContainer;
pGraphicsContainer.AddElement((IElement)PolygonElement, 0);
pActiveView.Refresh();
}试着修改了一下, 成了下面的样子, 没有报错,但也没有绘制(这是当然的,因为就没有设置绘制的相关属性) private void Test()
{
IGraphicsContainer pGraphicsContainer;
IMap pMap = axMapControl1.Map;
IActiveView pActiveView = axMapControl1.ActiveView; IGeometry Polygon;
Polygon = new PolygonClass();
IPolygonElement PolygonElement;
PolygonElement = new PolygonElementClass(); IElement pElement;
pElement = PolygonElement as IElement;
pElement.Geometry = Polygon;// 这里报错: 未将对象引用到对象的实例, Polygon为null
pGraphicsContainer = pMap as IGraphicsContainer;
pGraphicsContainer.AddElement((IElement)PolygonElement, 0);
pActiveView.Refresh();
}然后试着设置Polygon的属性, Demension, Envelope, GeometryType, IsEmpty都是只读属性, 只有一个SpaticalReference是读写属性Spatical意思是空间, Reference意思应该是引用. 引用空间? 不懂.试着折腾了一番, 成了下面一堆 private void Test()
{
IGraphicsContainer pGraphicsContainer;
IMap pMap = axMapControl1.Map;
IActiveView pActiveView = axMapControl1.ActiveView; IGeometry Polygon;
Polygon = new PolygonClass();
Polygon.SpatialReference = axMapControl1.Map as ISpatialReference;
IPolygonElement PolygonElement;
PolygonElement = new PolygonElementClass(); IElement pElement;
pElement = PolygonElement as IElement;
pElement.Geometry = Polygon;// 这里报错: 未将对象引用到对象的实例, Polygon为null
pGraphicsContainer = pMap as IGraphicsContainer;
pGraphicsContainer.AddElement((IElement)PolygonElement, 0);
pActiveView.Refresh();
}没有办法, 求救!! 需要在空白的axMapControl空间上绘制一个圆形阴影区域, 可以定义圆心和半径, 如果可以的话同时能够定义透明度
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货