arcgis 多边形查询

在default.aspx页面添加多边形控件:

<esri:Tool ClientAction="Polygon" Name="PolygonIdentify" DefaultImage="Images/MapTool/polyquery1.gif"
                    HoverImage="Images/MapTool/polyquery2.gif" SelectedImage="Images/MapTool/polyquery2.gif"
                    ServerActionAssembly="App_Code" ServerActionClass="IdentifyPolygon" Text="PolygonIdentify"
                    ToolTip="多边形查询" />

在app_code里面添加IdentifyPolygon类,实现代码如下:

//添加的命名空间
using ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools;
using ESRI.ArcGIS.ADF.Web.UI.WebControls;
using ESRI.ArcGIS.ADF.Web.Geometry;

/// <summary>
///IdentifyPolygon 实现多边形查询
/// </summary>
public class IdentifyPolygon : IMapServerToolAction
{
    public IdentifyPolygon()
    {
        //
        //TODO: 在此处添加构造函数逻辑
        //
    }

    void IMapServerToolAction.ServerAction(ToolEventArgs args)
    {
        Map map = args.Control as Map;
        PolygonEventArgs polyArgs = (PolygonEventArgs)args;
        Polygon mapPoly = IdentifyHelper.GetMapPolygon(map, polyArgs);
        IdentifyHelper.IdentifyRectangle(map, mapPoly);
    }

在IdentifyHelper类中添加GetMapPolygon方法:

/// <summary>
    /// 多边形查询
    /// </summary>
    /// <param name="map"></param>
    /// <param name="polyArgs"></param>
    /// <returns></returns>
    public static ESRI.ArcGIS.ADF.Web.Geometry.Polygon GetMapPolygon(Map map, PolygonEventArgs polyArgs)
    {
        System.Drawing.Point[] screenpoly = polyArgs.Vectors;
        PointCollection pc = new ESRI.ArcGIS.ADF.Web.Geometry.PointCollection();
        foreach (System.Drawing.Point dpnt in screenpoly)
        {
            pc.Add(ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(dpnt, map.Extent, (int)map.Width.Value, (int)map.Height.Value));
        }
        ESRI.ArcGIS.ADF.Web.Geometry.Ring ring = new ESRI.ArcGIS.ADF.Web.Geometry.Ring();
        ring.Points = pc;
        RingCollection rings = new RingCollection();
        rings.Add(ring);
        ESRI.ArcGIS.ADF.Web.Geometry.Polygon mapPoly = new ESRI.ArcGIS.ADF.Web.Geometry.Polygon();
        mapPoly.Rings = rings;
        return mapPoly;
    }

IdentifyRectangle方法在矩形查询里已有了喔!

转载于:https://www.cnblogs.com/lff255356/archive/2012/10/24/2737681.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值