ArcGIS 要素闪烁

        通过双击要素图例,闪烁定位到要素,并且闪烁一段时间:

                   

IFeatureLayer featureLayer = layer as IFeatureLayer;
                    ITable table = featureLayer as ITable;
                    IRow row = table.GetRow((int)data);
                    IFeature feature = row as IFeature;                  
                    IEnvelope envelope = feature.Shape.Envelope;                  
                    switch(feature.Shape.GeometryType)
                    {
                        case esriGeometryType.esriGeometryPoint:
                            IPoint point = feature.Shape as IPoint;
                            envelope.Expand(2.7, 2.7, true);
                            axMapControl1.FlashShape(point, 1, 300, null);
                            axMapControl1.Extent = envelope;
                            Application.DoEvents();
                            axMapControl1.Refresh();
                            axMapControl1.FlashShape(point, 6, 300, null);
                            break;
                        case esriGeometryType.esriGeometryPolyline:
                            IPolyline polyline = feature.Shape as IPolyline;
                            envelope.Expand(1.7, 1.7, true);
                            axMapControl1.FlashShape(polyline, 1, 300, null);
                            axMapControl1.Extent = envelope;
                            Application.DoEvents();
                            axMapControl1.Refresh();
                            axMapControl1.FlashShape(polyline, 15, 300, null);
                            break;
                        case esriGeometryType.esriGeometryPolygon:
                            IPolygon polygon = feature.Shape as IPolygon;
                            envelope.Expand(1.7, 1.7, true);
                            axMapControl1.FlashShape(polygon, 1, 300, null);
                            axMapControl1.Extent = envelope;
                            Application.DoEvents();
                            axMapControl1.Refresh();
                            ITopologicalOperator topOperator = polygon as ITopologicalOperator;
                            IPolyline line = new PolylineClass();
                            line=topOperator.Boundary as IPolyline;
                            axMapControl1.FlashShape(line, 15, 300, null);
                            break;

                    }

 

 

第一种:通过FlashShape来实现闪烁功能


public void PositionFlashElement(AxMapControl axMapControl, IElement pElement)
{
IGeometry pGeometry = pElement.Geometry;
ICartographicLineSymbol ipCartographicLineSymbol;
ISimpleFillSymbol ipSimpleFillSymbol;
ISimpleMarkerSymbol ipSimpleMarkersymbol;
ISymbol ipSymbol = null;
IRgbColor ipColor;
IPoint pPoint = new PointClass();
pPoint.X = pGeometry.Envelope.LowerLeft.X + pGeometry.Envelope.Width / 2;
pPoint.Y = pGeometry.Envelope.LowerLeft.Y + pGeometry.Envelope.Height / 2;
axMapControl.CenterAt(pPoint);
//pGeometry.Envelope.LowerLeft
int Size;

 




ipColor = new RgbColor();
ipColor.Red = 255;
Size = 10;




//esriGeometryType type = pGeometry.GeometryType;




if (type == esriGeometryType.esriGeometryPolyline)
{
ipCartographicLineSymbol = new CartographicLineSymbol();



ipSymbol = (ISymbol)ipCartographicLineSymbol;
ipSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
ipCartographicLineSymbol.Width = Size;
ipCartographicLineSymbol.Color = ipColor;
}
else if (type == esriGeometryType.esriGeometryPolygon)
{
ipSimpleFillSymbol = new SimpleFillSymbol();
ipSymbol = (ISymbol)ipSimpleFillSymbol;
ipSimpleFillSymbol.Color = ipColor;
}
else if (type == esriGeometryType.esriGeometryPoint || type == esriGeometryType.esriGeometryMultipoint)
{
ipSimpleMarkersymbol = new SimpleMarkerSymbol();
ipSymbol = (ISymbol)ipSimpleMarkersymbol;
ipSymbol.ROP2 = esriRasterOpCode.esriROPWhite;
ipSimpleMarkersymbol.Color = ipColor;
ipSimpleMarkersymbol.Size = 20;
}
axMapControl.FlashShape(pGeometry, 3, 300, ipSymbol);
}

        第二种:编辑自己闪烁的对象
 自己定义一个 FlashObjectsClass类来完成闪烁的功能,网上很对这样类的原代码.
     //获取对应要素
            LayerIdentifiedResult layerResult = identifiedResultsList[layerIndex];
            //点击了图层下的要素
            if (featureIndex > -1)
            {
                IFeatureIdentifyObj identifyObjDefault = layerResult.IdentifiedFeatureObjList[featureIndex];
                IFeature featureDefault = (identifyObjDefault as IRowIdentifyObject).Row as IFeature;
                //显示属性
                ShowFeatureAttributes(featureDefault);
                //判断是否闪烁要素
                if (doFlash)
                {
                    (identifyObjDefault as IIdentifyObj).Flash(associateMapControl.ActiveView.ScreenDisplay);
                }
            }
            //点击了图层,同时闪烁图层下的所有要素图形
            else
            {
                flashObjects.FlashObjects(layerResult);
            }
 
 第三种:结合IHookActions的DoAction方法并搭上esriHookActionsFlash动作,这样做效果很接近arcmap中的效果,速度也比较快。
 
           Action方面有6个constant,可以根据需要选择.

Constant

Value

Description

esriHookActionsFlash 

0

Flash the geometry.

esriHookActionsPan 

1

Pan to the geometry.

esriHookActionsZoom 

2

Zoom to the geometry.

esriHookActionsGraphic 

3

Create a graphic for the geometry.

esriHookActionsLabel 

4

Create a graphic and label for the geometry.

esriHookActionsCallout 

5

Create a callout for the geometry.


  完成闪烁的代码如下:

None.gifIHookActions hookActions;
None.gifhookActions.DoAction(feature.Shape, esriHookActions.esriHookActionsPan);

 Application.DoEvent();
None.gifhookActions.DoAction(feature.Shape,esriHookActions.esriHookActionsFlash);

 



第四种  
接口IIdentify的返回对象IFeatureIdentifyObj也可以实现这个功能。特摘录代码如下:


Dim pEnvs As IEnvelope
pEnvs = AxMapControl1.TrackRectangle

Dim pLayer As IFeatureLayer
pLayer = pMainMap.Layer(0)
Dim pIdentify As IIdentify
pIdentify = pLayer
Dim pArr As IArray
pArr = pIdentify.Identify(pEnvs)

Dim pFtIdenObj As IFeatureIdentifyObj
Dim pIdenObj As IIdentifyObj
If Not pArr Is Nothing Then
Dim j As Integer
For j = 0 To pArr.Count - 1
        pFtIdenObj = pArr.Element(j)
        pIdenObj = pFtIdenObj
        pIdenObj.Flash(pMainAV.ScreenDisplay)
        pIdenObj = Nothing
        pFtIdenObj = Nothing
Next
End If

 

转载于:https://www.cnblogs.com/St_Dlng/archive/2010/08/19/1803476.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ArcGIS是一款常用的地理信息系统软件,它供了丰富的功能和工具来处理和分析地理数据。在ArcGIS中,要素类是地理数据的基本组织形式之一。 要素类是由相同类型的要素组成的集合,每个要素都具有相同的属性结构。要素可以是点、线、等地理实体。要素类可以包含多个要素,这些要素可以表示不同的地理实体,如建筑物、道路、河流等。 要素类之间的转换可以通过ArcGIS中的工具和功能来实现。以下是一种常见的方法来介绍ArcGIS要素类至要素类的转换: 1. 打开ArcGIS软件并加载要素类:首先,打开ArcGIS软件并加载包含要素类的地理数据集。可以通过导航到文件路径或连接到数据库来加载要素类。 2. 选择要素类转换工具:在ArcGIS中,有多种工具可用于要素类之间的转换。例如,可以使用"Feature Class to Feature Class"工具将一个要素类转换为另一个要素类。 3. 配置转换参数:在选择要素类转换工具后,需要配置一些参数来定义转换的方式。这些参数可能包括输入要素类、输出要素类、字段映射等。 4. 运行转换工具:配置完参数后,可以运行转换工具来执行要素类至要素类的转换。在转换过程中,ArcGIS会根据配置的参数将输入要素类转换为输出要素类。 5. 检查转换结果:转换完成后,可以检查输出要素类以确保转换结果符合预期。可以使用ArcGIS中的地图查看器或属性表来查看和分析输出要素类。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值