图形绘制

鼠标移动到某个要素上显示属性
private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
{
    axMapControl1.ShowMapTips = true;
    IFeatureLayer pFeatureLayer = axMapControl1.Map.get_Layer(0) as IFeatureLayer;
    pFeatureLayer.DisplayField = "Name";
    pFeatureLayer.ShowTips = true;
}

private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
{
 IFeatureLayer pFeatureLayer = axMapControl1.Map.get_Layer(0) as IFeatureLayer;
    pFeatureLayer.DisplayField = "Name";
    pFeatureLayer.ShowTips = true;
    string pTip;
    pTip = pFeatureLayer.get_TipText(e.mapX, e.mapY, axMapControl1.ActiveView.FullExtent.Width / 10000);
    if (pTip != null)
    {
        toolTip1.SetToolTip(axMapControl1, "名称:" + pTip);
    }
    else           //当 ToolTip 空间显示的内容为 null 的时候,就不会显示了!相当于隐藏了!
    {
        toolTip1.SetToolTip(axMapControl1, "");
    }
}

选择要素

 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;
            IMap pMap = axMapControl1.Map;
            IGeometry pGeometry = axMapControl1.TrackRectangle();       //获取框选几何
            ISelectionEnvironment pSelectionEnv = new SelectionEnvironment(); //新建选择环境
            IRgbColor pColor = new RgbColor();
            pColor.Red = 255;
            pSelectionEnv.DefaultColor = pColor;         //设置高亮显示的颜色!

            pMap.SelectByShape(pGeometry, pSelectionEnv, false); //选择图形!
            axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
        }

只显示筛选的数据

IFeatureLayer pFeatureLayer = axMapControl1.Map.get_Layer(0) as IFeatureLayer;
IFeatureLayerDefinition pFeatLyrDef = pFeatureLayer as IFeatureLayerDefinition; //新建 IFeatureLayerDefinition 接口实例
pFeatLyrDef.DefinitionExpression = "Area > 20";  //定义筛选条件
axMapControl1.ActiveView.Refresh(); 
IFeatureLayer pFeatureLayer = axMapControl1.Map.get_Layer(0) as IFeatureLayer;
IFeatureLayerDefinition pFeatLyrDef = pFeatureLayer as IFeatureLayerDefinition;
pFeatLyrDef.DefinitionExpression = "Area > 20";
axMapControl1.ActiveView.Refresh();         //重新定义的图层

IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = "POP > 10";

IFeatureSelection pFeatSel = pFeatureLayer as IFeatureSelection;
pFeatSel.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);  //在新定义图层的基础上进行的查询

IFeatureLayer pNewFeat = pFeatLyrDef.CreateSelectionLayer("New Layer", true, null, null);  //新建的图层包括上面两者的交集部分!
pFeatSel.Clear();
axMapControl1.Map.AddLayer(pNewFeat);
MessageBox.Show(axMapControl1.Map.LayerCount.ToString());

高亮显示要素

IFeatureLayer pFeatureLayer = axMapControl1.Map.get_Layer(0) as IFeatureLayer;
IQueryFilter pQueryFilter = new QueryFilter();  //建立查询
pQueryFilter.WhereClause = "POP > 10";
IFeatureSelection pFeatSel = pFeatureLayer as IFeatureSelection;  //新建 IFeatureSelection 接口实例
pFeatSel.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, false);  //实现方法,选择筛选的部分!
axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值