===========类文件=======================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools;
using ESRI.ArcGIS.ADF.Web.UI.WebControls;
using ESRI.ArcGIS.ADF.Web.DataSources;
/// <summary>
/// bookmarkPrew 的摘要说明
/// 前一个视图
/// </summary>
public class bookmarkPrew : IMapServerCommandAction
{
public bookmarkPrew()
{
}
public void ServerAction(ToolbarItemInfo info)
{
int i = Convert.ToInt32(System.Web.HttpContext.Current.Session["tt"].ToString());
ESRI.ArcGIS.ADF.Web.UI.WebControls.Map mapcntrl = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)info.BuddyControls[0];
ArrayList _bookList = (ArrayList)mapcntrl.Page.Session["BookMark"];
int _num = int.Parse(mapcntrl.Page.Session["BookMarkNum"].ToString());
mapcntrl.Page.Session["BookMarkBool"] = "true";
if (_num >= _bookList.Count) _num = _bookList.Count - 1;
if (i == 0)
{
System.Web.HttpContext.Current.Session["tt"] = "9"; _num--;
}
if (_num != -1)
{
mapcntrl.Extent = (ESRI.ArcGIS.ADF.Web.Geometry.Envelope)_bookList[_num];
//_num--;
if (i != 0) _num--;
mapcntrl.Page.Session["BookMarkNum"] = _num;
//mapcntrl.Refresh();
}
}
}
/// <summary>
/// bookmarkNext 的摘要说明
/// 后一个视图
/// </summary>
public class bookmarkNext : IMapServerCommandAction
{
public bookmarkNext()
{
}
public void ServerAction(ToolbarItemInfo info)
{
int i = Convert.ToInt32(System.Web.HttpContext.Current.Session["tt1"].ToString());
ESRI.ArcGIS.ADF.Web.UI.WebControls.Map mapcntrl = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)info.BuddyControls[0];
ArrayList _bookList = (ArrayList)mapcntrl.Page.Session["BookMark"];
int _num = int.Parse(mapcntrl.Page.Session["BookMarkNum"].ToString());
mapcntrl.Page.Session["BookMarkBool"] = "true";
if (_num == -1) _num = 1;
if (i == 0)
{
System.Web.HttpContext.Current.Session["tt1"] = "9"; _num++;
}
if (_num < _bookList.Count)
{
mapcntrl.Extent = (ESRI.ArcGIS.ADF.Web.Geometry.Envelope)_bookList[_num];
if (i != 0) _num++;
mapcntrl.Page.Session["BookMarkNum"] = _num;
// mapcntrl.Refresh();
}
}
}
/// <summary>
/// bookmarkBegin 的摘要说明
/// 返回初始视图
/// </summary>
public class bookmarkBegin : IMapServerCommandAction
{
public bookmarkBegin()
{
}
public void ServerAction(ToolbarItemInfo info)
{
ESRI.ArcGIS.ADF.Web.UI.WebControls.Map mapcntrl = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)info.BuddyControls[0];
ArrayList _bookList = (ArrayList)mapcntrl.Page.Session["BookMark"];
if (_bookList.Count != 0)
{
mapcntrl.Extent = (ESRI.ArcGIS.ADF.Web.Geometry.Envelope)_bookList[0];
}
}
}
===========前台页面Toolbar设置=======================
<esri:Command ClientAction="" DefaultImage="~/myimg/105.png" HoverImage="~/myimg/105.png"
JavaScriptFile="" Name="Command" SelectedImage="~/myimg/105.png" ServerActi
ServerActi Text="回退" ToolTip="回退" />
<esri:Command ClientAction="" DefaultImage="~/myimg/106.png" HoverImage="~/myimg/106.png"
JavaScriptFile="" Name="Command0" SelectedImage="~/myimg/106.png" ServerActi
ServerActi Text="前进" ToolTip="前进" />
===============页面后台代码==========================
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) //初次加载
{
Session["BookMark"] = null; //记录地图状态
Session["BookMarkNum"] = -1;//记录地图操作次数
Session["BookMarkBool"] = "false"; //地图是否有操作,true是有,false没有,没有的情况下不存在前进和后退
}
Session["tt"] = "0"; //前一视图状态 整型索引
Session["tt1"] = "0";//后一视图状态 整型索引
}
//保存地图操作(前进、后退)
protected void Map1_ExtentChanged(object sender, ExtentEventArgs args)
{
//********清空点选的DIV
agf.CallBack(Map1, "closeDiv();");
//***********************8
System.Collections.ArrayList _tmp = new System.Collections.ArrayList();
string _Bool = Session["BookMarkBool"].ToString();
int _num = int.Parse(Session["BookMarkNum"].ToString());
if (_Bool == "false")
{
if (Session["BookMark"] != null)
{
_tmp = (ArrayList)Session["BookMark"];
}
_num++;
_tmp.Add(Map1.Extent);
Session["BookMark"] = null;
Session["BookMark"] = _tmp;
Session["BookMarkNum"] = _num;
}
else
{
Session["BookMarkBool"] = "false";
}
}
ArcGIS Server 视图前进后退
最新推荐文章于 2023-09-14 12:34:46 发布