default.aspx页面:

 <esri:Command ClientAction="" Name="ClearSelection" DefaultImage="Images/MapTool/clear.gif"
                    HoverImage="Images/MapTool/clear.gif" SelectedImage="Images/MapTool/clear.gif"
                    ServerActionAssembly="App_Code" ServerActionClass="ClearSelection" Text="清除选择"
                    ToolTip="清除选择" />

在app_code里面添加ClearSelection类,代码如下:

//添加的引用
using ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools;
using ESRI.ArcGIS.ADF.Web.UI.WebControls;
using ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer;
using ESRI.ArcGIS.ADF.ArcGISServer;

/// <summary>
///ClearSelection 实现清除高亮显示命令
/// </summary>
public class ClearSelection : IMapServerCommandAction
{
    public ClearSelection()
    {
        //
        //TODO: 在此处添加构造函数逻辑
        //
    }

    #region  IServerAction  Members
    void IServerAction.ServerAction(ToolbarItemInfo info)
    {
        Map map = info.BuddyControls[0] as Map;
        ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality mf;
        mf = map.GetFunctionality("Portland") as MapFunctionality;
        MapDescription mapDescription = mf.MapDescription;
        if (mapDescription.CustomGraphics == null)
            return;
        mapDescription.CustomGraphics = null;
        RefreshMap(map, "Portland");
    }
    #endregion
}

 /// <summary>
    /// 刷新地图
    /// </summary>
    /// <param name="map"></param>
    /// <param name="resourceName"></param>
    /// ImageBlendingMode(地图图片融合方式属性),如果该值为WebTier刷新整个地图,否则只刷新指定的资源
    public static void RefreshMap(Map map, string resourceName)
    {
        //web层融合
        if (map.ImageBlendingMode == ImageBlendingMode.WebTier)
        {
            map.Refresh();
        }
        //浏览器端融合
        else if (map.ImageBlendingMode == ImageBlendingMode.Browser)
        {
            map.RefreshResource(resourceName);
        }
    }

posted on 2012-10-24 19:27  求知的我  阅读(1015)  评论(0编辑  收藏  举报