⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demo.aspx.cs

📁 使用ASP.NET 2.0 (c#) 实现的gis 的地图系统
💻 CS
📖 第 1 页 / 共 5 页
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Xml;
using System.Configuration;
using System.Globalization;
using System.Diagnostics;
using SuperMap.IS.Web;
using SuperMap.IS.Utility;
using SuperMap.IS.WebControls;
using SuperMap.IS.WebControls.Utility;
using SuperMap.IS.WebControls.EventArguments;
using Microsoft.Web.UI.WebControls;
namespace AspxDemo
{
    /// <summary>
    /// Demo Page for SuperMap IS .NET 5.0 WebControl.
    /// 示范页面, 用于演示 SuperMap IS .NET 5.0 Web 控件的功能与使用.
    /// </summary>
    public partial class Demo : System.Web.UI.Page
    {
        #region 字段
        private SuperMap.IS.Utility.Style m_busStopStyle;
        private SuperMap.IS.Utility.Style m_busLineStyle;

        #endregion

        #region 属性: BusSolutionRef, TreeShowType,Edit相关的属性, QueryResult...
        private BusSolutionItem BusSolutionRef
        {
            get
            {
                return (BusSolutionItem)Session["BusSolutionRef"];
            }
            set
            {
                Session["BusSolutionRef"] = value;
            }
        }

        private string TreeShowType
        {
            get
            {
                return (string)Session["TreeShowType"];
            }
            set
            {
                Session["TreeShowType"] = value;
            }
        }


        #region Edit相关的属性
        private string EditLayerName
        {
            get
            {
                return (string)Session["EditLayerName"];
            }
            set
            {
                Session["EditLayerName"] = value;
            }
        }

        private int EditEntityID
        {
            get
            {
                int editEntityID;
                try
                {
                    editEntityID = (int)Session["EditEntityID"];
                }
                catch
                {
                    editEntityID = -1;
                }
                return editEntityID;
            }
            set
            {
                Session["EditEntityID"] = value;
            }
        }

        private Entity EditEntity
        {
            get
            {
                Entity editEntity;
                try
                {
                    editEntity = (Entity)Session["EditEntity"];
                }
                catch
                {
                    editEntity = null;
                }
                return editEntity;
            }
            set
            {
                Session["EditEntity"] = value;
            }
        }

        #endregion

        private ResultSet QueryResult
        {
            get
            {
                if (Session["QueryResult"] != null)
                {
                    return (ResultSet)Session["QueryResult"];
                }
                return null;
            }
            set
            {
                // 确保 value.MapResult.ReturnMapParam 为当前 MapParam。
                if (value != null)
                {
                    if (value.MapResult == null)
                    {
                        value.MapResult = new MapImage();
                    }
                    if (value.MapResult.ReturnMapParam == null)
                    {
                        value.MapResult.ReturnMapParam = this.MapControl1.GetCurrentMapParam();
                    }
                }

                Session["QueryResult"] = value;
            }
        }
        #endregion

        #region Web 窗体设计器生成的代码
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
            //
            InitializeComponent();
            base.OnInit(e);
        }

        /// <summary>
        /// 设计器支持所需的方法 - 不要使用代码编辑器修改
        /// 此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.img02.Click += new System.Web.UI.ImageClickEventHandler(this.img02_Click);
            this.img03.Click += new System.Web.UI.ImageClickEventHandler(this.img03_Click);
            this.img07.Click += new System.Web.UI.ImageClickEventHandler(this.img07_Click);
            this.img08.Click += new System.Web.UI.ImageClickEventHandler(this.img08_Click);
            this.img23.Click += new System.Web.UI.ImageClickEventHandler(this.img23_Click);
            this.img24.Click += new System.Web.UI.ImageClickEventHandler(this.img24_Click);
            this.img27.Click += new System.Web.UI.ImageClickEventHandler(this.img27_Click);
            this.img11.Click += new System.Web.UI.ImageClickEventHandler(this.img11_Click);
            this.MapControl1.ViewBoundsChanged += new SuperMap.IS.WebControls.MapControl.ViewBoundsChangedEventHandler(this.MapControl1_ViewBoundsChanged);
            this.MapControl1.LayerVisibleChanged += new SuperMap.IS.WebControls.MapControl.LayerVisibleChangedEventHandler(this.MapControl1_LayerVisibleChanged);
            this.MapControl1.LayerQueryableChanged += new SuperMap.IS.WebControls.MapControl.LayerQueryableChangedEventHandler(this.MapControl1_LayerQueryableChanged);
            this.MapControl1.MapSwitched += new SuperMap.IS.WebControls.MapControl.MapSwitchedEventHandler(this.MapControl1_MapSwitched);
            this.MapControl1.ClosestFacilityFound += new SuperMap.IS.WebControls.MapControl.ClosestFacilityFoundEventHandler(this.MapControl1_ClosestFacilityFound);
            this.MapControl1.AreaMeasured += new SuperMap.IS.WebControls.MapControl.AreaMeasuredEventHandler(this.MapControl1_AreaMeasured);
            this.MapControl1.QueryCompleted += new SuperMap.IS.WebControls.MapControl.QueryCompletedEventHandler(this.MapControl1_QueryCompleted);
            this.MapControl1.PathFound += new SuperMap.IS.WebControls.MapControl.PathFoundEventHandler(this.MapControl1_PathFound);
            this.MapControl1.Querying += new SuperMap.IS.WebControls.MapControl.QueryingEventHandler(this.MapControl1_Querying);
            this.MapControl1.AreaMeasuring += new SuperMap.IS.WebControls.MapControl.AreaMeasuringEventHandler(this.MapControl1_AreaMeasuring);
            this.MapControl1.DistanceMeasuring += new SuperMap.IS.WebControls.MapControl.DistanceMeasuringEventHandler(this.MapControl1_DistanceMeasuring);
            this.MapControl1.MapFirstInit += new System.ComponentModel.CancelEventHandler(this.MapControl1_MapFirstInit);
            this.MapControl1.ClosestFacilityFinding += new SuperMap.IS.WebControls.MapControl.ClosestFacilityFindingEventHandler(this.MapControl1_ClosestFacilityFinding);
            this.MapControl1.PathFinding += new SuperMap.IS.WebControls.MapControl.PathFindingEventHandler(this.MapControl1_PathFinding);
            this.MapControl1.DistanceMeasured += new SuperMap.IS.WebControls.MapControl.DistanceMeasuredEventHandler(this.MapControl1_DistanceMeasured);
            this.treeBusResult.Expand += new Microsoft.Web.UI.WebControls.ClickEventHandler(this.treeBusResult_Expand);
            this.treeBusResult.SelectedIndexChange += new Microsoft.Web.UI.WebControls.SelectEventHandler(this.treeBusResult_SelectedIndexChange);
            this.treeBusResult.Collapse += new Microsoft.Web.UI.WebControls.ClickEventHandler(this.treeBusResult_Collapse);

        }
        #endregion

        #region Page_Load,页面加载时的事件。
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                // 当页面被首次加载时
                this.txtSQLQuery.Text = ConfigurationSettings.AppSettings["SqlQueryDefaultValue"];	// 填充SQL查询文本框
                string a = this.LayerControl1.LayerNameText;	// for debug.
                string[] b = this.MapControl1.MapNames;			// for debug.
            }
            else
            {
                // 处理回发事件 
                try
                {
                    if (Request.Params["EditPostBack"] != null && Request.Params["EditPostBack"] == "true")
                    {
                        string editFieldNames = Request.Form["EditFieldNames"];
                        string editFieldValues = Request.Form["EditFieldValues"];
                        UpdateEditPropsValue(editFieldNames, editFieldValues);
                    }

                    // 公交方案的高亮
                    if ((this.Page.Request.Params["ShowBusSolution"]) != null)
                    {
                        HighlightBusSolution(this.Page.Request.Params["SolutionId"]);
                    }

                    // 公交站点的高亮
                    if ((this.Page.Request.Params["ShowBusStop"]) != null)
                    {
                        string stopId = this.Page.Request.Params["StopId"];
                        string solutionId = this.Page.Request.Params["SolutionId"];
                        string locationX = this.Page.Request.Params["LocationX"];
                        string locationY = Request.Params["LocationY"];
                        string stopName = Request.Params["StopName"];
                        HighlightBusStop(stopId, solutionId, locationX, locationY, stopName);
                    }

                    // 查询结果的居中显示
                    string Result_X = this.Page.Request.Params["Result_X"];
                    string Result_Y = this.Page.Request.Params["Result_Y"];
                    string Result_Name = this.Page.Request.Params["Result_Name"];
                    Result_Name = Result_Name.Replace("'", "\'");
                    if (Result_X.Length > 0 && Result_Y.Length > 0)
                    {
                        // 可能需要切换地图
                        string Result_MapName = this.Page.Request.Params["Result_MapName"];
                        if (Result_MapName != this.MapControl1.MapName)
                        {
                            this.MapControl1.MapName = Result_MapName;
                            this.MapControl1.Update();
                        }

                        double center_x = Double.Parse(Result_X);
                        double center_y = Double.Parse(Result_Y);

                        // 居中显示 
                        SuperMap.IS.Utility.MapCoord mapCenter = new MapCoord(center_x, center_y);
                        this.MapControl1.Zoom(mapCenter, 1.0);

                        // 插入小球
                        this.MapControl1.CustomLayer.Divs.Insert("ball", center_x, center_y, "<div align='left' style='text-align:left'><a target='_blank' href='url' title='" + Result_Name + "'><img border=0 src='images/hotball.gif'></a></div>");
                        this.MapControl1.CustomLayer.Visible = true;
                    }
                }
                catch
                { }
            }

        }
        #endregion

        #region 工具条按钮点击事件
        /// <summary>
        /// 快速放大
        /// </summary>
        private void img02_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            this.MapControl1.Zoom(2);
        }

        /// <summary>
        /// 快速缩小
        /// </summary>
        private void img03_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            this.MapControl1.Zoom(0.5);
        }

        /// <summary>
        /// 历史记录:前一视图
        /// </summary>
        private void img07_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            this.MapControl1.ViewPrevious();
        }

        /// <summary>
        /// 历史记录:后一视图
        /// </summary>
        private void img08_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            this.MapControl1.ViewNext();
        }

        /// <summary>
        /// 清除高亮。
        /// </summary>
        private void img11_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -