﻿/*----------------地图对象----------------------

             功能：用于构造地图对象，完成对地图的基本操作和查询功能
             作者：裴斐
             时间：2008年9月29日
             版权：北京超图地理信息技术有限公司，1999-2008
                   本程序只能在有效的授权许可下使用。未经许可，不得以任何手段擅自使用或传播。
                   
----------------------------------------------*/

/*---------------变量和对象声明---------------*/
var resource_overviewName = "鹰眼";
var resource_findPathLength = "长度为";
var resource_findPathIsNull="没有路径可达";
var resource_passedEdges = "经过的边数为";
var resource_passedNodes ="经过的中间节点为";
var resource_clearHighlight = "清除高亮";
var resource_findPathName="路径分析结果";
var resource_findPathError = "路径分析出错";
var resource_queryResultIsNull ="查询结果为空";
var resource_busSolutionLength ="公交换乘方案总数为";
var resource_busSolutionName = "方案";
var resource_ride = "乘坐";
var resource_title = "提示";
var resource_getOn= "上车";
var resource_bus= "汽车"
var resource_getDown ="下车";
var resource_busSolutionIsNull = "没有公交方案";
var resource_busSolutionResultName = "公交查询结果";
var resource_selectStartStop="起点";
var resource_selectEndStop = "终点";
var resource_passStartLines ="经过起点的线路";
var resource_passEndLines="经过终点的线路";
var resource_query = "查询";
var resource_confirmBusStop = "公交站点确认";
var resource_busSolutionError = "公交分析出错";
var resource_findBusStopCount = "找到的站点个数为";
var resource_clearBusStopHighlight="清除站点高亮";
var resource_findBusStopIsNull="没有找到公交站点";
var resource_findBusStopError = "FindBusStop出错";
var resource_findBusLineCount="找到的线路条数为";
var resource_clearBusLineHigthlight="清除线路高亮";
var resource_findBusLineIsNull = "没有找到公交线路";
var resource_findBusLineError="FindBusLine出错";
var resource_showBusStopError="ShowBusStop出错";
var resource_showBusLineError="ShowBusLine出错";
var resource_showRoutingError = "ShowRouting出错";
var resource_getBusLinesByStopID ="GetBusLinesByStopID出错";
var resource_startStopName ="起始站点";
var resource_startStopValue ="长";
var resource_endStopName="终止站点";
var resource_endStopValue = "青";
var resource_transferTimes = "换乘次数";
var resource_transferTime_0 = "直达车";
var resource_transferTime_1 = "一次换乘";
var resource_transferTime_2 = "二次换乘";
var resource_bmostName = "最多换乘";
var resource_fuzzyQueryName = "根据公交站点模糊查询";
var resource_stopName = "站点名称";
var resource_lineName = "线路名称";
var resource_getBusSolutionName = "公交查询";
var resource_inputStartStop="请输入起始点";
var resource_inputEndStop ="请输入终止点";
var resource_inputStopName="请输入站点名称";
var resource_inputLineName = "请输入线路名称";
var resource_inputLindId = "请输入线路ID";
var resource_inputDirection = "请输入行车方向";
var resource_inputStopId = "请输入站点ID";
var resource_inputBusRouting = "请输入换乘路径";
var resource_content = "添加了一个标记";
var resource_title ="标记";
var resource_measureDistanceLength ="长度为";
var resource_measureResultIsNull = "没有量算结果";
var resource_measureName = "量算结果";
var resource_measureDistanceError = "量算距离出错";
var resource_measureAreaLength = "面积为";
var resource_maesureAraeError="量算面积出错";
var resource_queryError="查询出错";
var resource_queryName="查询结果";
var resource_Tracking ="已在进行轨迹回放中,请稍等或先停止当前回放";
var resource_east = "正东";
var resource_northeast = "东北";
var resource_north = "正北";
var resource_northwest = "西北";
var resource_west = "正西";
var resource_southwest = "西南";
var resource_south = "正南";
var resource_southeast = "东南";
var resource_return = "返回";
var resource_toward ="往";
var resource_at ="在";
var resource_direction="方向走";
var resource_deleteComfirm="删除后不能恢复，确定删除？";
var resource_unvisible="不可见";
var resource_visible="可见";
var resource_unqueryable="不可查";
var resource_queryable="可查";
var resource_deleteLabelTheme="删除标签专题图";
var resource_createLabelTheme="创建标签专题图";
var resource_queryResult="空间查询结果";
/*------split line-------*/
var MapControl1 = null;
var panAction = null;
var zoomInAction = null;
var zoomOutAction = null;
var pointQueryAction = null;
var lineQueryAction=null;
var findPathAction = null;
var SqlRectQueryAction=null;
var former_index = 0;
var max_btn_number = 35;
var m_busSolution=null; 
var m_lastBusNum=0;
var overview=null;
var addHeigth = 30;
//公交换乘时出现选择换乘站点界面时，会先分加别对默认起始站点和终止站点调用GetBusLinesByStopID
//这对于异步的Ajax来说不太好控制结果的返回，所以在这里用busSolutionStep来控制
//false：正常情况
//true：还要对终止站点进行GetBusLinesByStopID
var busSolutionStep=false;
var measureDistanceAction=null;
var measureAreaAction=null;
var openInfoWindowAction = null;
var rectQueryAction=null;
var PolygonQueryAction=null;
var CircleQueryAction=null;

var bPasueDynamicNavigate = false;
var marks = new Array();
var _oldThemeDotDensity=new Array();
var _oldThemeGraduatedSymbol=new Array();
var _oldThemeGraph=new Array();
var _oldThemeLabel=new Array();
var _oldThemeRange=new Array();
var _oldThemeUnique=new Array();
var _ShowTextField;                                            //对于临时图层，选择哪个字段作为文本助记字段显示在地图上
var _onCompleteFunction;
var xx=1;
var _validate=false;
var _xmlValidateHttpRequest;
/*--------------------------------------------*/

/*不同版本的IS就通过这个变量设置:
 *
 *  .Net5.2版 : AJAX
 *  .Net5.3版 : .Net5.3
 *  Java版 : Java
 *  iServerJava2008版 : iServerJava2008
 *  ASP版 : ASP
 *  SkyLine版 ： SkyLine
*/
var _ISVersion = ".Net5.3"; 

//鼠标图片路径,用于SuperMap.IS.Action 
var _scriptLocation = "scripts/";   

var _browserLanguage = _GetBrowserLanguage;

//服务器URL
var _ServiceURL = "http://webgis.cwi.gov.cn:5632/";

//项目名称
var _ProjectName = "CWGeoPortalPublic/";


//iServerJava2008设置
var _mapServer = "192.168.5.110";                                   //地图服务器地址，仅对于iServerJava2008有效
var _mapServerPort = 8606;                                      //地图服务端口，仅对iServerJava2008有效
var _ISURL = _mapServer + _mapServerPort;
var _URLHead = _ServiceURL + _ProjectName;


//服务器端接收空间查询的页面
var _SpacialQueryPageURL = _ServiceURL + _ProjectName + "SpacialQuery";                

//服务器端接收属性查询的页面
var _XMLQueryURL = _ServiceURL + _ProjectName + "MapXMLQuery"; 

//临时库查询地址
var _DBQueryURL = _ServiceURL + _ProjectName + "EditEngine?action=queryCheckRecordonTempTable";  

/*-----------------地图对象-------------------*/
function MapControl()
{
    this.MapName = "";                   //地图名称
    this.MapHandler = "";               //地图服务地址
    this.MapDiv = null;                 //存放地图的DIV
    this.Style = null;                  //地图框架风格
    this.OverviewDiv = null;            //存放鹰眼的DIV
    this.ScaleBarDiv = null;            //存放比例尺控件的DIV
	this.NavigatorDiv = null;           //存放指北针控件的DIV
    this.MapScales = null;              //地图比例尺
    this.ZoomLevel = 5;                 //地图当前比例尺
    this.ResultListDiv = null;          //存放查询结果的DIV
	this.LengendDiv = null;             //存放图例控件的DIV  
		
	this.SkyLineDiv = null;			    //存放skyline窗口的DIV
	this.SkyLineFly = null;				//存放skyline的FLY工程路径
	
	//查询参数
    this.QueryParams = null;
    this.Query_arrXs;
    this.Query_arrYs;
    this.Query_type;
    this.Query_radius;

    this.InitMap = function(onComplete)//初始化地图
        {
            _objMap=this;
            _objMap.onInitComplete=onComplete;
            if(window.ActiveXObject)
		        _xmlValidateHttpRequest = new ActiveXObject("MicroSoft.XMLHTTP");
		    else if(window.XMLHttpRequest)
		        _xmlValidateHttpRequest = new XMLHttpRequest();
			_xmlValidateHttpRequest.onreadystatechange=function()
				{
					if(_xmlValidateHttpRequest.readyState==4&&_xmlValidateHttpRequest.status==200)
					{
						if(_xmlValidateHttpRequest.responseText=="true")
						{
							__InitMapControl();
				        }
					    else
					    {
					    	alert("您还没有登陆！请登陆后再使用地图！");
	            			return;
	            		}
	            	}
            	};
			_xmlValidateHttpRequest.open("GET",_URLHead+"LoginAction.do?method=ValidateUser&random="+Math.random(),true);
			_xmlValidateHttpRequest.send(null);
			//__InitMapControl();
        }

     //显示鹰眼   
	this.ShowOverview = function()
		{
			_ShowOverview();
		}
	
	//隐藏鹰眼
	this.HideOverview = function()
		{
			_HideOverview();
		}
	
	//显示比例尺控件
	this.ShowScaleBar = function()
		{
			_ShowScaleBar();
		}
		
	//隐藏比例尺控件
	this.HideScaleBar = function()
		{
			_HideScaleBar();
		}
	
	//显示指北针控件
	this.ShowNavigator = function()
		{
			_ShowNavigator();
		}
		
	//隐藏指北针控件
	this.HideNavigator = function()
		{
			_HideNavigator();
		}
    	 
	//获取当前比例尺 
     this.GetMapScale = function()
    	{
    		return _GetMapScale();
    	}

    //显示图例控件
	this.ShowLengend = function()
		{
			if(this.LengendDiv!=null)
				this.LengendDiv.style.display="block";
		}
		
	//隐藏图例控件
	this.HideLengend = function()
		{
			if(this.LengendDiv!=null)
				this.LengendDiv.style.display="none";
		}

	//查看全图操作
    this.ViewEntire = function()
        {
            _ViewEntire();
        }
    
	//拉框放大操作
    this.ZoomIn = function()
        {
            _SetZoomInAction();
        }
    
    //拉框缩小操作    
    this.ZoomOut = function()
        {
            _SetZoomOutAction();
        }
    
    //将地图按指定比例缩放，中心点位置不变
    this.Zoom = function(ratio)
        {
            _Zoom(ratio);
        }
        
    //平移操作    
    this.PanTo = function()
        {
            _PanTo();
        }
        
     //移动到指定位置
    this.MoveTo = function(position,scale)
    	{
    		if(position==null||position.length<1)
    			return;
    		if(scale =="undefined" || scale==null||scale<1)
    			scale = this.GetMapScale();
    		_MoveTo(position,scale);
    	}
        
    //设置距离量算处理函数    
    this.SetMeasureDistanceAction = function(onMeasureDistanceCompleteFunction, onMeasureDistanceErrorFunction, onMeasureStartFunction, divResult, digits)
        {
            _SetMeasureDistanceAction(onMeasureDistanceCompleteFunction, onMeasureDistanceErrorFunction, onMeasureStartFunction, digits);

        }
        
    /*设置量算面积事件处理函数
	 * onMeasureAreaCompleteFunction：面积量算完毕后的处理函数
     * onMeasureAreaErrorFunction：面积量算出错时的处理函数
     * onMeasureStartFunction：面积量算开始时的处理函数
	*/
    this.SetMeasureAreaAction = function(onMeasureAreaCompleteFunction, onMeasureAreaErrorFunction, onMeasureStartFunction, divResult, digits)
        {
            _SetMeasureAreaAction(onMeasureAreaCompleteFunction, onMeasureAreaErrorFunction, onMeasureStartFunction, digits);
        }
        
          
    /*设置点选查询处理事件
	 * QueryExp:查询表达式
     * tolerance:查询容限
     * onCompleteFunction:处理查询结果的函数
     */
	this.SetPointQueryAction = function(oQueryParams,tolerance,onPointQueryCompleteFunction, onError, onStart)     
        {
            _SetPointQueryAction(oQueryParams,tolerance,onPointQueryCompleteFunction, onError, onStart);
        }
        
    /*设置线选查询处理事件
     * QueryExp:查询表达式
     * onLineQueryCompleteFunction:处理查询结果的函数
	 */
	this.SetLineQueryAction = function(oQueryParams,onLineQueryCompleteFunction, onError, onStart)    
        {
            _SetLineQueryAction(oQueryParams,onLineQueryCompleteFunction, onError, onStart);
        }
        
    /*设置圆选查询处理事件
     * QueryExp:查询表达式
     * onCompleteFunction:处理查询结果的函数
     */
	this.SetCircleQueryAction = function(oQueryParams, onCircleQueryCompleteFunc, onError, onStart)     
        {
            _SetCircleQueryAction(oQueryParams, onCircleQueryCompleteFunc, onError, onStart);
        }
        
    /*设置框选查询处理事件
     * QueryExp:查询表达式
     *  onCompleteFunc:处理查询结果的函数
     */
	this.SetRectQueryAction = function(oQueryParams,onRectQueryCompleteFunction)    
        {
            _SetRectQueryAction(oQueryParams,onRectQueryCompleteFunction);
        }
        
    /*设置多边形查询处理事件
     * QueryExp:查询表达式
     * onCompleteFunc:处理查询结果的函数
     */
	this.SetPolygonQueryAction = function(oQueryParams, onComplete, onError, onStart)     
        {
            onQueryCompleteFunc=onComplete;
            _SetPolygonQueryAction(oQueryParams, onQueryCompleteFunc, onError, onStart);
        }
    
    //切换地图
    //newMapName:新的地图名 
    this.SwitchMap = function(newMapName)
        {
            var strNewMapName=_SwitchMap(newMapName);
            if(strNewMapName!=null&&typeof(strNewMapName)!="undefined")
            	this.MapName=strNewMapName;
        }
    
    //清除地图高亮
    //tag:清除选项(null:全部清除;1:)
    this.ClearHighLight = function(tag)
        {
            _ClearHighLight(tag);
            if(this.LengendDiv != null && this.LengendDiv != "undefined" && this.LengendDiv != "")
            {
                this.LengendDiv.style.display = "none";
            }
        }
   	    
    //清除自定义标记
    this.ClearAllMarks = function()
    {
    	_ClearAllMarks();
    }
    
	 //清除地图WMS
    //tag:清除选项(null:全部清除;1:)
    this.RemoveWMS = function(tag)
        {
            _RemoveWMS(tag);
        }
	//定位到指定的位置
    //imageURL:要显示的图片	
    this.Locate = function(id, x, y, imageURL)
        {
       	    if(imageURL==null||imageURL.Trim()=="")
    		    imageURL="../Images/location.gif";
    	    var imageHTML = "<img src='" + imageURL + "'/>";
    	    this.AddMark(id,x,y,null,null,imageHTML,null,1000);
    	    this.MoveTo([x,y]);
        }
    //设置地图显示大小
    this.ReSize = function(width,height)
    {
    	_ReSize(width,height);
    }
    
    /*添加客户端助记
     * id:客户端助记名称
     * x:助记x坐标(地理坐标)
     * y:助记y坐标(地理坐标)
     * width:助记宽度(象素)
     * height:助记高度(象素)
     * HTML:助记内容
     * strClass:助记class名称
     * zIndex:助记层编号
     * GroupID:分组ID，多个自定义助记可以为同一组
     */
	this.AddMark = function(id,x,y,width,height,HTML,strClass,zIndex,GroupID)
        {
            _AddMark(id,x,y,width,height,HTML,strClass,zIndex,GroupID);
        }
    
    //根据名称清除指定客户端自定义助记
	//id：自定义助记名称 
    this.RemoveMark = function(id)
        {
            _RemoveMark(id);
        }
    
    /*添加客户端线形助记
	 * id:客户端助记名称
	 * arrXs:线的端点X(地理)坐标数组
	 * arrYs:线的端点Y(地理)坐标数组
	 * strokeWeight:线宽
	 * strokeColor:线色
	 * zIndex:助记层编号 
     */
	this.AddLine = function(id,arrXs,arrYs,strokeWeight,strokeColor,zIndex)
        {
            _AddLine(id,arrXs,arrYs,strokeWeight,strokeColor,zIndex);
        }
   
    /* 添加客户端多边形助记
	* id:客户端助记名称
	* arrXs:多边形的端点X(地理)坐标数组
	* arrYs:多边形的端点Y(地理)坐标数组
	* strokeWeight:边框宽度
	* strokeColor:边框颜色
	* fillColor:填充色
	* fillOpacity:透明度
	* zIndex:助记层编号
    */
	this.AddPolygon = function(id,arrXs,arrYs,strokeWeight,strokeColor,fillColor,fillOpacity,zIndex)
        {
            _AddPolygon(id,arrXs,arrYs,strokeWeight,strokeColor,fillColor,fillOpacity,zIndex);
        }
		
	/* 添加客户端圆形助记
	* id:客户端助记名称
	* startPoint:圆心坐标
	* endPoint:圆外边任意一点的坐标
	* strokeWeight:边框宽度
	* strokeColor:边框颜色
	* fillColor:填充色
	* fillOpacity:透明度
	* zIndex:助记层编号
	*/
	this.AddCircle = function(id,startPoint,endPoint,strokeWeight,strokeColor,fillColor,fillOpacity,zIndex)
	    {
		    _AddCircle(id,startPoint,endPoint,strokeWeight,strokeColor,fillColor,fillOpacity,zIndex);
	    }
        
    //查询
	//onQueryComplete:查询完毕回掉函数
    this.Query = function(oQueryParams,onQueryComplete)
    	{

    		this.QueryParams=oQueryParams;
    		if(this.QueryParams==null || this.QueryParams.QueryExp==null || this.QueryParams.QueryExp.toString().Trim()=="")
    		{
    			throw("查询表达式不能为空！");
                return;
            }
			onQueryCompleteFunc=onQueryComplete;
            LoadShape(escape(this.QueryParams.QueryExp), this.QueryParams.QueryType, this.QueryParams.PageSize, this.QueryParams.CurrentPageIndex,onQueryComplete);
        }

    //空间查询
	this.SpacialQuery = function(oQueryParams, arrXs, arrYs, type)
         {
     	    if(oQueryParams != null){
     		    _SpacialQuery(oQueryParams, arrXs, arrYs, type);
     	    }
         }
		
	//导入WMS服务
	//URL：WMS服务地址
    this.LoadWMS = function(URL)
    	{
    		_RemoveWMS();
            var wmsLayerManager = new WMSManager();
			wmsLayerManager.initialize(GetGeoMapControl());
			wmsLayerManager.getCapabilities(URL);
		}
	
	//添加WMS图层
	//URL:WMS图层路径
	this.AddWMSLayer = function(URL)
		{
			_AddWMSLayer(URL);
		}
	
	//移除指定WMS图层
	//LayerName:指定的WMS图层名称
	this.RemoveWMSLayer = function(LayerName)
		{
			_RemoveWMSLayer(LayerName);
		}

	
	//保存地图为图片
	this.Save = function()
		{
			_Save();
		}
	
	//打印当前地图窗口
	this.Print = function()
		{
			_Print();
		}
	
	//获取地图名称列表
	this.GetMapNames = function()
		{
			return _GetMapNames();
		}

	//设置地图单击事件
	//返回点的屏幕坐标
	//回调函数onComplete(x,y)
	this.SetMapClickAction = function(onComplete)
		{
			_SetMapClickAction(onComplete);
		}

	//将像素坐标转换为地理坐标
	//onComplete(x,y)
	this.PixelToMapCoord = function(x,y)
	{
		return _PixelToMapCoord(x,y);
	}
	
	//将地理坐标转换为像素坐标
	//onComplete(x,y)
	this.MapCoordToPixel = function(x,y)
	{
		return _MapCoordToPixel(x,y);
	}
	
	/*将像素长度转换为地理长度
	 *distance:像素长度
 	 *scale:缩放级别
	 */
	this.PixelToMapDistance = function(distance,scale)
	{
		return _PixelToMapDistance(distance,scale);
	}
	
	//返回SuperMap初始化地图对象	
	this.GetSuperMapControl = function()
		{
			return _GetGeoMapControl();
		}
		
	this.SetShowTextField = function (txtFieldName)
		{
			_ShowTextField = txtFieldName;
		}
	this.GetShowTextField = function()
		{
			return _ShowTextField;
		}
	
	//查询临时库数据
	this.QueryTempDB = function(whereFields,LayerType,TableName,showType,onQueryComplete)
		{
			LoadShapeFromDS(whereFields,LayerType,TableName,showType,onQueryComplete);
		}
}


/*------------------------------------------*/
    function onSpatialQueryComplete(resultSet)
    {
        //这里直接接收自定义引擎传来的XML
    }

function QueryParams(QueryExp,QueryType,PageSize,CurrentPageIndex)
    {
	    this.QueryExp = QueryExp;
	    this.QueryType = QueryType;
	    this.PageSize = PageSize;
	    this.CurrentPageIndex = CurrentPageIndex;
    }

function TurnPageParams(PageSize,CurrentPage,CurrentCount,EndPage,EndCount,iRowCount)
{
    this.PageSize = (PageSize == null) ? -1 : PageSize;
    this.CurrentPage = (CurrentPage == null) ? -1 : CurrentPage;
    this.CurrentCount = (CurrentCount == null) ? 0 : CurrentCount;
    this.EndPage = (EndPage == null) ? -1 : EndPage;
    this.EndCount = (EndCount == null) ? -1 : EndCount;
    this.iRowCount = (iRowCount == null) ? -1 : iRowCount;
}

function Style(iWidth, iHeight, iBorderWidth, sBorderColor, izIndex)
    {
        this.Width = (iWidth == null || parseInt(iWidth) < 1) ? 800 : parseInt(iWidth);
        this.Height = (iHeight == null || parseInt(iHeight) < 1) ? 600 : parseInt(iHeight);
        this.BorderWidth = iBorderWidth == null ? 1 : parseInt(iBorderWidth);
        this.BorderColor = sBorderColor== null ? "Black" : sBorderColor;
        this.zIndex = (izIndex == null || parseInt(izIndex)) ? 1 : parseInt(izIndex);
    }

function __InitMapControl(onComplete)
	{
		if(_objMap.Style!=null)
		{
			_objMap.MapDiv.style.width = _objMap.Style.Width;
			_objMap.MapDiv.style.height = _objMap.Style.Height;
			_objMap.MapDiv.style.borderWidth = _objMap.Style.BorderWidth;
			_objMap.MapDiv.style.borderColor = _objMap.Style.BorderColor;
			_objMap.MapDiv.style.zIndex = _objMap.Style.zIndex;
		}
		//this.mapDiv.onmousemove=UpdateInfoEx;
		_initMapControl(_objMap);
		//alert(_objMap.onInitComplete);
		_TriggerCallBack(_objMap.onInitComplete);
		//_objMap = this;
		//地图大小和窗口保持一致
		var bodymain=document.getElementById("mainbody");
		if(bodymain!=null)
		{
			var mapcon=GetGeoMapControl();         
			mapcon.resize(bodymain.clientWidth-4,bodymain.clientHeight-58);
		} 
		//------------
		PreLoadImages();
		top._MapRef = _objMap;
		top._MapIFrm = window;
	}

function UpdateInfo(eventArg)
    {
	    var info = $("info");
	    if (!info) { return;}

	    if(eventArg.param == null){
		    info.innerHTML = '<font color="red">error: ' + eventArg.error + '</font>';
		    return false;
	    }

	    info.innerHTML = 'mapName = ' + eventArg.param.mapName
		    + ', zoomLevel=' + eventArg.param.zoomLevel
		    + ', mapCenter = ' + eventArg.param.mapCenter.ToString()
		    + ', pixelCenter = ' + eventArg.param.pixelCenter.ToString();
    }

function UpdateInfoEx()
    {
        try
        {
		    var oMap = GetGeoMapControl();
		    var info = $("info");
		    info.innerHTML = "mapName=" + oMap.mapName
			    + ",zoomLevel=" + oMap.GetZoomLevel()
			    + ",mapCenter=" + oMap.GetMapCenterX()
			    + "," + oMap.GetMapCenterY();
        }
        catch(err){}
    }
function onQueryError(responseText)
    {
	    if(responseText){
		    alert(resource_queryError+":"+responseText);
	    }
	    else{
		    alert(resource_queryError+"!");
	    }
    }

function startResultFilter()
{
	if(XmlRegionData != undefined && XmlRegionData.xml != "" && _isFilter == "true")
	{
		_MapRectByBounds = null;
		_MapDistance = -1;
		_CurrentMapScale = -1;
		_objMap.ClearAllMarks();
		DrawRegion(); 
	}
}

function PreLoadImages()
    {
	    //preload images
	    var imageIdList = new Array();
	    imageIdList.push("01");
	    imageIdList.push("04");
	    imageIdList.push("05");
	    imageIdList.push("06");
	    imageIdList.push("15");
	    imageIdList.push("13");
	    imageIdList.push("10");
	    imageIdList.push("32");
	    imageIdList.push("26");
	    imageIdList.push("16");
	    imageIdList.push("34");
	    imageIdList.push("11");
	    imageIdList.push("14");
	    imageIdList.push("17");
	    imageIdList.push("22");
    	
	    if (document.images) {
		    for(var i=0;i<imageIdList.length;i++)
		    {
			    var str = "var img"+imageIdList[i]+"_down = new Image();img"+imageIdList[i]+"_down.src = 'images/btn_"+imageIdList[i]+"_down.gif';";
			    str += "var img"+imageIdList[i]+"_on = new Image();img"+imageIdList[i]+"_on.src = 'images/btn_"+imageIdList[i]+"_on.gif';";
			    eval(str);
		    }
		    for(var i=0;i<imageIdList.length;i++)
		    {
			    imageIdList.pop();
		    }
		    imageIdList = null;
	    }
    	
    }

function CloseAllControls()
    {
	    var controlList = new Array("QueryResultForm","MeasureResultForm","FindPathResultForm","BusForm","CompassForm","OverviewForm","WalkResultForm","LegendForm","LayerForm","PropertyForm","MapPositionForm","SqlQueryForm");
	    for(var i=0;i<controlList.length;i++)
	    {
		    var control = document.getElementById(controlList[i]);
		    if(control){control.style.display ="none";}
	    }
    }

    function OpenControls(id)
    {
	    CloseAllControls();
	    var form = document.getElementById(id);
	    if(form){form.style.display ="block";}
    }


 // -----------修改或复制SuperMap.IS.Include.js中的方法(请勿轻易改动)--------------
 
 function _GetScriptLocation() {
	var scriptLocation = "";
	var scriptName = "DPFScripts/MapControl.js";
	var scripts = document.getElementsByTagName('script');
	for (var i = 0; i < scripts.length; i++) {
		var src = scripts[i].getAttribute('src');
		if (src) {
			var index = src.lastIndexOf(scriptName);
			// is it found, at the end of the URL?
			if ((index > -1) && (index + scriptName.length == src.length)) {
				scriptLocation = src.slice(0, -scriptName.length);
				break;
			}
		}
	}
	return scriptLocation;
}

//脚本引用路径
var _LocationURL = _GetScriptLocation();

function _SmAppIncludeScript(inc,baseLocation)
    {
        if(!baseLocation)
        {
            baseLocation = _LocationURL;
        }
        var script = '<' + 'script type="text/javascript" src="'+ baseLocation + inc
			    + '"' + '><' + '/script>';
	    document.writeln(script);
    }

function _IncludeStyle(inc,baseLocation)
    {
    	if(!baseLocation)
        {
            baseLocation = _LocationURL;
        }
	    var style='<'+'link type="text/css" rel="stylesheet" href="'+ baseLocation +inc+'"'+' />'; 
	    document.writeln(style); 
    }

function _GetBrowser()
    {
	    var ua=navigator.userAgent.toLowerCase();
	    if(ua.indexOf('opera')!=-1)return'opera';
	    else if(ua.indexOf('msie')!=-1)return'ie';
	    else if(ua.indexOf('safari')!=-1)return'safari';
	    else if(ua.indexOf('gecko')!=-1)return'gecko';
	    else return false;
    }

function _GetBrowserLanguage()
    {
	    var ul = navigator.userLanguage ? navigator.userLanguage : navigator.language;
	    return ul ? ul.toLowerCase() : "";
    }


_SmAppIncludeScript('DPFScripts/MapAdapter.js');
_SmAppIncludeScript('DPFScripts/Shape.js');
_SmAppIncludeScript('SGAPI/sgapi.js');
_SmAppIncludeScript('DPFScripts/MapControl.SkyLine.js');
//_SmAppIncludeScript('../../javascript/PortalPlat/LogToken.js');


if(_ISVersion == ".Net5.3")
    {
	    //添加鼠标样式
        _IncludeStyle('styles/SuperMap.IS.MapControl.css');              
        
        if (_GetBrowser() != "ie") 
            {
                _SmAppIncludeScript('scripts/AtlasCompat_0.08.js');
	            _SmAppIncludeScript('scripts/wz_jsgraphics.js');
            }
		else if(navigator.userAgent.toLowerCase().indexOf("msie 8.0")!=-1){
			//_SmAppIncludeScript('scripts/AtlasCompat_0.08.js');
	        //_SmAppIncludeScript('scripts/wz_jsgraphics.js');
		}
        //_SmAppIncludeScript('DPFScripts/MapAdapter.js');
        //_SmAppIncludeScript('DPFScripts/Shape.js');
        _SmAppIncludeScript('DPFScripts/CommonScripts.js');
        _SmAppIncludeScript('DPFScripts/yahoo-min.js');
        _SmAppIncludeScript('DPFScripts/event-min.js');
        _SmAppIncludeScript('DPFScripts/dom-min.js');
        _SmAppIncludeScript('DPFScripts/logger-min.js');
        _SmAppIncludeScript('DPFScripts/dragdrop-min.js');
        _SmAppIncludeScript('DPFScripts/win.js');
        _SmAppIncludeScript('DPFScripts/WMS.js');

        _SmAppIncludeScript('scripts/SuperMap.IS.Utility.js');
        _SmAppIncludeScript('scripts/SuperMap.IS.Resources.js');
        _SmAppIncludeScript('scripts/SuperMap.IS.Type.js');
        _SmAppIncludeScript('scripts/SuperMap.IS.Map.js');
        _SmAppIncludeScript('scripts/SuperMap.IS.QueryManager.js');
        _SmAppIncludeScript('scripts/SuperMap.IS.SpatialAnalystManager.js');
        _SmAppIncludeScript('scripts/SuperMap.IS.EditManager.js');
        _SmAppIncludeScript('scripts/SuperMap.IS.Action.js');
        _SmAppIncludeScript('scripts/SuperMap.IS.MapControl.js');
        _SmAppIncludeScript('scripts/SuperMap.IS.OverviewControl.js');
        _SmAppIncludeScript('scripts/SuperMap.IS.LegendControl.js');
        _SmAppIncludeScript('scripts/SuperMap.IS.LayerControl.js');
        _SmAppIncludeScript('scripts/SuperMap.IS.NavigationControl.js');
        _SmAppIncludeScript('scripts/SuperMap.IS.ScaleBarControl.js');
        _SmAppIncludeScript('scripts/SuperMap.IS.MagnifierControl.js');
        _SmAppIncludeScript('scripts/SuperMap.IS.WebServiceClient.js');
        
        _SmAppIncludeScript('DPFScripts/MapControl.Net5.3.js');
        _SmAppIncludeScript('DPFScripts/MapAction.Net5.3.js');
    }

else if(_ISVersion == "iServerJava2008")
    {	
    	_IncludeStyle('styles/SuperMap.UI.MapControl.css');

	    if(_GetBrowser()!="ie"){
		    _SmAppIncludeScript('scripts/wz_jsgraphics.js'); 
	    }
	
	    _SmAppIncludeScript('scripts/MicrosoftAjax.debug.js'); 
	    _SmAppIncludeScript('scripts/MicrosoftAjaxTimer.debug.js'); 
	    _SmAppIncludeScript('scripts/MicrosoftAjaxWebForms.debug.js'); 
	
	    _SmAppIncludeScript('scripts/SuperMap.Utility.js'); 
	    _SmAppIncludeScript('scripts/SuperMap.CommonTypes.js'); 
	    _SmAppIncludeScript('scripts/SuperMap.Decoder.js'); 
	    _SmAppIncludeScript('scripts/SuperMap.Encoder.js'); 
	    _SmAppIncludeScript('scripts/SuperMap.Committer.js'); 
		_SmAppIncludeScript('scripts/SuperMap.DataManager.js');
	    _SmAppIncludeScript('scripts/SuperMap.NetworkAnalystManager.js');
	    _SmAppIncludeScript('scripts/SuperMap.SpatialAnalystManager.js');
	    
	    _SmAppIncludeScript('scripts/SuperMap.Map.js'); 
	    _SmAppIncludeScript('scripts/SuperMap.Layer.js'); 
	    _SmAppIncludeScript('scripts/SuperMap.LayerParam.js'); 
	    _SmAppIncludeScript('scripts/SuperMap.GlobalMapLayer.js');
	    _SmAppIncludeScript('scripts/SuperMap.OverviewManager.js'); 
	    _SmAppIncludeScript('scripts/SuperMap.UI.Action.js'); 
	    _SmAppIncludeScript('scripts/SuperMap.UI.MapTile.js'); 
	    _SmAppIncludeScript('scripts/SuperMap.UI.MapControl.js'); 
	    _SmAppIncludeScript('scripts/SuperMap.UI.OverviewControl.js'); 
	    _SmAppIncludeScript('scripts/SuperMap.UI.CustomLayer.js'); 
	    _SmAppIncludeScript('scripts/SuperMap.UI.LayerControl.js'); 
	    _SmAppIncludeScript('scripts/SuperMap.UI.NavigationControl.js'); 
	    _SmAppIncludeScript('scripts/SuperMap.UI.MagnifierControl.js'); 
	    _SmAppIncludeScript('scripts/SuperMap.UI.SliderBarControl.js'); 
	
		_SmAppIncludeScript('DPFScripts/CommonScripts.js');
		_SmAppIncludeScript('DPFScripts/WMS.js');
		/*
		_SmAppIncludeScript(_DPFScriptsHead + 'yahoo-min.js');
		_SmAppIncludeScript(_DPFScriptsHead + 'event-min.js');
		_SmAppIncludeScript(_DPFScriptsHead + 'dom-min.js');
		_SmAppIncludeScript(_DPFScriptsHead + 'logger-min.js');
		_SmAppIncludeScript(_DPFScriptsHead + 'dragdrop-min.js');
		*/
        _SmAppIncludeScript('DPFScripts/MapControl.iServerJava2008.js');
        _SmAppIncludeScript('DPFScripts/MapAction.iServerJava2008.js');
		_SmAppIncludeScript('DPFScripts/win.js');
		
		_SmAppIncludeScript('scripts/MicrosoftAjax.js');
    }