﻿// JScript 文件
var RouterKeyValue="1";
var RouterFlag=true;
function GetPointWebToolCommand(name, interaction)
{

	if (arguments.length > 0) {
		this.Init(name, interaction);
	}
	
}
 
GetPointWebToolCommand.prototype = new MapCommand();
GetPointWebToolCommand.prototype.constructor = GetPointWebToolCommand;
GetPointWebToolCommand.superclass = MapCommand.prototype;
GetPointWebToolCommand.prototype.Execute = function()
{
    startProcessingMap();
    RouterFlag=false;
    this.CreateUrl();
    
	//create an XMLHttp obj to send request to server
	var xmlHttp = CreateXMLHttp();
	this.AddParamToUrl("GetPoint", "true");
	xmlHttp.open("GET", this.url, false);
	// explicitly send the request for the zoom value
	xmlHttp.send(null);
	var result = xmlHttp.responseText;
	SetRouterName(result);	
	if(result=="")
	    {
	        alert("选择的导航位置点有所偏离,无法定位,请检查...");
	        finishProcessingMap()
	        return ;
	    }
	   
	//Get the new map placed in the Map control
	else
	{
	this.CreateUrl();
	//startProcessingMap();
	this.AddParamToUrl("GetMapImage", "true");
	this.AddParamToUrl("RouterID", RouterKeyValue);
	var v = document.getElementById('MapControl1_Image');
	// by assigning the url to the element src, a request will be sent to the server
	v.src = this.url;
	}
   
};

function SetRouterName(sName)
{
    var RouterValue=window.parent.document.getElementById("RoadInfo").contentWindow.document.getElementById("Router"+RouterKeyValue);
    if (RouterValue!=null)
        RouterValue.value=sName;
}

function RouterWebToolCommand(name, interaction)
{
	if (arguments.length > 0) {
		this.Init(name, interaction);
	}
	this.Exc = this.eventHandler("Execute");
}
RouterWebToolCommand.prototype = new MapCommand();
RouterWebToolCommand.prototype.constructor = RouterWebToolCommand;
RouterWebToolCommand.superclass = MapCommand.prototype;
RouterWebToolCommand.prototype.Execute = function()
{
	//Get the new map placed in the Map control
	this.CreateUrl();
	this.AddParamToUrl("RouterType", "0");
	var v = document.getElementById('MapControl1_Image');
	// by assigning the url to the element src, a request will be sent to the server
	v.src = this.url;
};

function RouterMapCommand(sValue)
{
  var url = "MapController.ashx?Command=RouterCommand&Ran=" + Math.random();
  var mapImage =document.getElementById("MapControl1_Image");                  
  if (mapImage.mapAlias) 
    url +=  "&MapAlias=" + mapImage.mapAlias;
  url+="&Width="+mapImage.width+"&Height="+mapImage.height+"&ExportFormat="+mapImage.exportFormat+"&"+sValue;
  startProcessingMap();
  mapImage.src =url;
};

function RouterMap(sType)
{
    RouterMapCommand("RouterType="+sType);
}
function RouterClear()
{
    RouterMapCommand("RouterClear=true");
}

function RouterMapAddPoint(sRouterID,sX,sY)
{
    var surl="RouterID="+sRouterID;
    surl+="&pointX="+sX+"&pointY="+sY;
    RouterMapCommand(surl);
}

function RouterMapDelPoint(sRouterID)
{
    RouterMapCommand("RouterID="+sRouterID);
}

function GetSiteMap(SiteMapObj,SiteMapWidth,SiteMapHeight,SiteMapZoom,SiteMapCenterX,SiteMapCenterY,i)
{
  var url = "MapController.ashx?Command=GetDefMapCommand&Ran=" + Math.random();
  url+="&Width="+SiteMapWidth+"&Height="+SiteMapHeight+"&ExportFormat=Gif&mapzoom="+SiteMapZoom+"&mapcenterx="+SiteMapCenterX+"&mapcentery="+SiteMapCenterY;
  SiteMapObj.src =url;
};
//全图
function fullExtent(){
  var url = "MapController.ashx?Command=FullExtent&Ran=" + Math.random();
  var mapImage = document.getElementById("MapControl1_Image");                  
  if (mapImage.mapAlias) 
  url +=  "&MapAlias=" + mapImage.mapAlias;
  url+="&Width="+mapImage.width+"&Height="+mapImage.height+"&ExportFormat="+mapImage.exportFormat;
  startProcessingMap();
  try
  {
mapImage.src =url;
}
catch(e)
{
alert("Error!");
}
};
//鼠标中建
function GetMouseWheelEvent()
{
var mapImage = document.getElementById("MapControl1_Image");
var url = "MapController.ashx?Command=WheelZoom&Width=" + mapImage.width +"&Height=" + mapImage.height
+ "&ExportFormat=" + mapImage.exportFormat + "&Ran=" + Math.random() + "&wheelvalue=" + event.wheelDelta;
if (mapImage.mapAlias) 
url += "&MapAlias=" + mapImage.mapAlias; 
startProcessingMap();
try 
{
mapImage.src = url;
}
catch(e)
{ 
alert("Error!");
}
};
//
function ChangeRouterMap(id)
{
   var mapImage = document.getElementById("MapControl1_Image");
   if(id==1)
   {
   mapImage.width = document.body.clientWidth;
   mapImage.height = document.body.clientHeight;
   }
   else 
   {
   mapImage.width = document.body.clientWidth-2;
   mapImage.height = document.body.clientHeight;
   }
    GetMap("MapControl1");
};
//历史路况
function changetheme()
{
 var time=document.getElementById("dateinfo").value;
 if(time==""||time==null) 
    { 
        alert("查询时间为空,请输入查询时间！"); 
    } 
    else
        {
         var timecheck=MapHis.CheckHisData(time);
         if(timecheck.value==0)
            alert("查询时间不在查询范围内,请重新查询！")
                else if(timecheck.value==-1)
                 alert("两次查询时间相同,请重新查询！");
                 else
                    {
                        var url = "MapController.ashx?Command=changetheme&Ran=" + Math.random();
                        var mapImage =document.getElementById("MapControl1_Image");                  
                        if (mapImage.mapAlias) 
                            url +=  "&MapAlias=" + mapImage.mapAlias;
                            url+="&Width="+mapImage.width+"&Height="+mapImage.height+"&ExportFormat="+mapImage.exportFormat+"&time="+time;
                            startProcessingMap();
                            mapImage.src =url;
                    }
        }
};

