ArcGIS 要素闪烁
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.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);
}
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. |
IHookActions hookActions;
hookActions.DoAction(feature.Shape, esriHookActions.esriHookActionsPan);
Application.DoEvent();hookActions.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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器