var IE = document.all ? 1 : 0; //判断是不是IE浏览器
var PI = Math.asin(1.0)*2; //圆周率
var WGS_LRADIUS = 6378137;  //地球长半径
var WGS_SRADIUS = 6356752;
//var WGS_FR = (WGS_LRADIUS-WGS_SRADIUS)/WGS_LRADIUS;
var WGS_FER = Math.sqrt(1 - Math.pow(WGS_SRADIUS / WGS_LRADIUS, 2));
//var WGS_SER = sqrt(pow(WGS_LRADIUS / WGS_SRADIUS, 2) - 1);
var dMeterPerUnit = Math.round(WGS_LRADIUS * 2 * PI / 360)//111319;	//每一度经纬度的长度,单位米
var earth = 360; 				//360度
var dEarthLength = WGS_LRADIUS * 2 * PI;		//投影后的长度
var dMinX = -180; 				//最小西经		
var dMinY = -90; 				//最小南纬
var dMaxX = 180; 				//最大西经
var dMaxY = 90; 					//最大南纬
var Version = "0001"; 			//版本号
var BiggestZoom = 18; 			//最大放大值
var LeastZoom = 0;          //最小放大值
var LevelIgnore = [];
var Projection = "toogo";
var netTag="false";
var strImgurl = "http://10.33.252.6:9100/GetMap.aspx?Map="; //地图的URL
if (netTag=="true")
{
	strImgurl ="http://www.imapgo.com:9100/GetMap.aspx?Map="
}
strImgurl ="http://www.imapgo.com:9100/GetMap.aspx?Map="
//var strImgurl="/GetMap.aspx?Map=";//地图的URL

var toogolngdif=0.0059
var toogolatdif=0.0017
var baidulngdif=0.00476
var baidulatdif=0.0023

function onmousewheel(div)
{
	function document.onmousewheel(evt)  //重载滚轮事件，
	{       
		var target = div;
		var posw = new CPos(target.offsetLeft, target.offsetTop); 
		var posh = new CPos(target.offsetWidth, target.offsetHeight);
		var target = target.offsetParent;
		while (target)
		{
			posw.x += target.offsetLeft;
			posw.y += target.offsetTop;    
			target = target.offsetParent
		}
		var mapLeft = posw.x;        //地图左边界
		var mapRight = mapLeft+posh.x; //地图右边界
		var mapTop = posw.y;         //地图上边界
		var mapBottom = mapTop+posh.y; //地图下边界
		var curX = parseInt((IE) ? event.clientX : EVT.clientX);   //鼠标X坐标
		var curY = parseInt((IE) ? event.clientY : EVT.clientY);   //鼠标Y坐标
	 	  
		if((mapLeft<curX)&&(curX<mapRight)&&(mapTop<curY)&&(curY<mapBottom))
		{
			return false;  
		}
	};
	function CPos(x, y)  //用于求存放地图的DIV的坐标
	{
		this.x = x;
		this.y = y;
	}
};


/*双击后出现的距离框*/
document.writeln('<div id="myalert" style="position:absolute;z-index:100;filter:alpha(opacity=90);-moz-opacity:0.9;visibility:hidden;"></div>');
function distanceBox(x, y, distance)
{
	document.getElementById("myalert").style.top = parseInt(y) - 60 + "px";
	document.getElementById("myalert").style.left = parseInt(x) - 100 + "px";
	document.getElementById("myalert").innerHTML = '<table width="196px" border="0" cellpadding="0" cellspacing="0" style="border:1px solid #CCCCCC;"><tr><td height="19" bgcolor="#8888FF"></td></tr><tr><td height="100px" align="center" valign="middle" bgcolor="#FFFFFF"><table width="167px" height="79px" border="0" cellpadding="0" cellspacing="0"><tr><td height="55px" align="center" valign="middle" style="font-size: 12px;color: #0065AD;">' + distance + '</td></tr><tr><td height="24px" align="center" valign="middle"><input type="button" value="关闭" onClick="document.getElementById(\'myalert\').style.visibility = \'hidden\'"onMouseOver="style.background=\'#DEE7EF\';style.cursor=\'hand\'"onMouseOut="this.style.background=\'FDFAF3\'" style="font-size: 9pt; width: 38px; height:18px; border: 1px solid #4A799C;background-color: #FDFAF3"></td></tr></table></td></tr></table>';
	document.getElementById("myalert").style.visibility = "visible"
};

document.writeln('<div id="mymarker" style="position:absolute;top:0px;left:0px;z-index:5;visibility:hidden;"></div>');
document.writeln('<div id="tagmark" style="position:absolute;top:0px;left:0px;z-index:5;visibility:hidden;"></div>');
function markertagBox(html, x, y)
{
  this.html = (typeof html == "undefined") ? "" : html;
  var tag1 = '<div id="tag1" style="position:absolute;top:0px;left:0px">' + this.html + '</div>';
  document.getElementById("tagmark").innerHTML = tag1;
  tagwidth = document.getElementById("tag1").scrollWidth;
  tagwidth = parseInt((tagwidth <= 238) ? 238 : tagwidth);
  tagwidth = parseInt((tagwidth >= 400) ? 400 : tagwidth);
  var tag = '<div unselectable="on" id="tag" style="position:absolute;top:0px;left:0px;z-Index:10">'
  tag += '<div unselectable="on" style="left:0px; top:0px; width:25px; height:25px; position:absolute; z-index: 10;">'
  tag += '<img src="images/tag/iw_nw.png" ></div>'
  tag += '<div unselectable="on" style="right:0px; top:0px; position:absolute; z-index: 10;">'
  tag += '<img src="images/tag/iw_ne.png">'
  tag += '<img title="关闭" style="position:absolute; right:10px; top:10px;" onmousemove=style.cursor="hand" onclick="javascript:hidden()" src="images/tag/X.PNG"></div>';
  tag += '<table id="table1" cellpadding="0" cellspacing="0" width="' + tagwidth + '" style="word-wrap:break-word;word-break:break-all;"><tr height="25"><td></td></tr><tr><td bgcolor="#FFFFFF" style="BORDER-LEFT: #ababab 1px solid;BORDER-RIGHT: #ababab 1px solid;">' + this.html + '</td></tr><tr height="25"><td></td></tr></table>';
  tag += '<div unselectable="on" style="left:0px; bottom:0px; width:25px; height:25px; position:absolute; z-index: 10;">'
  tag += '<img src="images/tag/iw_sw.png"></div>'
  tag += '<div unselectable="on" style="right:0px; bottom:0px; width:25px; height:25px;position:absolute; z-index: 10;">'
  tag += '<img src="images/tag/iw_se.png"></div>'
  tag += '</div>';
  document.getElementById("mymarker").innerHTML = tag;
  tagheight = document.getElementById("tag").scrollHeight;
  var tagwidth1 = document.getElementById("tag").scrollWidth;
  var tagwidthtop = tagwidth1 - 50
  var top = tagheight - 25
  var tagtap = tagwidthtop / 2;
  tag += '<div unselectable="on" style="BORDER-TOP: #ababab 1px solid;left:25px; width:' + tagwidthtop + 'px; top:0px; height:24px; position:absolute; z-index: 10;background-color:#fff;"></div>'
  tag += '<div unselectable="on" style="BORDER-BOTTOM: #ababab 1px solid;left:25px; width:' + tagwidthtop + 'px; bottom:-' + tagheight + 'px; height:24px; position:absolute; z-index: 10;background-color:#fff;"></div>'
  tag += '<div unselectable="on" style="position:absolute;top:' + top + 'px;left:' + tagtap + 'px;z-Index:10"><img src="images/tag/iw_tap.png"></div>'
  document.getElementById("mymarker").innerHTML = tag;
  document.getElementById("mymarker").style.top = parseInt(y) - tagheight - 104;
  document.getElementById("mymarker").style.left = parseInt(x) - tagwidth1 / 2 + 18;
};
// 创建台风标签  wgf
function markertagBox_typhoon(html, x, y){
	var strHTML="";
	
	    strHTML+="<div id='divLabel' style='z-index:112;filter:alpha(opacity=75);background-color:#ffffff; width:240px;height:330px;'>";
		strHTML +="<table id='label_table' width='240' height=330 style='position:absolute; z-index:85;' style='font-size:9pt;' border='0' cellspacing='3' cellpadding='0' >";
		strHTML +="  <tr>";
		strHTML +="		<td colspan='2'  align='right' style='padding-right:10' height='5' nowrap><a href='javascript:void()' onMouseMove='window.StormPoints_mouseout()'  style='text-decoration:underline'>×</a></td>";
		strHTML +="  </tr>";
		strHTML +="  <tr>";
		strHTML +="		<td colspan='2'  align='center'   height='180' nowrap><div id='labelvalue8'></div></td>";
		strHTML +="  </tr>";
		strHTML +="  <tr>";
		strHTML +="		<td align='center' colspan='2'  nowrap><b><div id='labelvalue1'></div></b></td>";
		strHTML +="  </tr>";
		strHTML +="  <tr>";
		strHTML +="		<td style='padding-left:12' nowrap><div id='labelvalue2'></div></td><td nowrap><div id='labelvalue3'></div></td>";
		strHTML +="  </tr>";
		strHTML +="  <tr>";
		strHTML +="		<td style='padding-left:12' nowrap><div id='labelvalue4'></div></td><td nowrap><div id='labelvalue5'></div></td>";
		strHTML +="  </tr>";
		strHTML +="  <tr>";
		strHTML +="		<td style='padding-left:12' nowrap><div id='labelvalue6'></div></td><td nowrap><div id='labelvalue7'></div></td>";
		strHTML +="  </tr>";
		strHTML +="  <tr>";
		strHTML +="		<td style='padding-left:12' nowrap><div id='labelvalue9'></div></td><td nowrap><div id='labelvalue10'></div></td>";
		strHTML +="  </tr>";
		strHTML +="  <tr>";
		strHTML +="		<td style='padding-left:12'  colspan='2' nowrap><div id='labelvalue11'></div></td>";
		strHTML +="  </tr>";
		
		strHTML +="</table>";
		strHTML +="<div id='label_point'>";
		strHTML +="</div>";
		strHTML +="<v:roundRect style='position:relative;width:240;height:330;' FillColor='#FFFFFF' Filled='T' />";
		strHTML+="</div>";
		//strHTML +="	<v:shadow on='t' type='single' color='silver' offset='3pt,-3pt'></v:shadow>";
		document.getElementById("mymarker").innerHTML = strHTML;
        //document.getElementById("mymarker").style.top = parseInt(y) - 104;
        //document.getElementById("mymarker").style.left = parseInt(x) + 18;
	

}
function hidden()
{
	document.getElementById("mymarker").style.visibility = "hidden"
};

function visible()
{
	document.getElementById("mymarker").style.visibility = "visible"
};

/*图片加载出错时处理,处理加载四次*/
function imageTileError(image)
{
  if (image.width == 256 && image.ntry == "0")
  {
    image.ntry = "1";
    var tempSrc = image.src;
    image.src = tempSrc
  }
  else if (image.width == 256 && image.ntry == "1")
  {
    image.ntry = "2";
    var tempSrc = image.src;
    image.src = tempSrc
  }
  else if (image.width == 256 && image.ntry == "2")
  {
    image.ntry = "3";
    var tempSrc = image.src;
    image.src = tempSrc
  }
  else if (image.width == 256 && image.ntry == "3")
  {
    image.ntry = "4";
    var tempSrc = image.src;
    image.src = tempSrc
  }
  else 
  {
    image.ntry = "5";
    image.onerror = null;
    image.style.width = 256;
    image.style.height = 256
  }
};

/*延迟调用函数*/
function getTimeout(obj, fun, time)
{
	return window.setTimeout(function() { fun.apply(obj) }, time)
};

/*缩放工具条*/
function GSControlBar(file, zoomPara, left, top, width, height, bvisible, zIndex, maphold, clipLayer, bflag)
{
  this.strFile = (file == null || file == "undefined") ? '' : file + '/';
  this.bSimplify = (bflag == "1") ? true : false;
  this.maplet = clipLayer;
  this.topPosition = (this.bSimplify == true) ? (top+98) : (top+98 + (this.maplet.BiggestZoom - this.maplet.LevelIgnore.length - this.maplet.LeastZoom + 1) * ControlBarSpace); //简化时top值为100
  this.E3419 = '<IMG unselectable="on" style="position:absolute;left:' + (left + 10) + 'px;top:' + (top + 10) + 'px;" src="images/' + this.strFile + 'panshadow.gif" >';
  this.E3419 += '<IMG id="ctrlw" unselectable="on" title="向西平移" onmousemove=style.cursor="hand" onclick="javascript:PerformControl(event, this,1);" style="position:absolute;left:' + (left + 15) + 'px;top:' + (top + 32) + 'px;" src="images/' + this.strFile + 'west.gif" >';
 	this.E3419 += '<IMG id="ctrln" unselectable="on" title="向北平移" onmousemove=style.cursor="hand" onclick="javascript:PerformControl(event, this,2);" style="position:absolute;left:' + (left + 30) + 'px;top:' + (top + 18) + 'px;" src="images/' + this.strFile + 'north.gif" >';
  this.E3419 += '<IMG id="ctrle" unselectable="on" title="向东平移" onmousemove=style.cursor="hand" onclick="javascript:PerformControl(event, this,3);" style="position:absolute;left:' + (left + 50) + 'px;top:' + (top + 32) + 'px;" src="images/' + this.strFile + 'east.gif" >';
  this.E3419 += '<IMG id="ctrls" unselectable="on" title="向南平移" onmousemove=style.cursor="hand" onclick="javascript:PerformControl(event, this,4);" style="position:absolute;left:' + (left + 30) + 'px;top:' + (top + 52) + 'px;" src="images/' + this.strFile + 'south.gif" >';
  this.E3419 += '<IMG id="ctrlmeas" unselectable="on" title="测量距离" onmousemove=style.cursor="hand" onclick="javascript:PerformControl(event, this,7);" style="position:absolute;left:' + (left + 32) + 'px;top:' + (top + 38) + 'px;" src="images/' + this.strFile + 'measure.gif" >';
  if (!this.bSimplify)
  {
    for (i = 0; i <= this.maplet.BiggestZoom - this.maplet.LevelIgnore.length - this.maplet.LeastZoom+1; i++)
    {
      this.E3419 += '<IMG id="ctrlbg" unselectable="on" title="点击进行缩放" onmousemove=style.cursor="default" onclick="javascript:PerformControl(event, this, 8);" style="position:absolute;left:' + (left + 33) + 'px;top:' + (i * ControlBarSpace + top+92) + 'px;" src="images/' + this.strFile + 'zoom-bg2-1.gif" >'
    }
  }
  this.E3419 += '<IMG id="ctrlzmin" unselectable="on" title="放大" onmousemove=style.cursor="hand" onclick="javascript:PerformControl(event, this,5);" style="position:absolute;left:' + (left + 30) + 'px;top:' + (top + 76) + 'px;" src="images/' + this.strFile + 'zoom-plus.gif" >';
  this.E3419 += '<IMG id="ctrlzmout" unselectable="on" title="缩小" onmousemove=style.cursor="hand" onclick="javascript:PerformControl(event, this,6);" style="position:absolute;left:' + (left + 29) + 'px;top:' + (this.topPosition) + 'px;" src="images/' + this.strFile + 'zoom-minus.gif" >';
  this.layerControl = new Div("LayerControl", left, top, width, height, bvisible, zIndex, this.E3419, maphold);
  this.layerControl.objDiv.clipLayer = clipLayer;
  if (!this.bSimplify)
  {
    this.image = new Image();
    this.image.src = 'images/' + this.strFile + 'slider.gif'; //缩放上的横条
    this.image.id = "ctrlslider";
    this.image.unselectable = "on";
    this.image.style.position = "absolute";
    this.image.style.top = (parseInt(top) + 160) + "px";
    this.image.style.left = (parseInt(left) + 29) + "px";
    this.image.style.width = "19px";
    this.image.style.height = "6px";
    this.image.L71g = 0;
    this.image.maplet = this.maplet;
    this.layerControl.objDiv.appendChild(this.image);
    this.layerControl.objDiv.image = this.image;
    this.image.style.top = (this.maplet.BiggestZoom - 1 - zoomPara) * ControlBarSpace + 97 + parseInt(top) + "px";
    this.image.layerControl = this;
    this.image.offsetY = parseInt(this.maplet.top);
    this.image.top=parseInt(top)
    this.image.onmousedown = function(EVT)
    {
      if (this.L71g == 0)
      {
				this.L71g = parseInt((IE) ? event.clientY : EVT.clientY)-parseInt(top);
      }
      else
      {
				this.L71g = 0
      }
    };
    this.image.onmousemove = function(EVT)
    {
      this.parentNode.style.cursor = "default";
      if (this.L71g > 0)
      {
        var Xhe_0 = parseInt((IE) ? event.clientY : EVT.clientY) - parseInt(this.offsetY)- parseInt(top)+parseInt(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
        if (Xhe_0 >= 97+ parseInt(top) && Xhe_0 < (this.maplet.BiggestZoom - this.maplet.LevelIgnore.length - this.maplet.LeastZoom) * ControlBarSpace + 98+ parseInt(top))
        {
          this.style.top = Xhe_0;
          if (IE)
          {
            this.style.cursor = "move";
            this.parentNode.style.cursor = "move"
          }
        }
        return true
      }
      return false
    };
		this.image.onmouseup = function(EVT)
		{
      if (this.L71g > 0)
      {
        var y = parseInt((IE) ? event.clientY : EVT.clientY) + parseInt(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop)- parseInt(top);
        var zoomPara = this.maplet.BiggestZoom - Math.min(this.maplet.BiggestZoom - this.maplet.LeastZoom, Math.max(0, Math.min(this.maplet.BiggestZoom, parseInt((parseInt(y) - 96 - this.offsetY- parseInt(top)) / ControlBarSpace))));
        this.parentNode.S85(zoomPara);
        this.parentNode.clipLayer.mapContainer.objDiv.style.zoom = 1;
        for (i = this.maplet.LevelIgnore.length; i > 0; i--)
        {
          if (zoomPara <= this.maplet.LevelIgnore[i - 1])
          {
						zoomPara = zoomPara - 1
          }
        }
        this.parentNode.clipLayer.setZoom(parseInt(zoomPara));
        this.L71g = 0
      }
      this.L71g = 0;
      this.style.cursor = "default";
      return true
     }
  };
  this.onmousedown = function(EVT)
  {
		return false
  };
  this.onmousemove = function(EVT)
  {
    if (this.image)
    {
			return (IE) ? this.image.onmousemove() : this.image.onmousemove(EVT)
    }
    else 
    {
			return false
    }
  };
  this.onmouseup = function(EVT)
  {
		return (this.image) ? ((IE) ? this.image.onmouseup() : this.image.onmouseup(EVT)) : false
  };
  this.layerControl.objDiv.S85 = function(zoomPara)
  {
    if (this.image)
    {
      this.removeChild(this.image);
      this.image.style.top = (this.image.maplet.BiggestZoom - this.image.maplet.LevelIgnore.length - zoomPara) * ControlBarSpace + 97+ parseInt(top);
      if (this.image.parentNode == null || this.image.parentNode != this)
      {
				this.appendChild(this.image)
      }
    }
  };
  this.S85 = function(zoomPara)
  {
		this.layerControl.objDiv.S85(zoomPara)
  };
  this.hide = function()
  {
		this.layerControl.hide()
  };
  this.show = function()
  {
		this.layerControl.show()
  };
  this.remove = function()
  {
    this.layerControl.objDiv.clipLayer = null;
    if (this.layerControl.objDiv != null && this.layerControl.objDiv.parentNode != null)
    {
      this.layerControl.objDiv.parentNode.removeChild(this.layerControl.objDiv);
      this.layerControl.objDiv = null
    }
  }
};

/*操作缩放工具条*/
function PerformControl(EVT, objControlBar, num)
{
  switch (num)
  {
    case 1: //west
      objControlBar.parentNode.clipLayer.updateAfterChangeView(parseInt(objControlBar.parentNode.clipLayer.width) / 2, 0);
      break;
    case 2: //north
      objControlBar.parentNode.clipLayer.updateAfterChangeView(0, parseInt(objControlBar.parentNode.clipLayer.height) / 2);
      break;
    case 3: //east
      objControlBar.parentNode.clipLayer.updateAfterChangeView(-parseInt(objControlBar.parentNode.clipLayer.width) / 2, 0);
      break;
    case 4: //south
      objControlBar.parentNode.clipLayer.updateAfterChangeView(0, -parseInt(objControlBar.parentNode.clipLayer.height) / 2);
      break;
    case 5: //zoomin放大
      objControlBar.parentNode.clipLayer.zoomIn()
      break;
    case 6: //zoomout
      objControlBar.parentNode.clipLayer.zoomOut()
      break;
    case 7: //测距
      objControlBar.parentNode.clipLayer.bmeasure = true
      break;
    case 8: //点击缩放
      var y = parseInt((IE) ? event.clientY : EVT.clientY) + parseInt(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop)- objControlBar.parentNode.image.top;
      var zoomPara = objControlBar.parentNode.clipLayer.BiggestZoom - Math.max(0, Math.min(objControlBar.parentNode.clipLayer.BiggestZoom, parseInt((parseInt(y) - 97 - objControlBar.parentNode.image.offsetY- objControlBar.parentNode.image.top) / ControlBarSpace)));
      for (i = objControlBar.parentNode.clipLayer.LevelIgnore.length; i > 0; i--)
      {
        if (zoomPara <= objControlBar.parentNode.clipLayer.LevelIgnore[i - 1])
        {
					zoomPara = zoomPara - 1
        }
      }
      objControlBar.parentNode.clipLayer.setZoom(parseInt(zoomPara));
      break;
    default:
			break
  }
};

function GSToolBar(file, left, top, width, height, bvisible, zIndex, maphold, maplet)
{
  this.strFile = (file == null || file == "undefined") ? '' : file + '/';
  this.maplet = maplet;
  this.E3419 = '<IMG id="tools" unselectable="on" title="选择/平移地图" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,1);" style="position:absolute;left:' + (left + 100) + 'px;top:' + (top+10) + 'px;width:31px;height:31px;" src="images/' + this.strFile + 'Bsd.png" >';
  this.E3419 += '<IMG id="toolm" unselectable="on" title="添加点" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,2);" style="position:absolute;left:' + (left + 132) + 'px;top:' + (top+10) + 'px;width:31px;height:31px;" src="images/' + this.strFile + 'Bmu.png" >';
  this.E3419 += '<IMG id="tooll" unselectable="on" title="添加线" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,3);" style="position:absolute;left:' + (left + 164) + 'px;top:' + (top+10) + 'px;width:31px;height:31px;" src="images/' + this.strFile + 'Blu.png" >';
  this.E3419 += '<IMG id="toolp" unselectable="on" title="添加多边形" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,4);" style="position:absolute;left:' + (left + 196) + 'px;top:' + (top+10) + 'px;width:31px;height:31px;" src="images/' + this.strFile + 'Bpu.png" >';
  this.E3419 += '<IMG id="toolr" unselectable="on" title="添加公路" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,5);" style="position:absolute;left:' + (left + 228) + 'px;top:' + (top+10) + 'px;width:31px;height:31px;" src="images/' + this.strFile + 'Bru.png" >';
  this.E3419 += '<IMG id="toolsr" unselectable="on" title="添加小路" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,6);" style="position:absolute;left:' + (left + 260) + 'px;top:' + (top+10) + 'px;width:31px;height:31px;" src="images/' + this.strFile + 'Bsru.png" >';
  this.E3419 += '<IMG id="toolg" unselectable="on" title="添加高架" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,7);" style="position:absolute;left:' + (left + 292) + 'px;top:' + (top+10) + 'px;width:31px;height:31px;" src="images/' + this.strFile + 'Bgu.png" >';
  this.toolControl = new Div("ToolControl", left, top, width, height, bvisible, zIndex, this.E3419, maphold);
  this.toolControl.objDiv.maplet = maplet;
  this.dbclick = function()
  {
    var maphtml = '<IMG id="tools" unselectable="on" title="选择/平移地图" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,1);" style="position:absolute;left:100px;top:10px;width:31px;height:31px;" src="images/tool/Bsd.png" >';
    maphtml += '<IMG id="toolm" unselectable="on" title="添加点" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,2);" style="position:absolute;left:132px;top:10px;width:31px;height:31px;" src="images/tool/Bmu.png" >';
    maphtml += '<IMG id="tooll" unselectable="on" title="添加线" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,3);" style="position:absolute;left:164px;top:10px;width:31px;height:31px;" src="images/tool/Blu.png" >';
    maphtml += '<IMG id="toolp" unselectable="on" title="添加多边形" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,4);" style="position:absolute;left:196px;top:10px;width:31px;height:31px;" src="images/tool/Bpu.png" >';
    maphtml += '<IMG id="toolr" unselectable="on" title="添加公路" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,5);" style="position:absolute;left:' + (left + 228) + 'px;top:' + (top+10) + 'px;width:31px;height:31px;" src="images/' + this.strFile + 'Bru.png" >';
    maphtml += '<IMG id="toolsr" unselectable="on" title="添加小路" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,6);" style="position:absolute;left:' + (left + 260) + 'px;top:' + (top+10) + 'px;width:31px;height:31px;" src="images/' + this.strFile + 'Bsru.png" >';
    maphtml += '<IMG id="toolg" unselectable="on" title="添加高架" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,7);" style="position:absolute;left:' + (left + 292) + 'px;top:' + (top+10) + 'px;width:31px;height:31px;" src="images/' + this.strFile + 'Bgu.png" >';
    this.toolControl.objDiv.innerHTML = maphtml;
  }
};

function PerformToolControl(EVT, objControlBar, num)
{
  this.maplet = objControlBar.parentNode.maplet
  this.paint = function()
  {
    if (this.maplet.Polyline)
    {
      var totalDistance = 0;
      for (var i = 1; i < this.maplet.Polyline.pts.length; i++)
      {
        var latitude = this.maplet.Polyline.pts[i].lat() - this.maplet.Polyline.pts[i - 1].lat();
        var longitude = this.maplet.Polyline.pts[i].lng() - this.maplet.Polyline.pts[i - 1].lng();
        totalDistance += this.maplet.getSphereDis(new GSLatLng(this.maplet.Polyline.pts[i].lat(), this.maplet.Polyline.pts[i].lng()), new GSLatLng(this.maplet.Polyline.pts[i - 1].lat(), this.maplet.Polyline.pts[i - 1].lng()));
      }
      if (this.maplet.bmeasure)
      {
        totalDistance = Math.round(totalDistance / 100);
        if (totalDistance.toString() == Number.NaN.toString())
            totalDistance = 0;
        distanceBox(this.maplet.width / 2 + this.maplet.left, this.maplet.height / 2 + this.maplet.top, "总距离:" + (parseInt(totalDistance) / 10) + "公里");
        this.maplet.layerDrawMap.objDiv.removeChild(this.maplet.Polyline.elemDiv1);
        this.maplet.removeOverlay(this.maplet.Polyline)
      }
    }
    else if (this.maplet.Polygon)
    {
      this.maplet.Polygon.pts[this.maplet.Polygon.pts.length] = this.maplet.Polygon.pts[0];
      this.maplet.Polygon.S85();
      this.maplet.Polygon.elemPolygon.path.value = this.maplet.Polygon.elemPolygon.path.value.replace(" e", "") + "x e";
    }
    else if (this.maplet.bpoint)
    {
			this.maplet.removeOverlay(this.maplet.Point)
    }
    if (IE && this.maplet.linemove && this.maplet.linemove.elemDiv1.parentNode == this.maplet.layerDrawMap.objDiv)
    {
      this.maplet.layerDrawMap.objDiv.removeChild(this.maplet.linemove.elemDiv1)
      this.maplet.linemove.elemDiv1 = null
      if (this.maplet.bParallel || this.maplet.bSideway)
      {
        this.maplet.layerDrawMap.objDiv.removeChild(this.maplet.linemove.elemDiv)
        this.maplet.linemove.elemDiv = null
      }
    }
    this.maplet.Polyline = null;
    this.maplet.Polygon = null;
    this.maplet.Parallel = null;
    this.maplet.linemove = null;
    this.maplet.Sideway = null;
    this.maplet.OverheadRoad=null;
    this.maplet.bEditline=false;
    this.maplet.bEditgon=false;
  	this.maplet.bEditParallel=false;
    this.maplet.bEditSideway=false;
  	this.maplet.bEditOverheadRoad=false;
  	this.maplet.bEditpoint=false;
  	this.maplet.bpoint = false;
    this.maplet.bmeasure = false;
    this.maplet.bPolygon = false;
    this.maplet.bPolyline = false;
    this.maplet.bParallel = false;
    this.maplet.bSideway = false;
    this.maplet.bOverheadRoad = false
  };
  this.showtool=function(a,b,c,d,e,f,g)
  {
  	var maphtml = '<IMG id="tools" unselectable="on" title="选择/平移地图" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,1);" style="position:absolute;left:100px;top:10px;width:31px;height:31px;" src="images/tool/'+a+'.png" >';
    maphtml += '<IMG id="toolm" unselectable="on" title="添加点" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,2);" style="position:absolute;left:132px;top:10px;width:31px;height:31px;" src="images/tool/'+b+'.png" >';
    maphtml += '<IMG id="tooll" unselectable="on" title="添加线" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,3);" style="position:absolute;left:164px;top:10px;width:31px;height:31px;" src="images/tool/'+c+'.png" >';
    maphtml += '<IMG id="toolp" unselectable="on" title="添加多边形" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,4);" style="position:absolute;left:196px;top:10px;width:31px;height:31px;" src="images/tool/'+d+'.png" >';
    maphtml += '<IMG id="toolr" unselectable="on" title="添加公路" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,5);" style="position:absolute;left:228px;top:10px;width:31px;height:31px;" src="images/tool/'+e+'.png" >';
    maphtml += '<IMG id="toolsr" unselectable="on" title="添加小路" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,6);" style="position:absolute;left:260px;top:10px;width:31px;height:31px;" src="images/tool/'+f+'.png" >';
    maphtml += '<IMG id="toolg" unselectable="on" title="添加高架" onmousemove=style.cursor="hand" onclick="javascript:PerformToolControl(event, this,7);" style="position:absolute;left:292px;top:10px;width:31px;height:31px;" src="images/tool/'+g+'.png" >';
    objControlBar.parentNode.innerHTML = maphtml;
  };
  switch (num)
  {
    case 1: //选择/平移地图
		{
      this.maplet.bmove = true;
      this.maplet.bdbclick = true;
      this.showtool("Bsd","Bmu","Blu","Bpu","Bru","Bsru","Bgu");
      this.paint();
      break;
		}
    case 2: //添加点
    {
  		this.showtool("Bsu","Bmd","Blu","Bpu","Bru","Bsru","Bgu");
      this.paint();
      var b = new GSIcon("images/icon/blue.png", 20, 34);
      this.maplet.Point = new GSMarker(new GSLatLng(this.maplet.latClick, this.maplet.lonClick), b);
      this.maplet.addOverlay(this.maplet.Point);
      this.maplet.bpoint = true;
      break;
    }
    case 3: //添加线
    {
	    this.showtool("Bsu","Bmu","Bld","Bpu","Bru","Bsru","Bgu");
	    this.paint();
	    this.maplet.bPolyline = true;
	    break;
    }
    case 4: //添加点多边形
    {
      this.showtool("Bsu","Bmu","Blu","Bpd","Bru","Bsru","Bgu");
      this.paint();
      this.maplet.bPolygon = true;
      break;
    }
    case 5:
    {
      this.showtool("Bsu","Bmu","Blu","Bpu","Brd","Bsru","Bgu");
      this.paint();
      this.maplet.bParallel = true;
      break;
    }
    case 6:
    {
      this.showtool("Bsu","Bmu","Blu","Bpu","Bru","Bsrd","Bgu");
      this.paint();
      this.maplet.bSideway = true;
      break;
    }
		case 7:
    {
      this.showtool("Bsu","Bmu","Blu","Bpu","Bru","Bsru","Bgd");
      this.paint();
      this.maplet.bOverheadRoad = true;
      break;
    }
    default:
			break
  }
};

/*创建图层，并附加相关操作的类*/
function Div(name, left, top, width, height, bvisible, zIndex, content, mapholder)
{
  this.mapholder = mapholder;
  this.name = name;
  this.hide = function()
  {
		this.style.visibility = "hidden"
  };
  this.show = function()
  {
		this.style.visibility = "visible"
  };
  this.moveTo = function(x, y)
  {
    this.style.left = x;
    this.style.top = y
  };
  this.resize = function(width, height)
  {
    if (parseInt(width) >= 0 && parseInt(height) >= 0)
    {
      this.style.width = width;
      this.style.height = height
    }
  };
  this.height = function()
  {
		return parseInt(this.style.height)
  };
  this.width = function()
  {
		return parseInt(this.style.width)
  };
  this.inRect = function(x, y)
  {
    if (x > parseInt(this.style.left) && x < (parseInt(this.style.left) + parseInt(this.style.width)) && y > parseInt(this.style.top) && y < (parseInt(this.style.top) + parseInt(this.style.height)))
    {
			return true
    }
    return false
  };
  this.appendChild = function(aL8B)
  {
    try
    {
			this.objDiv.appendChild(aL8B)
    }
    catch (EVT)
    {
    }
  };
  this.removeChild = function(fK)
  {
    try
    {
			this.objDiv.removeChild(fK)
    }
    catch (EVT) { }
  };
  this.clear = function()
  {
    while (this.objDiv.hasChildNodes())
    {
			this.objDiv.removeChild(this.objDiv.lastChild)
    }
  };
  this.clean = this.clear;
  this.getName = function()
  {
		return this.name
  };
  try 
  {
    this.objDiv = creatDiv(this.name, left, top, width, height, bvisible, zIndex, content);
    this.objDiv.unselectable = "on";
    if (this.mapholder)
			this.mapholder.appendChild(this.objDiv);
    this.style = this.objDiv.style;
  }
  catch (EVT) {}
};

/*创建图层*/
function creatDiv(name, left, top, width, height, bvisible, zIndex, content) 
{
	var tempDiv = document.createElement("div");
	tempDiv.unselectable = "on";
	tempDiv.id = name;
	tempDiv.style.position = "absolute";
	tempDiv.style.top = top + "px";
	tempDiv.style.left = left + "px";
	tempDiv.style.zIndex = zIndex;
	tempDiv.style.width = width + "px";
	tempDiv.style.height = height + "px";
	tempDiv.style.visibility = (bvisible) ? 'visible' : 'hidden';
	tempDiv.innerHTML = content;
	return tempDiv
};

function GSScaleControl(x, y) {
	this.x = (typeof x == "undefined") ? 0 : parseInt(x);
	this.y = (typeof y == "undefined") ? 0 : parseInt(y);
	this.id = new Date().getTime() + parseInt(Math.random() * 1000);
  this.qc = function(maplet)
  {
    this.maplet = maplet;
    if (this.maplet.gc[this.id] == null)
    {
      this.maplet.gc[this.id] = this;
      this.maplet.layerScale = new Div("LayerScale", 10 - this.x, this.maplet.height - 24 - this.y, 100, 24, true, 3, '', this.maplet.holder);
      if (this.maplet.zoomLevel)
				this.maplet.updateOthers();
    }
  };
  this.remove = function()
  {
    if (this.maplet.layerScale)
    {
      this.maplet.layerScale.clear();
      this.maplet.layerScale = null
    }
    this.maplet = null;
  };
  this.toString = function()
  {
		return 'com.toogo.maplet.GSScaleControl'
  }
};

function GSSmallMapControl(x, y)
{
  this.x = (typeof x == "undefined") ? 0 : parseInt(x);
  this.y = (typeof y == "undefined") ? 0 : parseInt(y);
  this.id = new Date().getTime() + parseInt(Math.random() * 1000);
  this.qc = function(maplet)
  {
    this.maplet = maplet;
    if (this.maplet.gc[this.id] == null)
    {
      this.maplet.gc[this.id] = this;
      this.maplet.controlBar = new GSControlBar("toogo", this.maplet.zoomLevel ? this.maplet.zoomLevel : 1, this.x+5, this.y+10, 90, 120, true, 3, this.maplet.holder, this.maplet, 1)
    }
  };
  this.remove = function()
  {
    if (this.maplet.controlBar)
    {
      this.maplet.controlBar.remove();
      this.maplet.controlBar = null
    }
    this.maplet = null;
  };
  this.toString = function() {
      return 'com.toogo.maplet.GSmallMapControl'
  }
};

function GSLargeMapControl(x, y)
{
  this.x = (typeof x == "undefined") ? 0 : parseInt(x);
  this.y = (typeof y == "undefined") ? 0 : parseInt(y);
  this.id = new Date().getTime() + parseInt(Math.random() * 1000);
  this.qc = function(maplet)
  {
    this.maplet = maplet;
    if (this.maplet.gc[this.id] == null)
    {
      this.maplet.gc[this.id] = this;
      this.maplet.controlBar = new GSControlBar("toogo", this.maplet.zoomLevel ? this.maplet.zoomLevel : 1, this.x+5, this.y+10, 90, 298, true, 3, this.maplet.holder, this.maplet)
    }
  };
  this.remove = function()
  {
    if (this.maplet.controlBar)
    {
      this.maplet.controlBar.remove();
      this.maplet.controlBar = null
    }
    this.maplet = null;
  };
  this.toString = function()
  {
		return 'com.toogo.maplet.GSmallMapControl'
  }
};
function GSOverviewMapControl()
{
  this.id = new Date().getTime() + parseInt(Math.random() * 1000);
  this.qc = function(maplet)
  {
    this.maplet = maplet;
    if (this.maplet.gc[this.id] == null)
    {
      this.maplet.gc[this.id] = this;
      this.maplet.ovw = new overview(this.maplet)
      this.maplet.ovw.qa(this.maplet.holder);
      if (this.maplet.layerLogo)
      {
        this.maplet.onresize();
        this.maplet.ovw.paint()
      }
    }
  };
  this.remove = function()
  {
    if (this.maplet.ovw)
    {
      this.maplet.ovw.clear();
      this.maplet.ovw = null
    }
    this.maplet = null;
  };
  this.toString = function()
  {
		return 'com.toogo.maplet.GSOverviewMapControl'
  }
};

function GSToolControl(x, y)
{
  this.x = (typeof x == "undefined") ? 0 : parseInt(x);
  this.y = (typeof y == "undefined") ? 0 : parseInt(y);
  this.id = new Date().getTime() + parseInt(Math.random() * 1000);
  this.qc = function(maplet)
  {
    this.maplet = maplet;
    if (this.maplet.gc[this.id] == null)
    {
      this.maplet.gc[this.id] = this;
      this.maplet.toolBar = new GSToolBar("tool", this.x, this.y, 200, 35, true, 3, this.maplet.holder, this.maplet)
    }
  };
  this.remove = function()
  {
    if (this.maplet.toolBar)
    {
      this.maplet.toolBar.clear();
      this.maplet.toolBar = null
    }
    this.maplet = null;
  };
  this.toString = function()
  {
		return 'com.toogo.maplet.GSToolControl'
  }
};

function clearOnerror()
{
	if (document.all)
	{
    for (var i = 0, length = document.all.length; i < length; i++)
    {
			document.all[i]['onerror'] = null
    }
	}
};
/*测距时的右下角"请双击结束"的提示框*/
var mousetipboxDiv = null;
function showMouseTipBox(x, y, tipContent, mapholder)
{
  try
  {
    if (mousetipboxDiv == null || mousetipboxDiv == "undefined")
    {
      var distance = '<table border="1" cellspacing="0" cellpadding="0" bordercolor=#FF0000>' + '<tr><td width="100%" bgcolor=#FFFFCC>' + '<font class="ptlabel" color="#000000" >' + tipContent + '</font>' + '</td></tr>' + '</table>';
      mousetipboxDiv = creatDiv("mousetipbox", parseInt(x) + 10, parseInt(y) + 18, 70, 20, 1, 100, distance);
      mousetipboxDiv.unselectable = "on";
      mousetipboxDiv.style.FsD = "none"
    }
    else
  	{
      mousetipboxDiv.style.left = parseInt(x) + 10;
      mousetipboxDiv.style.top = parseInt(y) + 18;
      mousetipboxDiv.visibility = "visible"
    }
    if (mousetipboxDiv != null && (mousetipboxDiv.parentNode == null || mousetipboxDiv.parentNode != mapholder))
    {
			mapholder.appendChild(mousetipboxDiv)
    }
  }
  catch (H694) {}
};
/*双击后去除"请双击结束"的提示框*/
function removeTipbox()
{
  if (mousetipboxDiv != null)
  {
    if (mousetipboxDiv.parentNode != null)
    {
			mousetipboxDiv.parentNode.removeChild(mousetipboxDiv)
    }
    mousetipboxDiv = null
  }
};

/*导航图*/
function overview(maplet)
{
  this.maplet = maplet;
  document["toogo-overview"] = this;
  this.ca = false;
  this.vb = document.createElement("div");
  this.vb.unselectable = "on";
  this.vb.style.position = "absolute";
  this.vb.style.visibility = "visible";
  this.vb.style.zIndex = 1000;
  this.vb.style.backgroundColor = "white";
  this.vb.style.borderLeftStyle = "solid";
  this.vb.style.borderLeftWidth = "1px";
  this.vb.style.borderLeftColor = "#949694";
  if (this.ca)
  {
    this.vb.style.borderBottomStyle = "solid";
    this.vb.style.borderBottomWidth = "1px";
    this.vb.style.borderBottomColor = "#949694"
  }
  else
	{
    this.vb.style.borderTopStyle = "solid";
    this.vb.style.borderTopWidth = "1px";
    this.vb.style.borderTopColor = "#949694"
  }
  this.vb.style.overflow = "hidden";
  this.c3 = true;
  if (this.ca)
  {
		this.vb.style.top = "0px"
  }
  else
	{
    if (this.c3)
    {
			this.vb.style.top = (this.maplet.height - owh) + "px"
    }
    else
  	{
      this.vb.style.top = (this.maplet.height - uS) + "px"
    }
  }
  this.fC = document.createElement("div");
  this.fC.id = "toogo-overview-canvas";
  this.fC.unselectable = "on";
  this.fC.style.position = "absolute";
  this.fC.style.visibility = "visible";
  this.fC.style.zIndex = 0;
  if (this.ca)
  {
		this.fC.style.top = "0px"
  }
  else
	{
    this.fC.style.top = (uU - 1) + "px"
  }
  this.fC.style.left = "7px";
  this.fC.style.backgroundColor = "buttonface";
  this.fC.style.borderStyle = "solid";
  this.fC.style.borderWidth = "1px";
  this.fC.style.overflow = "hidden";
  this.fC.style.borderColor = "#949694";
  this.fC.selected = false;
  this.vb.appendChild(this.fC);
  this.cW = 0;
  this.show = function()
  {
    this.vb.style.visibility = "visible";
    this.vb.style.display = "block"
  };
  this.hide = function()
  {
    this.close();
    this.vb.style.visibility = "hidden";
    this.vb.style.display = "none"
  };
  this.top = function()
  {
		return parseInt(this.vb.style.top)
  };
  this.height = function()
  {
		return parseInt(this.vb.style.height)
  };
  this.mousedownfun = function(EVT)
  {
    var event = window.event;
    if (this.fC.setCapture)
    {
			this.fC.setCapture();
    }
    else if (window.captureEvents)
  	{
      window.captureEvents(event.MOUSEMOVE | event.MOUSEUP);
    }
    if (this.maplet.bmove)
    {
      this.down = true;
      var xdown = (IE) ? event.clientX : EVT.clientX;
      var ydown = (IE) ? event.clientY : EVT.clientY;
      this.downx = xdown;
      this.downy = ydown;
    }
  };
  this.mousemovefun = function(EVT)
  {
    var event = window.event;
    if (this.down && this.maplet.bmove)
    {
      this.move = true;
      var xmove = (IE) ? event.clientX : EVT.clientX;
      var ymove = (IE) ? event.clientY : EVT.clientY;
      var movex = (xmove - this.downx);
      var movey = ymove - this.downy;
      this.viewContainer.moveTo(movex, movey)
      this.fC.style.cursor = "move";
    }
  };
  this.mouseupfun = function(EVT)
  {
    var event = window.event;
    if (this.fC.releaseCapture)
    {
			this.fC.releaseCapture();
    }
    else if (window.captureEvents)
  	{
      window.captureEvents(event.MOUSEMOVE | event.MOUSEUP);
    }
    this.fC.style.cursor = "default";
    if (this.down && this.move)
    {
      this.up = true;
      var xup = (IE) ? event.clientX : EVT.clientX;
      var yup = (IE) ? event.clientY : EVT.clientY;
      this.upx = xup;
      this.upy = yup;
      var latlng=this.maplet.ScreenToLatlng((this.downx-this.upx),(this.downy-this.upy),this.zoomLevel);
			this.ycenter=latlng.lat();
			this.xcenter=latlng.lng();
      this.maplet.setCenter(new GSLatLng(this.ycenter, this.xcenter), this.maplet.zoomLevel);
    }
    this.down = false;
    this.move = false;
  };

  this.pU = new Array();
  this.yN = null;
  this.c4 = false;
  this.cl = false;
  if (this.c3)
	{
    var An = (IE) ? 0 : 2;
    this.vb.style.left = (parseInt(this.maplet.width) - oww) + "px";
    this.vb.style.width = oww + "px";
    this.vb.style.height = owh + "px";
    this.fC.style.width = (oww - 8 - An) + "px";
    this.fC.style.height = (owh - 8) + "px"
  }
  else
	{
    var An = (IE) ? 0 : 1;
    this.vb.style.left = (parseInt(this.maplet.width) - uS) + "px";
    this.vb.style.width = (uS) + "px";
    this.vb.style.height = (uS - An) + "px";
    this.fC.style.width = (uS - 4) + "px";
    this.fC.style.height = (uS - 4) + "px"
  }
  this.sa = new Array();
  this.width = function()
  {
		return parseInt(this.vb.style.width)
  };

  this.uq = function()
  {
    for (var pf in this.sa)
    {
      if (this.sa[pf] && this.sa[pf].onresize)
      {
				this.sa[pf].onresize()
      }
    }
    this.maplet.onresize()
  };

  this.onresize = function()
  {
    if (this.c3)
    {
			this.vb.style.left = (parseInt(this.maplet.width) - oww) + "px"
    }
    else
  	{
      this.vb.style.left = (parseInt(this.maplet.width) - uS) + "px"
    }
    if (!this.ca)
    {
			this.vb.style.top = (this.maplet.height - parseInt(this.vb.style.height)) + "px"
    }
    this.uq()
  };
  this.close = function()
  {
    if (this.c4)
			return;
    if (this.img.src != "images/toogo/overopen2.gif")
			this.img.src = "images/toogo/overopen2.gif";
    var An = (IE) ? 0 : 1;
    if (this.yN)
			clearTimeout(this.yN);
    this.yN = null;
    if (parseInt(this.vb.style.width) > 2 * uS)
    {
      this.vb.style.left = (parseInt(this.vb.style.left) + uS) + "px";
      this.vb.style.width = (parseInt(this.vb.style.width) - uS) + "px";
      this.vb.style.height = (parseInt(this.vb.style.height) - (uS - 5)) + "px";
      this.fC.style.width = (parseInt(this.vb.style.width) - uS - 4) + "px";
      this.fC.style.height = (parseInt(this.vb.style.height) - (uS - 5) - 4) + "px";
      this.img.style.left = (parseInt(this.vb.style.width) - uS - 1 + An) + "px";
      this.cl = true;
      this.yN = getTimeout(this, this.close, 10)
    }
    else
  	{
      this.vb.style.left = (parseInt(this.maplet.width - uS)) + "px";
      this.vb.style.width = (uS) + "px";
      this.vb.style.height = (uS - An) + "px";
      this.fC.style.width = (uS - 4) + "px";
      this.fC.style.height = (uS - 4) + "px";
      this.img.style.left = "-1px";
      this.cl = false
    }
    if (!this.ca)
    {
      this.vb.style.top = (this.maplet.height - parseInt(this.vb.style.height)) + "px";
      this.img.style.top = (parseInt(this.vb.style.height) - uS - 1) + "px"
    }
    this.uq()
  };
  this.open = function()
  {
    if (this.cl)
			return;
    var An = (IE) ? 0 : 2;
    if (this.img.src != "images/toogo/overclose2.gif")
			this.img.src = "images/toogo/overclose2.gif"
    if (this.yN)
			clearTimeout(this.yN);
    this.yN = null;
    if (parseInt(this.vb.style.width) < (oww - 2 * uS))
    {
      this.vb.style.left = (parseInt(this.vb.style.left) - uS) + "px";
      this.vb.style.width = (parseInt(this.vb.style.width) + uS) + "px";
      this.vb.style.height = (parseInt(this.vb.style.height) + (uS - 5)) + "px";
      this.fC.style.width = (parseInt(this.vb.style.width) - 4 - An) + "px";
      this.fC.style.height = (parseInt(this.vb.style.height) - 8 - 4) + "px";
      this.img.style.left = (parseInt(this.vb.style.width) - uS - 1) + "px";
      this.c4 = true;
      this.yN = getTimeout(this, this.open, 10)
    }
    else
  	{
      this.vb.style.left = (parseInt(this.maplet.width) - oww) + "px";
      this.vb.style.width = (oww) + "px";
      this.vb.style.height = (owh) + "px";
      this.fC.style.width = (oww - 8 - An) + "px";
      this.fC.style.height = (owh - 8) + "px";
      this.img.style.left = (oww - uS - 1) + "px";
      this.paint();
      this.c4 = false
    }
    if (!this.ca)
    {
      this.vb.style.top = (this.maplet.height - parseInt(this.vb.style.height)) + "px";
      this.img.style.top = (parseInt(this.vb.style.height) - uS - 1) + "px"
    }
    this.uq()
  };
  this.qa = function(f2)
  {
    var An = (IE) ? 0 : 2;
    this.img = new Image();
    this.img.unselectable = "on";
    this.img.style.position = "absolute";
    this.img.style.zIndex = 2000;
    this.img.style.left = "-1px";
    this.img.width = uS + "px";
    this.img.height = uS + "px";
    this.img.style.width = uS + "px";
    this.img.style.height = uS + "px";
    this.img.ovw = this;
    this.img.style.cursor = (IE) ? "hand" : "pointer";
    this.img.src = "images/toogo/overclose2.gif";
    this.img.onclick = function()
    {
      if (this.ovw.c3)
      {
				this.ovw.close()
      }
      else
    	{
        this.ovw.open()
      }
      this.ovw.c3 = !this.ovw.c3
    };
    if (this.c3)
    {
			this.img.src = "images/toogo/overclose2.gif"
    }
    else
  	{
      this.img.src = "images/toogo/overopen2.gif"
    }
    if (this.ca)
    {
			this.img.style.top = "0px"
    }
    else
  	{
      this.img.style.top = (parseInt(this.vb.style.height) - uS - 1) + "px"
    }
    this.img.style.left = (parseInt(this.vb.style.width) - uS - 1) + "px";
    this.vb.appendChild(this.img);
    f2.appendChild(this.vb);
    GSEvent.addListener(this.fC, "mousedown", this, this.mousedownfun);
    GSEvent.addListener(this.fC, "mousemove", this, this.mousemovefun);
    GSEvent.addListener(this.fC, "mouseup", this, this.mouseupfun)
  };

  this.paint = function()
	{
    if (!this.c3)
			return;
    this.wh = oww - 10;
    this.ht = owh - 10;
    if (!this.viewContainer)
			this.viewContainer = new Div("viewContainer", 0, 0, this.wh, this.ht, true, 2, '', this.fC);
    this.viewContainer.moveTo(0, 0);
    this.viewContainer.objDiv.style.zoom = 1;
    this.viewContainer.objDiv.innerHTML = '';
    this.zoomLevel = Math.max(0, ovz[this.maplet.zoomLevel]);
    innerHtmlImg = '';
   	if(this.maplet.Projection == "toogo"||this.maplet.Projection == "Toogo"||this.maplet.Projection == "TooG"||this.maplet.Projection == "TOOGO")
   	{
   		innerHtmlImg=this.maplet.toogo(this.wh,this.ht,this.zoomLevel,"toogoovwinfo")
   	}
    else if(this.maplet.Projection == "google"||this.maplet.Projection == "Google"||this.maplet.Projection == "GooGle"||this.maplet.Projection == "GOOGLE")  
    {
    	innerHtmlImg=this.maplet.google(this.wh,this.ht,this.zoomLevel,"toogoovwinfo")
    }
    else if(this.maplet.Projection == "baidu"||this.maplet.Projection == "Baidu"||this.maplet.Projection == "BaiDu"||this.maplet.Projection == "BAIDU")
    {
    	innerHtmlImg=this.maplet.baidu(this.wh,this.ht,this.zoomLevel,"toogoovwinfo")
    }
    else if(this.maplet.Projection == "yahoo"||this.maplet.Projection == "Yahoo"||this.maplet.Projection == "YaHoo"||this.maplet.Projection == "YAHOO")
    {
    	innerHtmlImg=this.maplet.yahoo(this.wh,this.ht,(this.zoomLevel<=2?2:this.zoomLevel),"toogoovwinfo")
    }
    else if(this.maplet.Projection == "51ditu"||this.maplet.Projection == "51DiTu"||this.maplet.Projection == "51Ditu"||this.maplet.Projection == "51DITU")
    {
    	innerHtmlImg=this.maplet.ditu51(this.wh,this.ht,this.zoomLevel,"toogoovwinfo")
    }
    else if(this.maplet.Projection == "sogou"||this.maplet.Projection == "Sogou"||this.maplet.Projection == "SoGou"||this.maplet.Projection == "SOGOU")
    {
    	innerHtmlImg=this.maplet.sogou(this.wh,this.ht,this.zoomLevel,"toogoovwinfo")
    }
    else if(this.maplet.Projection == "bing")
    {
    	innerHtmlImg=this.maplet.bing(this.wh,this.ht,(this.zoomLevel<=1?1:this.zoomLevel),"toogoovwinfo")
    }
    this.viewContainer.objDiv.innerHTML = innerHtmlImg;
    innerHtmlImg = null;
  };
};

/*自定义事件处理*/
window.GSEvent =
{
  addListener: function(obj, eventname, fU, q0)
  {
    var an = this.gm(fU, q0);
    return this.addBuiltInListener(obj, eventname, an)
  },
  gm: function(uy, eventname)
  {
    return function(EVT)
    {
      EVT = ny(EVT);
      eventname.call(uy, EVT)
    }
  },
  addBuiltInListener: function(obj, eventname, q0)
  {
    var objGEventListener = new GSEventListener();
    objGEventListener.marker = obj;
    objGEventListener.eventType = eventname;
    objGEventListener.handler = q0;
    if (obj.addEventListener)
    {
			obj.addEventListener(eventname, q0, false)
    }
    else if (obj.attachEvent)
    {
			obj.attachEvent("on" + eventname, q0)
    }
    else 
  	{
      obj["on" + eventname] = q0
    }
    return objGEventListener;
  },
  removeListener: function(obj, eventname, q0)
  {
//    if (obj.removeEventListener)
//    {
//			obj.removeEventListener(eventname, q0, false)
//    }
//    else if (obj.detachEvent)
//    {
//			obj.detachEvent("on" + eventname, q0)
//    }
//    else
//    {
//			obj["on" + eventname] = null
//    }
    this.removeobjGEventListener(q0);
  },
    removeobjGEventListener:function(objGEventListener)      //wgf 09102 this.ao里保存的是objGEventListener对象，不是事件
  {
	  
      if (objGEventListener.marker.removeEventListener)
    {
			objGEventListener.marker.removeEventListener(objGEventListener.eventType, objGEventListener.handler, false)
    }
    else if (objGEventListener.marker.detachEvent)
    {
			objGEventListener.marker.detachEvent("on" +objGEventListener.eventType,objGEventListener.handler)
    }
    else
    {
			objGEventListener.marker["on" + objGEventListener.eventType] = null
    }
  }
};

function ny(EVT)
{
  if (!EVT)
  {
		EVT = window.event
  }
  if (EVT && !EVT.target)
  {
		EVT.target = EVT.srcElement
  }
  if (EVT && typeof EVT.button == "undefined")
  {
		EVT.button = EVT.which
  }
  return EVT
};
var fJ = function(obj, yH)
{
  var flag = false;
  while (obj != null)
  {
    if ((typeof yH == "string" && obj.id == yH) || (obj == yH))
    {
      flag = true;
      break
    }
    obj = obj.parentNode
  }
  return flag
};

var GSBrush = function(color, stroke, style, fill, bgcolor, transparency, bgtransparency, arrow)
{
  this.color = (typeof color == "undefined") ? "#FF0000" : color;
  this.stroke = (typeof stroke == "undefined") ? 5 : parseInt(stroke);
  this.style = (typeof style == "undefined") ? 0 : parseInt(style);
  this.fill = (typeof fill == "undefined") ? false : fill;
  this.bgcolor = (typeof bgcolor == "undefined") ? this.color : bgcolor;
  this.transparency = (typeof transparency == "undefined") ? transparencyLevel : parseInt(transparency);
  this.bgtransparency = (typeof bgtransparency == "undefined") ? transparencyLevel / 2 : parseInt(bgtransparency);
  this.arrow = (typeof arrow == "undefined") ? bArrow : arrow;
  this.toString = function()
  {
		return 'com.toogo.maplet.GSBrush'
  }
};

function GSIcon(imgurl, width, height, x, y)
{
  this.icon = document.createElement("div");
  this.icon.unselectable = "on";
  this.icon.style.zIndex = 9;
  this.icon.style.position = "absolute";
   var str=imgurl.substring(imgurl.lastIndexOf('.')+1,imgurl.length);
  if(str=="png"||str=="PNG"||str=="jpg"||str=="JPG"||str=="gif"||str=="GIF"||str=="bmp"||str=="BMP")
  {
  	this.width = (typeof width == "undefined") ? 20 : width;
  	this.height = (typeof height == "undefined") ? 34 : height;
  }
  else
  {
  	this.width = (typeof width == "undefined") ? 10 : width;
  	this.height = (typeof height == "undefined") ? 20 : height;
  }
  this.img = document.createElement("div");
  this.img.unselectable = "on";
  this.img.style.MozUserSelect = "none";
  this.img.style.zIndex = 100;
  this.img.style.position = "absolute";
  this.img.style.cursor = "hand";
  this.img.style.cursor = "pointer";
  this.img.style.top = "0px";
  this.img.style.left = "0px";
  this.imgcolor="#FF0000"
  this.setColor=function(color)
  {
  	this.imgcolor=color;
  }
  this.setStyle=function(style)
	{
		if(this.icon)
		{
			this.icon.style.zIndex=style
		}
	};
  var str=imgurl.substring(imgurl.lastIndexOf('.')+1,imgurl.length);
  if(str=="png"||str=="PNG"||str=="jpg"||str=="JPG"||str=="gif"||str=="GIF"||str=="bmp"||str=="BMP")
  	this.imgurl = "<img src=" + imgurl + ">";
  else
  {
  	this.imgurl = '<div unselectable="on"><TABLE cellSpacing=0 cellPadding=0 border=0><TBODY><TR><TD unselectable="on" style="z-Index:1;FONT-SIZE: 12px; COLOR='+this.imgcolor+';FONT-WEIGHT: bold;" width="100%">'+imgurl+'</TD></TR></TBODY></TABLE></div>'
	}
  this.wz = function(id)
  {
    this.icon.id = "Overlaytoogo" + id;
    this.img.children[0].children[0].children[0].children[0].children[0].children[0].id = "ico_"+id;
  };

  this.updateImage = function(urlimg, widthimg, heightimg)
  {
  	var str=urlimg.substring(urlimg.lastIndexOf('.')+1,urlimg.length);
  	if(str=="png"||str=="PNG"||str=="jpg"||str=="JPG"||str=="gif"||str=="GIF"||str=="bmp"||str=="BMP")
  		this.imgurl = "<img src=" + urlimg + " width=" + (typeof widthimg == "undefined" ? this.width : widthimg) + "px height=" + (typeof heightimg == "undefined" ? this.height : heightimg) + "px >";
  	else
  		this.imgurl = '<div unselectable="on"><TABLE cellSpacing=0 cellPadding=0 border=0><TBODY><TR><TD unselectable="on" style="z-Index:1;FONT-SIZE: 12px; COLOR='+this.imgcolor+';FONT-WEIGHT: bold;" width="100%">'+urlimg+'</TD></TR></TBODY></TABLE></div>'

    if (this.imgurl != null)
    {
			this.img.innerHTML = this.imgurl
    }
    else
    {
			this.img.innerHTML = "<img src=images/icon/blue.png width=" + (typeof widthimg == "undefined" ? width : widthimg) + "px height=" + (typeof heightimg == "undefined" ? height : heightimg) + "px >";
		}
  };
  this.updateImage(this.imgurl);
  this.width = (typeof this.width == "undefined") ? parseInt(this.img.width) : parseInt(this.width);
  this.height = (typeof this.height == "undefined") ? parseInt(this.img.height) : parseInt(this.height);
  this.icon.style.width = this.width + "px";
  this.icon.style.height = this.height + "px";
  this.x = (typeof x == "undefined") ? this.width / 2 : parseInt(x);
  this.y = (typeof y == "undefined") ? this.height : parseInt(y);
  this.icon.appendChild(this.img);

  this.paint = function(maplet, left, top)
  {
    var zB = parseInt(left) - parseInt(this.x);
    var zF = parseInt(top) - parseInt(this.y);
    if (zB > maplet.width || zB < -this.width || zF > maplet.height || zF < -this.height)
    {
      if (this.icon.parentNode)
      {
        this.icon.parentNode.removeChild(this.icon);
        this.fu = false
      }
    }
    else
    {
      if (this.icon.parentNode != maplet.layerDrawMap)
      {
        maplet.layerDrawMap.appendChild(this.icon);
        this.icon.style.width = this.width + "px";
        this.icon.style.height = this.height + "px";
        this.img.width = this.width + "px";
        this.img.height = this.height + "px";
        this.icon.style.top = parseInt(zF) + "px";
        this.icon.style.left = parseInt(zB) + "px";
        this.fu = true
      }
    }
  };
  this.qs = function()
  {
		return (this.fu)
  };
  this.zq = function()
  {
		return (this.img.firstChild.src) + "," + this.width + "," + this.height
  };

  this.hilite = function()
  {
    if (this.icon)
    {
      if (this.icon.style.zIndex < pF)
      { pF++ }
      this.icon.style.zIndex = pF
    }
  };
  this.hide = function()
  {
		this.icon.style.display = "none"
  };
  this.show = function()
  {
		this.icon.style.display = "block"
  };
  this.remove = function()
  {
    if (this.icon && this.icon.parentNode)
    {
//        var Ddiv=document.createElement("div");
//        Ddiv.appendChild(this.icon);
//        Ddiv.innerHTML="";
//        Ddiv=null;
			this.icon.parentNode.removeChild(this.icon)
			this.icon.removeNode();
			//removeChildSafe(this.icon);
			//this.icon.innerHTML="";
			this.icon=null;
    }
  };
  this.toString = function()
  {
		return 'com.toogo.maplet.MIcon'
  }
};
var markerinfo = '';
function removeChildSafe(el) {
    //before deleting el, recursively delete all of its children.
    while(el.childNodes.length > 0) {
        removeChildSafe(el.childNodes[el.childNodes.length-1]);
    }
    el.parentNode.removeChild(el);
    el.removeNode(); 
}
function GSMarker(pt, icon, info)
{
  this.id = new Date().getTime() + "" + parseInt(Math.random() * 10000);
  this.pt = pt;
  this.ao = new Array();
  this.icon = (typeof icon == "undefined") ? (new GSIcon("images/icon/blue.png", 20, 34)) : icon;
  if (this.icon && this.icon.wz)
  {
		//this.icon.wz(this.id)
  }
  this.bmove = false;
  this.info = null;
  if (typeof info != "undefined" && info)
  {
		this.info = info;
  }
  this.ls = false;
  this.wz = function(id)
  {
    this.id = id;
    if (this.icon && this.icon.wz)
    {
			//this.icon.wz(id)
    }
  };
  this.qc = function(maplet)
  {
    this.maplet = maplet;
    if (this.info)
    {
			this.ao["click"] = GSEvent.addListener(this.maplet.holder, "click", this, this.openInfoWindow())
    }
    this.ao["mousedown"] = GSEvent.addListener(this.maplet.holder, "mousedown", this, this.mousedownfun);
    this.ao["mousemove"] = GSEvent.addListener(this.maplet.holder, "mousemove", this, this.mousemovefun);
    this.ao["mouseup"] = GSEvent.addListener(this.maplet.holder, "mouseup", this, this.mouseupfun);
    if (typeof this.maplet.holder != "undefined")
    {
			this.paint()
    }
  };
  this.toString = function()
  {
		return 'com.toogo.maplet.GSMarker'
  };
  this.paint = function()
  {
  	var xy=this.maplet.LatlngToScreen(parseFloat(this.pt.lng()),parseFloat(this.pt.lat()));
		var x =xy.x();
		var y =xy.y();
    if (this.icon)
    {
			this.icon.paint(this.maplet, x, y);
    }
  };
  this.hide = function()
  {
    if (this.icon)
			this.icon.hide()
  };
  this.show = function()
  {
    if (this.icon)
			this.icon.show()
  };
  this.remove = function()
  {
    for (var eventname in this.ao)
    {
      GSEvent.removeListener(this.maplet.holder, eventname, this.ao[eventname]);
      this.ao[eventname] = null
    }
    if (this.icon)
    {
			this.icon.remove()
    }

    this.maplet = null
  };
  this.openInfoWindow = function(content)
  {
    this.info = content?content:this.info;
		markerinfo = this.info;
		this.maplet.moveTo(this.pt);
		visible();
  };

  this.mousedownfun = function(EVT)
  {
    if (this.bmove && this.icon != null && this.maplet && fJ((IE) ? event.srcElement : EVT.target, this.icon.img) && EVT.button != 2)
    {
      this.qo = true;
      this.l6 = this.id;
      this.l0 = parseInt(EVT.clientX - this.maplet.left) - parseInt(this.icon.icon.style.left)+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
      this.na = parseInt(EVT.clientY - this.maplet.top) - parseInt(this.icon.icon.style.top)+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
    }
    else
			hidden()
  };
  this.mousemovefun = function(EVT)
  {
    if (this.bmove && this.icon != null && this.maplet && this.l6 == this.id)
    {
      if (this.qo)
      {
        var x = EVT.clientX - this.maplet.left- this.l0 + this.icon.x+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
        var y = EVT.clientY - this.maplet.top - this.na + this.icon.y+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
        this.icon.paint(this.maplet, x, y);
        this.ls = true
      }
    }
  };
  this.mouseupfun = function(EVT)
  {
    if (this.icon != null && this.maplet && this.qo)
    {
      var xclient = EVT.clientX  - this.maplet.left - this.l0+ this.icon.x+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
      var yclient = EVT.clientY  - this.maplet.top - this.na+ this.icon.y+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
      this.qo = false;
      var latlng=this.maplet.ScreenToLatlng(xclient,yclient);
			var lat=latlng.lat();
			var lng=latlng.lng();
      this.pt = new GSLatLng(lat, lng);
      if (this.ls)
      {
        this.ls = false;
        if (document.getElementById("mymarker").style.visibility == "visible")
        {
          markertagBox(this.info, xclient + this.maplet.left, yclient + this.maplet.top);
          visible()
        }
        else
					hidden()
      }
    }
    if (this.l6 == this.id)
    {
			this.l6 = null
    }
  };
  this.getLatLng = function()
  {
    x = this.pt.lng();
    y = this.pt.lat();
    return new GSLatLng(y, x);
  };
  this.enableDragging = function()
  {
		this.bmove = true;
  };
  this.disableDragging = function()
  {
		this.bmove = false;
  };
  this.draggable = function()
  {
    if (this.bmove)
			return true;
    else
			return false;
  };
};
function GSPlyline_paint()   //wgf
{
        if(IE)
        {
            if (typeof this.elemDiv1 == "undefined")
            {
              this.elemDiv1 = document.createElement("div");
              this.elemDiv1.unselectable = "on";
              this.elemDiv1.style.zIndex = 10;
              this.elemDiv1.style.position = "absolute";
              this.elemDiv1.style.cursor = (IE) ? "hand" : "pointer";
              this.elemPolyline = document.createElement("v:polyline");
              this.elemPolyline.unselectable = "on";
              this.elemPolyline.strokecolor = this.strokeColor;
              this.elemPolyline.strokeweight = this.strokeWeight + 'pt';
              this.elemPolyline.fill = "false";
              this.elemPolyline.filled = "false";
              this.elemStroke = document.createElement("v:stroke");
              this.elemStroke.opacity = (this.strokeOpacity / 100);
              this.elemStroke.joinstyle = "round";
              this.elemStroke.endcap = "round";
              this.elemStroke.fill = "false";
              this.elemStroke.dashstyle="LongDash";
	          this.elemStroke.EndArrow="Block";
    	      
            }
          }
          else
          {
            this.elemDiv1=document.getElementById("vCanvasSVG");
                this.elemPolyline=document.getElementById("LayerDrawSVG");
                if(this.elemDiv1==null)
                {
                    this.elemDiv1=document.createElement("div");
                    //this.elemDiv1.vb=this;
                    this.elemDiv1.id="vCanvasSVG";
                    this.elemDiv1.style.position="absolute";
                    this.elemDiv1.unselectable="on";
                    this.elemDiv1.style.zIndex=10;
                    this.elemDiv1.style.MozUserSelect="none";
                    this.elemPolyline=document.createElementNS("http://www.w3.org/2000/svg","svg");
                    this.elemPolyline.setAttribute("id","LayerDrawSVG");
                    this.elemPolyline.setAttribute("version","1.1");
                    this.elemPolyline.setAttribute("overflow","visible");
                    this.elemPolyline.setAttribute("viewBox","-"+this.maplet.width+" -"+this.maplet.height+" "+this.maplet.width*3+" "+this.maplet.height*3);
                    this.elemPolyline.setAttribute("style","position: absolute; left: -"+this.maplet.width+"px; top: -"+this.maplet.height+"px; z-index: 11;");
                    this.elemPolyline.setAttribute("height",this.maplet.height*3+"px");
                    this.elemPolyline.setAttribute("width",this.maplet.width*3+"px");
                }
                this.elemStroke=document.createElementNS("http://www.w3.org/2000/svg","path");
                this.elemStroke.setAttribute("id",this.id);
                this.elemStroke.setAttribute("MStrName",this.toString());
                this.elemStroke.setAttribute("stroke-linejoin","round");
                this.elemStroke.setAttribute("stroke-linecap","round");
                this.elemStroke.setAttribute("marker-end","");
                this.elemStroke.setAttribute("stroke",this.strokeColor);
                this.elemStroke.setAttribute("stroke-width",this.strokeWeight+"px");
                this.elemStroke.setAttribute("stroke-opacity",this.strokeOpacity/100);
                //this.elemStroke.setAttribute("style",:"");
                this.elemStroke.setAttribute("fill-opacity",this.strokeOpacity/100);
                this.elemStroke.setAttribute("fill","none");
                this.elemStroke.setAttribute("onmouseover",'this.style.cursor = "pointer"');
                this.elemStroke.setAttribute("onmousedown",'this.style.cursor = "move"');
          }
          this.elemPolyline.appendChild(this.elemStroke);
          this.elemDiv1.appendChild(this.elemPolyline);
        this.elemDiv1.style.visibility = "visible";
        if (this.maplet.layerDrawMap.objDiv != null)
        {
                this.maplet.layerDrawMap.objDiv.appendChild(this.elemDiv1)
        }
        this.S85();
}
function GSPolyline(pts, strokeColor, strokeWeight, strokeOpacity, info)
{
  this.id = new Date().getTime() + "" + parseInt(Math.random() * 10000) + "GSPolyline";
  this.pts = pts;
	this.wz = function(id)
	{
		this.id = id; 
	};
  this.strokeColor = (strokeColor == null) ? "#FF0000" : strokeColor;
  this.strokeWeight = (strokeWeight == null || strokeWeight == 0) ? 3 : strokeWeight;
  this.strokeOpacity = (strokeOpacity == null || strokeOpacity == 0) ? 60 : strokeOpacity;
  {
    this.info = null;
    if (typeof info != "undefined" && info)
    {
			this.info = info;
    }
  }
  this.qo = false;
  this.ls = false;
  this.Polylineflag = null;
  this.maplet = null;
  this.bEditable = false;
  this.ao = new Array();
  this.setEditable = function(cs)
  {
    this.bEditable = (typeof cs == "undefined") ? false : cs;
    if (this.maplet != null)
    {
			this.S85()
    }
  };
  this.qc = function(maplet)
  {
    this.maplet = maplet;
    this.ao["mouseover"] = GSEvent.addListener(this.maplet.holder, "mouseover", this, this.mouseoverfun);
    this.ao["mousedown"] = GSEvent.addListener(this.maplet.holder, "mousedown", this, this.mousedownfun);
    this.ao["mousemove"] = GSEvent.addListener(this.maplet.holder, "mousemove", this, this.mousemovefun);
    this.ao["mouseup"] = GSEvent.addListener(this.maplet.holder, "mouseup", this, this.mouseupfun);

    if (typeof this.maplet.holder != "undefined")
    {
			this.paint()
    }
  }
  this.paint = function()
  {
  	if(IE)
  	{
	    if (typeof this.elemDiv1 == "undefined")
	    {
	      this.elemDiv1 = document.createElement("div");
	      this.elemDiv1.unselectable = "on";
	      this.elemDiv1.style.zIndex = 10;
	      this.elemDiv1.style.position = "absolute";
	      this.elemDiv1.style.cursor = (IE) ? "hand" : "pointer";
	      this.elemPolyline = document.createElement("v:polyline");
	      this.elemPolyline.unselectable = "on";
	      this.elemPolyline.strokecolor = this.strokeColor;
	      this.elemPolyline.strokeweight = this.strokeWeight + 'pt';
	      this.elemPolyline.fill = "false";
	      this.elemPolyline.filled = "false";
	      this.elemStroke = document.createElement("v:stroke");
	      this.elemStroke.opacity = (this.strokeOpacity / 100);
	      this.elemStroke.joinstyle = "round";
	      this.elemStroke.endcap = "round";
	      this.elemStroke.fill = "false";
	      
	    }
	  }
	  else
	  {
	  	this.elemDiv1=document.getElementById("vCanvasSVG");
			this.elemPolyline=document.getElementById("LayerDrawSVG");
			if(this.elemDiv1==null)
			{
				this.elemDiv1=document.createElement("div");
				//this.elemDiv1.vb=this;
				this.elemDiv1.id="vCanvasSVG";
				this.elemDiv1.style.position="absolute";
				this.elemDiv1.unselectable="on";
				this.elemDiv1.style.zIndex=10;
				this.elemDiv1.style.MozUserSelect="none";
				this.elemPolyline=document.createElementNS("http://www.w3.org/2000/svg","svg");
				this.elemPolyline.setAttribute("id","LayerDrawSVG");
				this.elemPolyline.setAttribute("version","1.1");
				this.elemPolyline.setAttribute("overflow","visible");
				this.elemPolyline.setAttribute("viewBox","-"+this.maplet.width+" -"+this.maplet.height+" "+this.maplet.width*3+" "+this.maplet.height*3);
				this.elemPolyline.setAttribute("style","position: absolute; left: -"+this.maplet.width+"px; top: -"+this.maplet.height+"px; z-index: 11;");
				this.elemPolyline.setAttribute("height",this.maplet.height*3+"px");
				this.elemPolyline.setAttribute("width",this.maplet.width*3+"px");
			}
			this.elemStroke=document.createElementNS("http://www.w3.org/2000/svg","path");
			this.elemStroke.setAttribute("id",this.id);
			this.elemStroke.setAttribute("MStrName",this.toString());
			this.elemStroke.setAttribute("stroke-linejoin","round");
			this.elemStroke.setAttribute("stroke-linecap","round");
			this.elemStroke.setAttribute("marker-end","");
			this.elemStroke.setAttribute("stroke",this.strokeColor);
			this.elemStroke.setAttribute("stroke-width",this.strokeWeight+"px");
			this.elemStroke.setAttribute("stroke-opacity",this.strokeOpacity/100);
			//this.elemStroke.setAttribute("style",:"");
			this.elemStroke.setAttribute("fill-opacity",this.strokeOpacity/100);
			this.elemStroke.setAttribute("fill","none");
			this.elemStroke.setAttribute("onmouseover",'this.style.cursor = "pointer"');
			this.elemStroke.setAttribute("onmousedown",'this.style.cursor = "move"');
	  }
	  this.elemPolyline.appendChild(this.elemStroke);
	  this.elemDiv1.appendChild(this.elemPolyline);
    this.elemDiv1.style.visibility = "visible";
    if (this.maplet.layerDrawMap.objDiv != null)
    {
			this.maplet.layerDrawMap.objDiv.appendChild(this.elemDiv1)
    }
    this.S85();
  };
  this.S85 = function()
  {
    this.NodeLayer = document.getElementById(this.id + "vNodeLayer");
    if ((this.bEditable||this.maplet.bPolyline) && this.NodeLayer == null)
    {
      this.NodeLayer = document.createElement("div");
      this.NodeLayer.vb = this;
      this.NodeLayer.id = this.id + "vNodeLayer";
      this.NodeLayer.style.position = "absolute";
      this.NodeLayer.unselectable = "on";
      this.NodeLayer.style.zIndex = 1;
      this.NodeLayer.style.display = "none"
      this.NodeLayer.style.cursor = (IE) ? "hand" : "pointer";
      this.elemDiv1.appendChild(this.NodeLayer)
    }
    this.pu = new Array();
    this.xPointValue = new Array();
    this.yPointValue = new Array();
    var measCount = 0;
    if (this.pts == null || this.pts.length < 2)
			return;
    for (var i = 0; i < this.pts.length; i += 1)
    {
      this.pu[measCount] = i;
      if (this.pts[i].lat().toString() != eval("Number.NaN.toString()")&&this.pts[i].lat().toString() !=eval("Number.NaN.toString()"))
      {
	      var xy=this.maplet.LatlngToScreen(parseFloat(this.pts[i].lng()),parseFloat(this.pts[i].lat()));
				this.xPointValue[measCount] =xy.x();
				this.yPointValue[measCount] =xy.y()
			}
			else
				return
      if (measCount > 0 && (Math.abs(this.xPointValue[measCount] - this.xPointValue[measCount - 1]) + Math.abs(this.yPointValue[measCount] - this.yPointValue[measCount - 1])) > 10) {
				measCount++
      }
      if (measCount == 0)
				measCount++
    }
    var pointValue = '';
    var vw='';
    for (var i = 0; i < this.xPointValue.length; i++)
    {
			if (i > 0)
				pointValue += ',';
      pointValue += (parseInt(this.xPointValue[i]) + ',' + parseInt(this.yPointValue[i]))
      vw+=((i==0)?"M":"L")+parseInt(this.xPointValue[i])+","+parseInt(this.yPointValue[i]);
      if (this.NodeLayer && !this.maplet.bmeasure)
      {
        var sidenode = document.getElementById(this.id + "_node_" + this.pu[i]);
        if (sidenode == null)
        {
          sidenode = new Image();
          sidenode.id = this.id + "_node_" + this.pu[i];
          sidenode.num = i;
          sidenode.count = this.pu[i];
          sidenode.src = "images/toogo/node.gif";
          sidenode.unselectable = "on";
          sidenode.alt = "拖动以移动此点";
          sidenode.title = "拖动以移动此点";
          sidenode.style.position = "absolute";
          sidenode.style.filter = "alpha(opacity=100);";
          sidenode.style.MozOpacity = 1.0;
          sidenode.style.opacity = 1.0;
          sidenode.onmousedown = function()
          {
              return false
          };
				}
        sidenode.style.left = (parseInt(this.xPointValue[i]) - 5) + "px";
        sidenode.style.top = (parseInt(this.yPointValue[i]) - 5) + "px";
        this.NodeLayer.appendChild(sidenode);
        if (i > 0)
        {
          var midnode = document.getElementById(this.id + "_midnode_" + this.pu[i]);
          if (midnode == null)
          {
            midnode = new Image();
            midnode.id = this.id + "_midnode_" + this.pu[i];
            midnode.num = i;
            midnode.count = this.pu[i];
            midnode.unselectable = "on";
            midnode.src = "images/toogo/node.gif";
            midnode.alt = "拖动以移动此点";
            midnode.title = "拖动以移动此点";
            midnode.style.position = "absolute";
            midnode.style.filter = "alpha(opacity=60);";
            midnode.style.MozOpacity = 0.6;
            midnode.style.opacity = 0.6;
            midnode.onmousedown = function() { return false };
          }
          midnode.style.left = ((parseInt(this.xPointValue[i]) + parseInt(this.xPointValue[i - 1])) / 2 - 5) + "px";
          midnode.style.top = ((parseInt(this.yPointValue[i]) + parseInt(this.yPointValue[i - 1])) / 2 - 5) + "px";
          this.NodeLayer.appendChild(midnode)
        }
      }
    }
    if (this.elemPolyline.points)
    {
			this.elemPolyline.points.value = pointValue
    }
    else if(IE)
  	{
      this.elemPolyline.points = pointValue
    }
    else
    {
    	this.elemStroke.setAttribute("d",vw)
    	//alert("adsf")
    }
  };
	
	this.setStyle=function(style)
	{
		if(this.elemDiv1)
		{
			this.elemDiv1.style.zIndex=style
		}
	};
  this.setStrokeColor = function(color)
  {
    if (typeof this.elemDiv1 != "undefined")
    {
      this.strokeColor = color;
      this.elemPolyline.strokecolor = this.strokeColor
    }
    else
			this.strokeColor = color
  };
  this.getStrokeColor = function()
  {
    if (this.strokeColor != "")
			return this.strokeColor
  };
  this.setStrokeWeight = function(weight)
  {
    if (typeof this.elemDiv1 != "undefined")
    {
      this.strokeWeight = weight;
      this.elemPolyline.strokeweight = this.strokeWeight
    }
    else
			this.strokeWeight = weight
  };
  this.getStrokeWeight = function()
  {
    if (this.strokeWeight != "")
			return this.strokeWeight
  };
  this.setStrokeOpacity = function(opacity)
  {
    if (typeof this.elemDiv1 != "undefined")
    {
      this.strokeOpacity = opacity;
      this.elemStroke.opacity = this.strokeOpacity
    }
    else
			this.strokeOpacity = opacity
  };
  this.getStrokeOpacity = function()
  {
    if (this.strokeOpacity != "")
			return this.strokeOpacity
  };
  this.hide = function()
  {
    if (this.elemDiv1)
			this.elemDiv1.style.display = "none"
  };
  this.show = function()
  {
    if (this.elemDiv1)
			this.elemDiv1.style.display = "block"
  };
  this.remove = function()
  {
    if (typeof this.elemDiv1 != "undefined" && this.elemDiv1.parentNode)
    {
      this.elemDiv1.parentNode.removeChild(this.elemDiv1);
      this.elemDiv1 = null
    }
    for (var eventname in this.ao)
    {
      GSEvent.removeListener(this.maplet.holder, eventname, this.ao[eventname]);
      this.ao[eventname] = null
    }
  };
  this.openInfoWindow = function(content)
  {
    this.info = content
		markerinfo = this.info;
		this.maplet.moveTo(this.pts[this.pts.length - 1]);
		visible();
  };
  this.bdisplaynode = function(bflag)
  {
    if (this.NodeLayer != null)
    {
      if (bflag)
      {
        this.NodeLayer.style.display = "block";
        this.NodeLayer.style.zIndex = 10
      }
      else
    	{
        this.NodeLayer.style.display = "none";
        this.NodeLayer.style.zIndex = 0
      }
    }
  };
  this.mouseoverfun = function(EVT)
  {
    if (this.maplet)
    {
      if (this.bEditable || this.maplet.bEditline)
      {
        if (this.ls || this.elemDiv1 != null && this.maplet && fJ(EVT.target, this.elemDiv1) || fJ(EVT.target, this.NodeLayer))
        {
          if (IE)
          {
						this.elemStroke.opacity = ((this.strokeOpacity <= 20) ? this.strokeOpacity : this.strokeOpacity - 20) / 100
          }
          this.bdisplaynode(true)
        }
        else
      	{
          if (IE)
          {
						this.elemStroke.opacity = this.strokeOpacity / 100
          }
          this.bdisplaynode(false)
        }
      }
    }
  };
  this.mousedownfun = function(EVT)
  {
    if (this.elemDiv1 != null && (this.bEditable || this.maplet.bEditline) && this.maplet && fJ(EVT.target, this.elemDiv1) && EVT.button == 1 && EVT.target.id.indexOf("node") != -1)
    {
      this.qo = true;
      this.l0 = IE?EVT.offsetX:EVT.layerX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
      this.na = IE?EVT.offsetX:EVT.layerX+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
      nodeflag = EVT.target;
      if(IE)
      {
	      if (this.Polylineflag == null)
	      {
	        this.Polylineflag = document.createElement("v:polyline");
	        this.Polylineflag.unselectable = "on";
	        this.Polylineflag.id = this.id;
	        this.Polylineflag.strokecolor = this.strokeColor;
	        this.Polylineflag.strokeweight = this.strokeWeight + 'px';
	        this.Polylineflag.fill = "false";
	        this.Polylineflag.filled = "false";
	        this.Polylineflag.style.position = "absolute";
	        this.Strokeflag = document.createElement("v:stroke");
	        this.Strokeflag.opacity = this.strokeOpacity / 100;
	        this.Strokeflag.joinstyle = "round";
	        this.Strokeflag.endcap = "round";
	        this.Strokeflag.fill = "false";
	      }
	    }
	    else
	    {
	    	if(this.Polylineflag == null)
	    	{ 
	    		this.Polylineflag=document.createElementNS("http://www.w3.org/2000/svg","svg");
					this.Polylineflag.setAttribute("id",this.id);
					this.Polylineflag.setAttribute("version","1.1");
					this.Polylineflag.setAttribute("overflow","visible");
					this.Polylineflag.setAttribute("viewBox","-"+this.maplet.width+" -"+this.maplet.height+" "+this.maplet.width*3+" "+this.maplet.height*3);
					this.Polylineflag.setAttribute("style","position: absolute; left: -"+this.maplet.width+"px; top: -"+this.maplet.height+"px; z-index: 11;");
					this.Polylineflag.setAttribute("height",this.maplet.height*3+"px");
					this.Polylineflag.setAttribute("width",this.maplet.width*3+"px");
					this.Strokeflag=document.createElementNS("http://www.w3.org/2000/svg","path");
					this.Strokeflag.setAttribute("MStrName",this.toString());
					this.Strokeflag.setAttribute("stroke-linejoin","round");
					this.Strokeflag.setAttribute("stroke-linecap","round");
					this.Strokeflag.setAttribute("marker-end","");
					this.Strokeflag.setAttribute("stroke",this.strokeColor);
					this.Strokeflag.setAttribute("stroke-width",this.strokeWeight+"px");
					this.Strokeflag.setAttribute("stroke-opacity",this.strokeOpacity/100);
					//this.elemStroke.setAttribute("style",:"");
					this.Strokeflag.setAttribute("fill-opacity",this.strokeOpacity/100);
					this.Strokeflag.setAttribute("fill","none");
	    	}
	    }
      this.Polylineflag.appendChild(this.Strokeflag);
      this.elemDiv1.appendChild(this.Polylineflag)
  	}
    else if (this.elemDiv1 != null && !(this.bEditable || this.maplet.bPolyline) && this.maplet && fJ(EVT.target, this.elemDiv1) && EVT.button == 1)
    { }
  };
  this.mousemovefun = function(EVT)
  {
    if (nodeflag != null && (this.bEditable || this.maplet.bEditline) && this.qo && nodeflag.id.indexOf("node") > 0)
    {
      if (nodeflag != null)
      {
        var x = EVT.clientX - this.l0 - this.maplet.left+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
        var y = EVT.clientY - this.na - this.maplet.top+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
        nodeflag.style.left = (parseInt(x)) + "px";
        nodeflag.style.top = (parseInt(y)) + "px";
        this.ls = true;
        var ps = parseInt(nodeflag.num);
        var Points = new String(IE ? "" : "M");
        if (nodeflag.id.indexOf("_midnode_") > 0)
        {
          Points += parseInt(this.xPointValue[ps - 1]) + ',' + parseInt(this.yPointValue[ps - 1]);
          Points += ',' + (x + 5) + ',' + (y + 5);
          Points += ',' + parseInt(this.xPointValue[ps]) + ',' + parseInt(this.yPointValue[ps])
        }
        else
      	{
          if (ps > 0)
          {
						Points += parseInt(this.xPointValue[ps - 1]) + ',' + parseInt(this.yPointValue[ps - 1]) + ','
          }
          Points += (x + 5) + ',' + (y + 5);
          if (ps < this.xPointValue.length - 1)
         	{
						Points += ',' + parseInt(this.xPointValue[ps + 1]) + ',' + parseInt(this.yPointValue[ps + 1])
          }
        }
        if (this.Polylineflag != null)
        {
          if (this.Polylineflag.points)
          {
						this.Polylineflag.points.value = Points
          }
          else
        	{
            this.Polylineflag.value = Points
          }
        }
      }
    }
  };
  this.mouseupfun = function(EVT)
  {
    if (this.elemDiv1 != null && (this.bEditable || this.maplet.bEditline) && this.maplet && this.qo)
    {
      if (nodeflag != null)
      {
        var x = EVT.clientX - this.l0+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
        var y = EVT.clientY - this.na+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
        var ps = parseInt(nodeflag.count);
        var ud=this.maplet.ScreenToLatlng(x + 5-this.maplet.left,y + 5-this.maplet.top);
        if (nodeflag.id.indexOf("_midnode_") > 0) {
					this.pts.splice(ps, 0, ud)
        }
        else
      	{
          this.pts.splice(ps, 1, ud)
        }
      }
      this.qo = false;
      if (this.ls)
      {
				this.ls = false
      }
      if (this.Polylineflag.parentNode != null)
      {
        this.Polylineflag.parentNode.removeChild(this.Polylineflag);
        this.Polylineflag = null
      }
      this.S85()
    }
  };
  this.removeNode = function(node)
  {
    if (typeof node != "undefined")
    {
      if (node.toString().indexOf(this.id) >= 0 && node.toString().lastIndexOf("_") >= 0)
      {
				node = node.toString().substring(node.toString().lastIndexOf("_") + 1)
      }
      node = parseInt(node);
      if (!isNaN(node) && node < this.pts.length)
      {
        this.pts.splice(node, 1);
        if (typeof this.NodeLayer != "undefined" && this.NodeLayer != null)
        {
          for (var uy in this.NodeLayer)
          {
            if (typeof uy == "object")
            {
							this.NodeLayer.removeChild(uy)
            }
          }
        }
        if (this.Polylineflag != null && this.Polylineflag.parentNode != null)
        {
          this.Polylineflag.parentNode.removeChild(this.Polylineflag);
          this.Polylineflag = null
        }
        this.maplet.refresh()
      }
    }
  };
  this.getLatLng = function()
  {
    x = this.pts.lng();
    y = this.pts.lat();
    return new GSLatLng(y, x);
  };
  this.enableDragging = function()
  {
		this.bEditable = true;
  };
  this.disableDragging = function()
  {
		this.bEditable = false;
  };
  this.draggable = function()
  {
    if (this.bEditable)
			return true;
    else
			return false;
  };
  this.toString = function()
  {
		return 'com.toogo.maplet.GSPolyline'
 	}
};
function GSRoundRect(pt,strokeColor, strokeWidth, strokeHeight, flag, fillColor,strokeOpacity,info)
{
    this.id = new Date().getTime() + "" + parseInt(Math.random() * 10000) + "GSRoundRect";
    this.pt = pt
    this.maplet = null;
    this.ao = new Array();
    this.info = null;
    if (typeof info != "undefined" && info)
    {
        this.info = info;
    }
	this.falg = (flag == true)? true:false;
    this.strokeColor = (strokeColor == null) ? "#FF0000" : strokeColor;
    this.fillColor = (fillColor == null) ? "#FF0000" : fillColor;
    this.strokeWidth = (strokeWidth == null || strokeWidth == 0) ? 10 : strokeWidth;
    this.strokeHeight = (strokeHeight == null || strokeHeight == 0) ? 10 : strokeHeight;
    this.inset="0pt,0pt,0pt,0pt";
    this.cursorStyle=(IE) ? "hand" : "pointer";
    this.setCursorStyle=function(cursorType)
    {
        if(typeof this.elemDiv1 != "undefined")
		{
			this.elemDiv1.style.cursor=cursorType;
		}
		else
		    this.cursorStyle=cursorType;
    }
    this.wz = function(id)
    {
        this.id = id; 
    };
    this.qc = function(maplet)
    {
        this.maplet = maplet;
        if (typeof this.maplet.holder != "undefined")
        {
		        this.paint();
        }
    };
    this.paint = function()
    {
	    this.xPointValue = 0;
        this.yPointValue = 0;   
        if (this.pt.lat().toString() != eval("Number.NaN.toString()")&&this.pt.lat().toString() !=eval("Number.NaN.toString()"))
        {
          var xy=this.maplet.LatlngToScreen(parseFloat(this.pt.lng()),parseFloat(this.pt.lat()));
		        this.xPointValue =xy.x();
		        this.yPointValue =xy.y();
	    }
        if (typeof this.elemDiv1 == "undefined")
        {
            this.elemDiv1 = document.createElement("div");
            this.elemDiv1.unselectable = "on";
            this.elemDiv1.style.zIndex = 15;          //wgf 10改为15
            this.elemDiv1.style.position = "absolute";
            this.elemDiv1.style.cursor = this.cursorStyle;
            //if(this.Filter!="")                        //wgf
            //    this.elemDiv1.style.filter = this.Filter;
            this.elemRoundRect = document.createElement("v:RoundRect");
            this.elemRoundRect.style.position = "absolute";
            this.elemRoundRect.unselectable = "on";
            //this.elemOval.fill = this.falg;
            //this.elemOval.strokecolor = this.strokeColor;
            this.elemRoundRect.style.width = this.strokeWidth;
            this.elemRoundRect.style.height = this.strokeHeight;
            //this.elemOval.filled = this.falg;
            if(this.falg)
                this.elemRoundRect.fillcolor = this.fillColor;
            
            this.elemTextBox= document.createElement("v:TextBox");
            this.elemTextBox.inset=this.inset;
            this.elemTextBox.style.position = "absolute";
            this.elemTextBox.innerHTML=this.info;
        }
        this.elemRoundRect.style.left = (this.xPointValue);
        this.elemRoundRect.style.top = (this.yPointValue-this.strokeHeight);
        this.elemRoundRect.appendChild(this.elemTextBox);
        this.elemDiv1.appendChild(this.elemRoundRect);
        this.elemDiv1.style.visibility = "visible";
        if (this.maplet.layerDrawMap.objDiv != null)
        {
		        this.maplet.layerDrawMap.objDiv.appendChild(this.elemDiv1)
        }
    };
    this.hide = function()
    {
        if (this.elemDiv1)
	        this.elemDiv1.style.display = "none";
    };
    this.show = function()
    {
        if (this.elemDiv1)
	        this.elemDiv1.style.display = "block";
    };
    this.remove = function()
    {
        for (var eventname in this.ao)
        {
            GSEvent.removeListener(this.maplet.holder, eventname, this.ao[eventname]);
            this.ao[eventname] = null;
        }
        if (typeof this.elemDiv1 != "undefined" && this.elemDiv1.parentNode)
        {
            this.elemDiv1.parentNode.removeChild(this.elemDiv1);
            this.elemDiv1 = null;
        }
    };
};

function GSOval(pt, strokeColor, strokeWidth, strokeHeight, flag, fillColor,strokeOpacity,info)
{
  this.id = new Date().getTime() + "" + parseInt(Math.random() * 10000) + "GSOval";
  this.pt = pt;
	this.wz = function(id)
	{
		this.id = id; 
	};
	this.falg = (flag == true)? true:false;
  this.strokeColor = (strokeColor == null) ? "#FF0000" : strokeColor;
  this.fillColor = (fillColor == null) ? "#FF0000" : fillColor;
  this.strokeWidth = (strokeWidth == null || strokeWidth == 0) ? 10 : strokeWidth;
  this.strokeHeight = (strokeHeight == null || strokeHeight == 0) ? 10 : strokeHeight;
  this.dashstyle="";                    //wgf
  this.Filter="";
  {
    this.info = null;
    if (typeof info != "undefined" && info)
    {
			this.info = info;
    }
  } 
  this.maplet = null;
  this.ao = new Array();
  this.qc = function(maplet)
  {
    this.maplet = maplet;
    if (typeof this.maplet.holder != "undefined")
    {
			this.paint()
    }
  }
  this.paint = function()
  {
		this.xPointValue = 0;
    this.yPointValue = 0;   
    if (this.pt.lat().toString() != eval("Number.NaN.toString()")&&this.pt.lat().toString() !=eval("Number.NaN.toString()"))
    {
      var xy=this.maplet.LatlngToScreen(parseFloat(this.pt.lng()),parseFloat(this.pt.lat()));
			this.xPointValue =xy.x();
			this.yPointValue =xy.y()
		}
    if (typeof this.elemDiv1 == "undefined")
    {
        this.elemDiv1 = document.createElement("div");
        this.elemDiv1.unselectable = "on";
        this.elemDiv1.style.zIndex = 15;          //wgf 10改为15
        this.elemDiv1.style.position = "absolute";
        this.elemDiv1.style.cursor = (IE) ? "hand" : "pointer";
        if(this.Filter!="")                        //wgf
            this.elemDiv1.style.filter = this.Filter;
        this.elemOval = document.createElement("v:Oval");
        this.elemOval.style.position = "absolute";
        this.elemOval.unselectable = "on";
        this.elemOval.fill = this.falg;
        this.elemOval.strokecolor = this.strokeColor;
        this.elemOval.style.width = this.strokeWidth;
        this.elemOval.style.height = this.strokeHeight;
        this.elemOval.filled = this.falg;
        if(this.falg)
        this.elemOval.fillcolor = this.fillColor;
        
        this.elemStroke = document.createElement("v:stroke");     //wgf
        //this.elemStroke.opacity = (this.strokeOpacity / 100);
        if(this.dashstyle!="")
            this.elemStroke.dashstyle=this.dashstyle;
    }
    this.elemOval.style.left = (this.xPointValue-this.strokeWidth/2);
    this.elemOval.style.top = (this.yPointValue-this.strokeHeight/2);
    this.elemOval.appendChild(this.elemStroke);
	this.elemDiv1.appendChild(this.elemOval);
    this.elemDiv1.style.visibility = "visible";
    if (this.maplet.layerDrawMap.objDiv != null)
    {
			this.maplet.layerDrawMap.objDiv.appendChild(this.elemDiv1)
    }
  };
  
	this.setStyle=function(style)
	{
		if(this.elemDiv1)
		{
			this.elemDiv1.style.zIndex=style;
		}
	};
    this.setStyleFilter=function(style)              //wgf
	{
		if(typeof this.elemDiv1 != "undefined")
		{
			this.elemDiv1.style.filter=style;
		}
		else
		    this.Filter=style;
	};
  this.setStrokeColor = function(color)
  {
    if (typeof this.elemDiv1 != "undefined")
    {
      this.strokeColor = color;
      this.elemOval.strokecolor = this.strokeColor;
    }
    else
			this.strokeColor = color;
  };
    this.setDashstyle = function(dashstyle)  //wgf
  {
    if (typeof this.elemDiv1 != "undefined")
    {
      this.dashstyle = dashstyle;
      this.elemStroke.dashstyle = this.dashstyle;
    }
    else
			this.strokeColor = color
  };

  this.getStrokeColor = function()
  {
    if (this.strokeColor != "")
			return this.strokeColor
  };
  this.setStrokeWidth = function(width)
  {
    if (typeof this.elemDiv1 != "undefined")
    {
      this.strokeWidth = width;
      this.elemOval.style.width = this.strokeWidth
      this.elemOval.style.left = (this.xPointValue-this.strokeWidth/2);
    }
    else
			this.strokeWidth = width
  };
  this.getStrokeWidth = function()
  {
    if (this.strokeWidth != "")
			return this.strokeWidth
  };
  this.setStrokeHeight = function(height)
  {
    if (typeof this.elemDiv1 != "undefined")
    {
      this.strokeHeight = height;
      this.elemOval.style.height = this.strokeHeight
      this.elemOval.style.top = (this.yPointValue-this.strokeHeight/2);
    }
    else
			this.strokeHeight = height
  };
  this.getStrokeHeight = function()
  {
    if (this.strokeHeight != "")
			return this.strokeHeight
  };
  this.hide = function()
  {
    if (this.elemDiv1)
			this.elemDiv1.style.display = "none"
  };
  this.show = function()
  {
    if (this.elemDiv1)
			this.elemDiv1.style.display = "block"
  };
  this.remove = function()
  {
    if (typeof this.elemDiv1 != "undefined" && this.elemDiv1.parentNode)
    {
      this.elemDiv1.parentNode.removeChild(this.elemDiv1);
      this.elemDiv1 = null
    }
    for (var eventname in this.ao)
    {
      GSEvent.removeListener(this.maplet.holder, eventname, this.ao[eventname]);
      this.ao[eventname] = null
    }
  };
  this.openInfoWindow = function(content)
  {
    this.info = content
		markerinfo = this.info;
		this.maplet.moveTo(this.pt);
		visible();
  };
  this.StormForecastPoints_mouseover=function(){    //台风预报点鼠标移入事件
        var forecastIndex;
        var stationIndex;
        var tempArr;
	    var arrForecast;
	    var x1;
	    var y1;
	    var forecast_station=window.alternation.forecast_station;
	    var divForecastLable=document.getElementById("divForecastLable");
	    var divForecast=document.getElementById("divForecast");
	    tempArr=this.id.split('_');
	    if(typeof  tempArr[1]!="undifined"&& tempArr[1]!="")
	    {
	         stationIndex=parseInt(tempArr[1]);
	         arrForecast=window.alternation.searchForecast(forecast_station[stationIndex]);
	    }
	    if(typeof  tempArr[2]!="undifined"&& tempArr[2]!="")
	    {
	         forecastIndex=parseInt(tempArr[2]);
	         if(typeof  arrForecast!="undifined" && arrForecast!=null)
	         {
	 	         x1=map.LatlngToScreen(arrForecast[forecastIndex][1],arrForecast[forecastIndex][2]).x();
	             y1=map.LatlngToScreen(arrForecast[forecastIndex][1],arrForecast[forecastIndex][2]).y();	         
	         }

	    }

        create_divForecastLable();    // 创建台风预报标签
	    if(typeof forecastIndex!="undifined"&&typeof  arrForecast!="undifined"&&divForecast){
    		
		    window.label_forecast_value1.innerText = forecast_station[stationIndex]+"预报";
		    //alert(arrForecast)
		    //try{alert(arrForecast[forecastIndex][0])}catch(e){alert(e)}
		    window.label_forecast_value2.innerText = "时间:"+arrForecast[forecastIndex][0];
		    window.label_forecast_value3.innerText = "经度:"+arrForecast[forecastIndex][1]+"　　纬度:"+arrForecast[forecastIndex][2];
		    window.label_forecast_value4.innerText = "地点:"+arrForecast[forecastIndex][3];
    		
		    var labelWidth = window.label_forecast_table.clientWidth;
		    var labelHeight =window.label_forecast_table.clientHeight;
		    window.label_forecast_bg.points.value="2,0 " + (labelWidth - 2).toString() + ",0 " + labelWidth.toString() + ",2 " + labelWidth.toString() + "," + (labelHeight - 2).toString() + " " + (labelWidth - 2).toString() + "," + labelHeight.toString() + " 2," + labelHeight.toString() + " 0," + (labelHeight-2).toString() + " 0,2";
		    if (x1+160 > mcx){
			    divForecast.style.left	= x1-151;
		    }else{
			    divForecast.style.left	= x1+4;
		    }
		    if (y1-90 < 0){
			    divForecast.style.top	= y1+8;
		    }else{
			    divForecast.style.top	= y1-98;
		    }
	    }
	    divForecast.style.visibility="visible";
	   // divForecastLable.style.visibility="visible";
	    
	    //alert("ok367")

    };
    this.StormForecastPoints_mouseout=function()
    {
        document.getElementById("divForecast").style.visibility="hidden";
    }
    
    this.StormPoints_mouseout=function()         //wgf
    {
        document.getElementById("mymarker").style.visibility="hidden";
        closeStormCircle();    //关闭风圈
    };
this.StormPoints_mouseover=function(){     //wgf
    var index=null;
    var tempArr;
    var pt=this.pt;
    var d=window.alternation.d;
    var absolutePoint=window.alternation.absolutePoint;
    var xy=this.maplet.LatlngToScreen(parseFloat(this.pt.lng()),parseFloat(this.pt.lat()));
	var x1 =xy.x();
	var y1=xy.y();
	var mymarker=document.getElementById("mymarker");
	tempArr=this.id.split('_');
	if(typeof  tempArr[1]!="undifined"&& tempArr[1]!="")
	{
	    index=parseInt(tempArr[1]);
	}
	if(index!=null){
	    if (index != absolutePoint) {					// 最后一个风圈在"底图"上已绘制
		    //drawStormCircle(index,x1,);
		    drawStormCircle(index);
	    }
	    markertagBox_typhoon();      //弹出的div框 wgf
	    if(d[index][3]!="")
	    {
		    var PicPath = (d[index][3].substr(0,10)).replace(/\-/g,"");
		    var PicTime = (d[index][3].substr(11,2)).replace(/\:/g,"");
		    var PT = "";
		    switch(PicTime)
		    {
			    case "08":
				    PT = "0800";
				    break;
			    case "09":
				    PT = "0900";
				    break;
			    case "10":
				    PT = "1000";
				    break;
			    case "11":
				    PT = "1100";
				    break;
			    case "12":
				    PT = "1200";
				    break;
			    case "13":
				    PT = "1300";
				    break;
			    case "14":
				    PT = "1400";
				    break;
			    case "15":
				    PT = "1500";
				    break;
			    case "16":
				    PT = "1600";
				    break;
			    case "17":
				    PT = "1700";
				    break;
			    case "18":
				    PT = "1800";
				    break;
			    case "19":
				    PT = "1900";
				    break;
			    case "20":
				    PT = "2000";
				    break;
			    case "21":
				    PT = "2100";
				    break;
			    case "22":
				    PT = "2200";
				    break;
			    case "23":
				    PT = "2300";
				    break;
			    case "00":
    				
				    PT = "0000";
				    break;
			    case "01":
    				
				    PT = "0100";
				    break;
			    case "02":
    				
				    PT = "0200";
				    break;
			    case "03":
    				
				    PT = "0300";
				    break;
			    case "04":
    				
				    PT = "0400";
				    break;
			    case "05":
    				
				    PT = "0500";
				    break;
			    case "06":
    				
				    PT = "0600";
				    break;
			    case "07":
    				
				    PT = "0700";
				    break;
		    }
    		
		    var PIC = "../../CloudDownload/FY2B2云图/"+PicPath+PT+".jpg";
		    var xml;
		    function Create()
		    {
			    if(window.ActiveXObject)
			    {
				    xml = new ActiveXObject("Microsoft.XMLHTTP");
			    }
			    else if(window.XMLHttpRequest)
			    {
				    xml = new XMLHttpRequest();
			    }
		    }
		    function SelectPic()
		    {
			    Create();
			    var url = "SelectPic1.asp?Pic="+PIC;
			    xml.open("GET",url,true);
			    xml.onreadystatechange = callback;
			    xml.send(null);
		    }
		    function callback()
		    {
			    if(xml.readystate == 4)
			    {
				    if(xml.status == 200)
				    {
					    var msg = xml.responseText;
					    window.labelvalue8.innerHTML = "<img id='ImgInit' src="+msg+" width=210' height='175' name='imgInit' />";
				    }
			    }
		    }
		    SelectPic();	
		    //mapWin.labelvalue8.innerHTML ="<img id='ImgInit' src="+PIC+" width=210' height='160' name='imgInit' />";
	    }
		    var mdbearing = "";
		    if(d[index][12]!="")
		    {
    			
			    for(p=1;p<=d[index][12].length;p++)
			    {
				    if(d[index][12].substring(p-1,p) == "e")
				    {
					    mdbearing = mdbearing+"东";
				    }
				    else if(d[index][12].substring(p-1,p) == "w")
				    {
					    mdbearing = mdbearing+"西";
				    }
				    else if(d[index][12].substring(p-1,p) == "s")
				    {
					    mdbearing = mdbearing+"南";
				    }
				    else if(d[index][12].substring(p-1,p) == "n")
				    {
					    mdbearing = mdbearing+"北";
				    }
				    else
				    {
					    mdbearing = d[index][12];
				    }
			    }
		    }
		    else
		    {
			    mdbearing = "--";
		    }
		    leng=mdbearing.length;
		    if (leng==3) {
			    if (mdbearing.substr(0,1)==mdbearing.substr(1,1)){
				    if (mdbearing.substr(0,1)=="北" || mdbearing.substr(0,1)=="南") {
					    mdbearing=mdbearing.substr(0,1)+"偏"+mdbearing.substr(2,1)+mdbearing.substr(1,1)
				    }else{
					    mdbearing=mdbearing.substr(0,1)+"偏"+mdbearing.substr(1,2)
				    }
			    }else{
				    mdbearing=mdbearing.substr(0,2)+"偏"+mdbearing.substr(2,1)
			    }
		    }
	    if(d[index][4]==""){d[index][4]="--";}
	    /*if(d[index][5]==""){d[index][5]="--";}
	    if(d[index][6]==""){d[index][6]="--";}
	    if(d[index][7]==""){d[index][7]="--";}
	    if(d[index][8]==""){d[index][8]="--";}
	    if(d[index][11]==""){d[index][11]="--";}*/

	    window.labelvalue1.innerText = "时间:"+d[index][3];				// 时刻
	    window.labelvalue2.innerText = "移动速度:"	+d[index][11]+"公里/时";
	    window.labelvalue3.innerText = "经度:"	+d[index][1];
	    window.labelvalue4.innerText = "移动方向:"	+mdbearing;
	    window.labelvalue5.innerText = "纬度:"+d[index][2];
	    window.labelvalue6.innerText = "中心气压:"	+d[index][6]+"百帕";
	    window.labelvalue7.innerText = "风速:"	+d[index][4]+"米/秒";
	    window.labelvalue9.innerText = "七级风圈半径:"	+d[index][7]+"公里";
	    window.labelvalue10.innerText = "风力:"+d[index][5]+"级";
	    window.labelvalue11.innerText = "十级风圈半径:"	+d[index][8]+"公里";
    	
    	
	    labelWidth = window.label_table.clientWidth;
	    labelHeight =window.label_table.clientHeight;
    	
	    if (x1+340 > mcx){
		    mymarker.style.left	= x1-244;
		    if (y1-315 < 0)
		    {
			    mymarker.style.top	= y1+4;		//左下
    			
    			
		    }else{
			    mymarker.style.top	= y1-334;		//左上
    			
		    }
    		
    		
	    }else{
		    mymarker.style.left	= x1+4;
		    if (y1-315 < 0){
			    mymarker.style.top	= y1+4;		//右下
    			
		    }
		    else{
			    mymarker.style.top	= y1-334;		//右上
    			
		    }
    		
	    }
	    mymarker.style.visibility="visible";
	    //window.divLabel.style.visibility="visible";
	    // 画风圈

	}
};
  this.getLatLng = function()
  {
    x = this.pt.lng();
    y = this.pt.lat();
    return new GSLatLng(y, x);
  };
  
  this.toString = function()
  {
		return 'com.toogo.maplet.GSOval'
 	}
};

function GSPolygon(pts, strokeColor, strokeWeight, strokeOpacity, fillColor, fillOpacity, info)
{
  this.id = new Date().getTime() + "" + parseInt(Math.random() * 10000) + "GSPolygon";
  this.pts = pts;
	this.wz = function(id)
	{
		this.id = id;
	};
  this.strokeColor = (strokeColor == null) ? "#FF0000" : strokeColor;
  this.strokeWeight = (strokeWeight == null || strokeWeight == 0) ? 2 : strokeWeight;
  this.strokeOpacity = (strokeOpacity == null || strokeOpacity == 0) ? 60 : strokeOpacity;
  this.fillColor = (fillColor == null) ? "blue" : fillColor;
  this.fillOpacity = (fillOpacity == null || fillOpacity == 0) ? 60 : fillOpacity;
  {
    this.info = null;
    if (typeof info != "undefined" && info)
    {
			this.info = info;
    }
  }
  this.qo = false;
  this.ls = false;
  this.Polylineflag = null;
  this.maplet = null;
  this.bEditable = false;
  this.ao = new Array();
  this.qc = function(maplet)
  {
    this.maplet = maplet;
    this.ao["mouseover"] = GSEvent.addListener(this.maplet.holder, "mouseover", this, this.mouseoverfun);
    this.ao["mousedown"] = GSEvent.addListener(this.maplet.holder, "mousedown", this, this.mousedownfun);
    this.ao["mousemove"] = GSEvent.addListener(this.maplet.holder, "mousemove", this, this.mousemovefun);
    this.ao["mouseup"] = GSEvent.addListener(this.maplet.holder, "mouseup", this, this.mouseupfun);
    if (typeof this.maplet.holder != "undefined")
    {
			this.paint()
    }
  }
  this.paint = function()
  {
    if (typeof this.elemDiv1 == "undefined")
    {
      this.elemDiv1 = document.createElement("div");
      this.elemDiv1.unselectable = "on";
      this.elemDiv1.style.zIndex = 10;
      this.elemDiv1.style.top = "0px";
      this.elemDiv1.style.left = "0px";
      this.elemDiv1.style.position = "absolute";
      this.elemDiv1.style.cursor = (IE) ? "hand" : "pointer";
      this.elemPolygon = document.createElement("v:shape");
      this.elemPolygon.unselectable = "on";
      this.elemPolygon.strokecolor = this.strokeColor;
      this.elemPolygon.strokeweight = this.strokeWeight + 'pt';
      this.elemPolygon.filled = "true";
      this.elemPolygon.style.width = 1;
      this.elemPolygon.style.height = 1;
      this.elemPolygon.style.top = "0px";
      this.elemPolygon.style.left = "0px";
      this.elemPolygon.style.position = "absolute";
      this.elemPolygon.coordsize = '1,1'
      this.elemStroke = document.createElement("v:stroke");
      this.elemStroke.opacity = (this.strokeOpacity / 100);
      this.elemStroke.joinstyle = "round";
      this.elemStroke.endcap = "round";
      this.elemStroke.fill = "false";
      this.elemPolygonfill = document.createElement("v:fill");
      this.elemPolygonfill.unselectable = "on";
      this.elemPolygonfill.color = this.fillColor;
      this.elemPolygonfill.opacity = (this.fillOpacity / 100);
      this.elemPolygonfill.style.cursor = (IE) ? "hand" : "pointer";
      this.elemPolygon.appendChild(this.elemStroke);
      this.elemPolygon.appendChild(this.elemPolygonfill);
      this.elemDiv1.appendChild(this.elemPolygon);
    }
    this.elemDiv1.style.visibility = "visible";
    if (this.maplet.layerDrawMap.objDiv != null)
    {
			this.maplet.layerDrawMap.objDiv.appendChild(this.elemDiv1)
    }
    this.S85();
  };
  this.S85 = function()
  {
    this.NodeLayer = document.getElementById(this.id + "vNodeLayer");
    if ((this.bEditable||this.maplet.bPolygon) && this.NodeLayer == null)
    {
      this.NodeLayer = document.createElement("div");
      this.NodeLayer.vb = this;
      this.NodeLayer.id = this.id + "vNodeLayer";
      this.NodeLayer.style.position = "absolute";
      this.NodeLayer.unselectable = "on";
      this.NodeLayer.style.zIndex = 1;
      this.NodeLayer.style.display = "none"
      this.NodeLayer.style.cursor = (IE) ? "hand" : "pointer";
      this.elemDiv1.appendChild(this.NodeLayer)
    }
    this.pu = new Array();
    this.xPointValue = new Array();
    this.yPointValue = new Array();
    var measCount = 0;
    if (this.pts == null || this.pts.length < 2)
			return;
    for (var i = 0; i < this.pts.length; i += 1)
    {
      this.pu[measCount] = i;
      if (this.pts[i].lng().toString() != Number.NaN.toString()&&this.pts[i].lat().toString() != Number.NaN.toString())
    	{
	      var xy=this.maplet.LatlngToScreen(parseFloat(this.pts[i].lng()),parseFloat(this.pts[i].lat()));
				this.xPointValue[measCount] =xy.x();
				this.yPointValue[measCount] =xy.y()
			}
			else
				return
      if (measCount > 0 && (Math.abs(this.xPointValue[measCount] - this.xPointValue[measCount - 1]) + Math.abs(this.yPointValue[measCount] - this.yPointValue[measCount - 1])) > 10) {
				measCount++
      }
      if (measCount == 0)
				measCount++
    }
    var pointValue = ''
    for (var i = 0; i < this.xPointValue.length; i++)
    {
      if (i > 1)
				pointValue += ','
      if (i == 0)
				pointValue += ('m' + parseInt(this.xPointValue[i]) + ',' + parseInt(this.yPointValue[i]) + 'l')
      else
				pointValue += (parseInt(this.xPointValue[i]) + ',' + parseInt(this.yPointValue[i]))
      if (this.NodeLayer && !this.maplet.bmeasure)
      {
        var sidenode = document.getElementById(this.id + "_node_" + this.pu[i]);
        if (sidenode == null)
        {
          sidenode = new Image();
          sidenode.id = this.id + "_node_" + this.pu[i];
          sidenode.num = i;
          sidenode.count = this.pu[i];
          sidenode.src = "images/toogo/node.gif";
          sidenode.unselectable = "on";
          sidenode.alt = "拖动以移动此点";
          sidenode.title = "拖动以移动此点";
          sidenode.style.position = "absolute";
          sidenode.style.filter = "alpha(opacity=100);";
          sidenode.style.MozOpacity = 1.0;
          sidenode.style.opacity = 1.0;
          sidenode.onmousedown = function()
          {
						return false
          };
        }
        sidenode.style.left = (parseInt(this.xPointValue[i]) - 5) + "px";
        sidenode.style.top = (parseInt(this.yPointValue[i]) - 5) + "px";
        this.NodeLayer.appendChild(sidenode);
        if (i > 0)
        {
          var midnode = document.getElementById(this.id + "_midnode_" + this.pu[i]);
          if (midnode == null)
          {
            midnode = new Image();
            midnode.id = this.id + "_midnode_" + this.pu[i];
            midnode.num = i;
            midnode.count = this.pu[i];
            midnode.unselectable = "on";
            midnode.src = "images/toogo/node.gif";
            midnode.alt = "拖动以移动此点";
            midnode.title = "拖动以移动此点";
            midnode.style.position = "absolute";
            midnode.style.filter = "alpha(opacity=60);";
            midnode.style.MozOpacity = 0.6;
            midnode.style.opacity = 0.6;
            midnode.onmousedown = function() { return false };
          }
          midnode.style.left = ((parseInt(this.xPointValue[i]) + parseInt(this.xPointValue[i - 1])) / 2 - 5) + "px";
          midnode.style.top = ((parseInt(this.yPointValue[i]) + parseInt(this.yPointValue[i - 1])) / 2 - 5) + "px";
          this.NodeLayer.appendChild(midnode)
        }
      }
    }
    if (this.elemPolygon.path)
    {
			this.elemPolygon.path.value = pointValue;
    }
    else
  	{
      this.elemPolygon.path = pointValue
    }
  };
  this.setStrokeColor = function(color)
  {
    if (typeof this.elemDiv1 != "undefined")
  	{
      this.strokeColor = color;
      this.elemPolygon.strokecolor = this.strokeColor
    }
    else
			this.strokeColor = color
  };
  this.getStrokeColor = function()
  {
    if (this.strokeColor != "")
			return this.strokeColor
};
  this.setStrokeWeight = function(weight)
  {
    if (typeof this.elemPolygon != "undefined")
    {
      this.strokeWeight = weight;
      this.elemPolygon.strokeweight = this.strokeWeight
    }
    else
			this.strokeWeight = weight
  };
  this.getStrokeWeight = function()
  {
    if (this.strokeWeight != "")
			return this.strokeWeight
  };
  this.setStrokeOpacity = function(opacity)
  {
    if (typeof this.elemStroke != "undefined")
    {
      this.strokeOpacity = opacity;
      this.elemStroke.opacity = this.strokeOpacity / 100
    }
    else
			this.strokeOpacity = opacity
  };
  this.getStrokeOpacity = function()
  {
    if (this.strokeOpacity != "")
			return this.strokeOpacity
  };
  this.setFillColor = function(color)
  {
    if (typeof this.elemPolygonfill != "undefined")
    {
      this.fillColor = color;
      this.elemPolygonfill.color = this.fillcolor
    }
    else
			this.fillcolor = color
  };
  this.getFillColor = function()
  {
    if (this.fillcolor != "")
			return this.fillcolor
  };
  this.setFillOpacity = function(opacity)
  {
    if (typeof this.elemPolygonfill != "undefined")
    {
      this.fillOpacity = opacity;
      this.elemPolygonfill.opacity = this.fillOpacity / 100
    }
    else
			this.fillOpacity = opacity
  };
  this.getFillOpacity = function()
  {
    if (this.fillOpacity != "")
			return this.fillOpacity
  };
  this.hide = function()
  {
    if (this.elemDiv1)
			this.elemDiv1.style.display = "none"
  };
  this.show = function()
  {
    if (this.elemDiv1)
			this.elemDiv1.style.display = "block"
  };
  this.remove = function()
  {
    if (typeof this.elemDiv1 != "undefined" && this.elemDiv1.parentNode)
    {
      this.elemDiv1.parentNode.removeChild(this.elemDiv1);
      this.elemDiv1 = null
    }

    for (var eventname in this.ao)
    {
      GSEvent.removeListener(this.maplet.holder, eventname, this.ao[eventname]);
      this.ao[eventname] = null
    }
  };
  this.openInfoWindow = function(content)
  {
    this.info = content
		markerinfo = this.info;
		this.maplet.moveTo(this.pts[this.pts.length - 1]);
		visible();
  };
  this.bdisplaynode = function(bflag)
  {
    if (this.NodeLayer != null)
    {
      if (bflag)
      {
        this.NodeLayer.style.display = "block";
        this.NodeLayer.style.zIndex = 10
      }
      else
    	{
        this.NodeLayer.style.display = "none";
        this.NodeLayer.style.zIndex = 0
      }
    }
  };
  this.mouseoverfun = function(EVT)
  {
    if (this.maplet)
    {
      if (this.bEditable || this.maplet.bEditgon)
      {
        if (this.ls || this.elemDiv1 != null && this.maplet && fJ(EVT.target, this.elemDiv1) || fJ(EVT.target, this.NodeLayer))
        {
          if (IE)
          {
						this.elemStroke.opacity = ((this.strokeOpacity <= 20) ? this.strokeOpacity : this.strokeOpacity - 20) / 100
          }
          this.bdisplaynode(true)
        }
        else
      	{
          if (IE)
          {
						this.elemStroke.opacity = this.strokeOpacity / 100
          }
          this.bdisplaynode(false)
        }
      }
    }
  };
  this.mousedownfun = function(EVT)
  {
    if (this.elemDiv1 != null && (this.bEditable || this.maplet.bEditgon) && this.maplet && fJ(EVT.target, this.elemDiv1) && EVT.button == 1 && EVT.target.id.indexOf("node") != -1)
    {
      this.qo = true;
      this.l0 = IE?EVT.offsetX:EVT.layerX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
      this.na = IE?EVT.offsetX:EVT.layerX+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
      nodeflag = EVT.target;
      if (this.Polylineflag == null)
      {
        this.Polylineflag = document.createElement("v:polyline");
        this.Polylineflag.unselectable = "on";
        this.Polylineflag.id = this.id;
        this.Polylineflag.strokecolor = this.strokeColor;
        this.Polylineflag.strokeweight = this.strokeWeight + 'px';
        this.Polylineflag.fill = "false";
        this.Polylineflag.filled = "false";
        this.Polylineflag.style.position = "absolute";
        this.Strokeflag = document.createElement("v:stroke");
        this.Strokeflag.opacity = this.strokeOpacity / 100;
        this.Strokeflag.joinstyle = "round";
        this.Strokeflag.endcap = "round";
        this.Strokeflag.fill = "false";
      }
      this.Polylineflag.appendChild(this.Strokeflag);
      this.elemDiv1.appendChild(this.Polylineflag)
    }
    else if (this.elemDiv1 != null && !(this.bEditable || this.maplet.bPolygon) && this.maplet && fJ(EVT.target, this.elemDiv1) && EVT.button == 1)
		{ }
  };
  this.mousemovefun = function(EVT)
  {
    if (nodeflag != null && (this.bEditable || this.maplet.bEditgon) && this.qo && nodeflag.id.indexOf("node") > 0)
    {
      if (nodeflag != null)
      {
        var x = EVT.clientX - this.l0 - this.maplet.left+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
        var y = EVT.clientY - this.na - this.maplet.top+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
        nodeflag.style.left = (parseInt(x)) + "px";
        nodeflag.style.top = (parseInt(y)) + "px";
        this.ls = true;
        var ps = parseInt(nodeflag.num);
        var Points = new String(IE ? "" : "M");
        if (nodeflag.id.indexOf("_midnode_") > 0)
        {
          Points += parseInt(this.xPointValue[ps - 1]) + ',' + parseInt(this.yPointValue[ps - 1]);
          Points += ',' + (x + 5) + ',' + (y + 5);
          Points += ',' + parseInt(this.xPointValue[ps]) + ',' + parseInt(this.yPointValue[ps])
        }
        else
      	{
          if (ps > 0)
          {
						Points += parseInt(this.xPointValue[ps - 1]) + ',' + parseInt(this.yPointValue[ps - 1]) + ','
          }
          Points += (x + 5) + ',' + (y + 5);
          if (ps < this.xPointValue.length - 1)
          {
						Points += ',' + parseInt(this.xPointValue[ps + 1]) + ',' + parseInt(this.yPointValue[ps + 1])
          }
        }
        if (this.Polylineflag != null)
        {
          if (this.Polylineflag.points)
          {
						this.Polylineflag.points.value = Points
          }
          else
        	{
            this.Polylineflag.value = Points
          }
        }
      }
    }
  };
  this.mouseupfun = function(EVT)
  {
    if (this.elemDiv1 != null && (this.bEditable || this.maplet.bEditgon) && this.maplet && this.qo)
    {
      if (nodeflag != null)
      {
        var x = EVT.clientX - this.l0+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
        var y = EVT.clientY - this.na+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);

        var ps = parseInt(nodeflag.count);
        var ud=this.maplet.ScreenToLatlng(x + 5-this.maplet.left,y + 5-this.maplet.top);
        if (nodeflag.id.indexOf("_midnode_") > 0)
        {
					this.pts.splice(ps, 0, ud)
        }
        else
      	{
          this.pts.splice(ps, 1, ud)
        }
      }
      this.qo = false;
      if (this.ls)
      {
				this.ls = false
      }
      if (this.Polylineflag.parentNode != null)
      {
        this.Polylineflag.parentNode.removeChild(this.Polylineflag);
        this.Polylineflag = null
      }
      this.S85()
    }
  };
  this.removeNode = function(node)
  {
    if (typeof node != "undefined")
    {
      if (node.toString().indexOf(this.id) >= 0 && node.toString().lastIndexOf("_") >= 0)
      {
				node = node.toString().substring(node.toString().lastIndexOf("_") + 1)
      }
      node = parseInt(node);
      if (!isNaN(node) && node < this.pts.length)
      {
        this.pts.splice(node, 1);
        if (typeof this.NodeLayer != "undefined" && this.NodeLayer != null)
        {
          for (var uy in this.NodeLayer)
          {
            if (typeof uy == "object")
            {
							this.NodeLayer.removeChild(uy)
            }
          }
        }
        if (this.Polylineflag != null && this.Polylineflag.parentNode != null)
        {
          this.Polylineflag.parentNode.removeChild(this.Polylineflag);
          this.Polylineflag = null
        }
        this.maplet.refresh()
      }
    }
  };
  this.getLatLng = function()
  {
    x = this.pts.lng();
    y = this.pts.lat();
    return new GSLatLng(y, x);
  };
  this.enableDragging = function()
  {
		this.bEditable = true;
  };
  this.disableDragging = function()
  {
		this.bEditable = false;
  };
  this.draggable = function()
  {
    if (this.bEditable)
			return true;
    else
			return false;
  };
  this.toString = function()
  {
		return 'com.toogo.maplet.GSPolygon'
  }
};

function GSLatLng(lat, lng)
{
  while (lng < -180)
		lng += 360
  while (lng > 180)
		lng -= 360
  while (lat < -90)
		lat += 180
  while (lat > 90)
		lat -= 180
  this.lat = function()
  {
		return lat;
  };
  this.lng = function()
  {
		return lng;
  }
  this.toString = function()
  {
		return 'toogo.GSLatLng'
  }
};

function GSPoint(x, y)
{
  this.y = function()
  {
		return y;
  };
  this.x = function()
  {
		return x;
  }
  this.toString = function()
  {
		return 'toogo.GSPoint'
  }
};

function GSMap(div)
{
  this.holder = div;        //地图的载体，即窗口层
  this.width = parseInt(this.holder.offsetWidth);
  this.height = parseInt(this.holder.offsetHeight);
  this.left = parseInt(this.holder.offsetLeft);
  this.top = parseInt(this.holder.offsetTop);
  this.holder.style.position = "absolute";
  this.holder.style.overflow = 'hidden';
  this.holder.style.background = "buttonface";
  this.dW = (dMaxX - dMinX) * dMeterPerUnit;
  this.dH = (dMaxY - dMinY) * dMeterPerUnit;
  this.mapsize = 0;
  this.Version = Version;
  this.Projection=Projection;
  this.BiggestZoom = BiggestZoom;
  this.LeastZoom = LeastZoom;
  this.LevelIgnore = LevelIgnore;
  this.xLoop = 0;
  this.yLoop = 0;
  this.xcenter = 0;         //实时中心点
  this.ycenter = 0;
  this.zoomLevel = 0;       //缩放等级
  this.xClick = 0; //鼠标点击时的x坐标
  this.yClick = 0;
  this.lonClick = 0;
  this.latClick = 0;
  this.downx = 0;
  this.downy = 0;
  this.movex = 0;
  this.movey = 0;
  this.lonMove = 0;
  this.latMove = 0;
  this.upx = 0;
  this.upy = 0;
  this.Polyline = null;
  this.linemove = null;
  this.Polygon = null;
  this.Point = null;
  this.Parallel = null;
  this.Sideway = null;
  this.u5 = [];
  this.gc = [];
  this.lines = [];
  this.gons = [];
  this.parallels = [];
  this.pots = [];
  this.sideways = [];
  this.overheadroad = [];
  this.bOverheadRoad=false;
  this.bEditOverheadRoad=false;
  this.bpoint = false;
  this.bEditpoint=false;
  this.bmeasure = false;
  this.bPanning = false;
  this.bPolyline = false;
  this.bEditline = false;
  this.bEditgon = false
  this.bPolygon = false;
  this.bParallel = false;
  this.bEditParallel = false;
  this.bSideway = false;
  this.bEditSideway = false;
  this.bmove = true;
  this.blogo = true;
  this.bscale = true;
  this.bmarker = true;
  this.bControl = true;
  this.bdbclick = true;
  this.bcontZoom = true;
  this.bwheel = true;
  this.bmousemove = false;
  this.bmousedown = false;
  this.bcenterflag = true;
  this.layerScale = '';
  this.controlBar = '';
  this.ovw = '';
  this.toolBar = '';
  this.layerDrawMap=null;
  if (this.width > 480)
  {
    owh = 140;
    oww = 210;
  }
  this.zoomnum = 0.2;
  this.bzoom = -1;
  this.Zoom = 0;
  this.offsetx = 0;
  this.offsety = 0;
};

GSMap.prototype =
{
  resize: function(width, height)
  {
    this.width = parseInt(width);
    this.height = parseInt(height);
    if(this.Projection == "baidu"||this.Projection == "Baidu"||this.Projection == "BaiDu"||this.Projection == "BAIDU")
			this.mapsize = 300
		else
			this.mapsiae = 256
    this.dW = (dMaxX - dMinX) * dMeterPerUnit;
    this.dH = (dMaxY - dMinY) * dMeterPerUnit;
    this.xLoop = Math.ceil((this.width) / (this.mapsize) / 2);
    this.yLoop = Math.ceil((this.height) / (this.mapsize) / 2);
    this.holder.style.width = this.width + "px";
    this.holder.style.height = this.height + "px";
    this.holder.style.clip = "rect(0px," + this.width + "px," + this.height + "px,0px)";   //wgf
    this.mapContainer.resize(this.width, this.height);
    this.layerMap.resize(this.width, this.height);
    if (this.layerScale)
    {
			this.layerScale.moveTo(10, this.height - 24);
    }
    this.sg = (this.width > 360) ? 85 : 58;
    if (this.blogo && this.ovw)
    {
      var ui = 0;
      if ((this.ovw.top() + this.ovw.height()) > (this.height - 23))
      {
				ui += Math.max(0, this.ovw.width() - (this.sg - 70))
      }
      this.layerLogo.resize(this.sg, this.layerLogo.height());
      this.layerLogo.moveTo(this.width - this.sg - ui, this.height - 23)
    }
    else
			this.layerLogo.moveTo(this.width - this.sg, this.height - 23)
    this.setZoom(this.zoomLevel);
    if (this.ovw)
			this.ovw.onresize()
  },
  onresize: function()
  {
    if (this.blogo)
    {
      var ui = 0;
      this.sg = (this.width <= 360) ? 85 : 58;
      if ((this.ovw.height() + this.ovw.top()) > (this.height - 23))
      {
				ui += Math.max(0, this.ovw.width() - (this.sg - 70))
      }
      this.layerLogo.resize(this.sg, this.layerLogo.height());
      this.layerLogo.moveTo(this.width - this.sg - ui, this.height - 23)
    }
  },

  getCenter: function()
  {
    while (this.xcenter < -180)
			this.xcenter += 360
    while (this.xcenter > 180)
			this.xcenter -= 360
    while (this.ycenter < -90)
			this.ycenter += 180
    while (this.ycenter > 90)
			this.ycenter -= 180
    return new GSLatLng(this.ycenter, this.xcenter);
  },
  setCenter: function(LatLng, zoom)
  {
    var latlng = LatLng
    this.xcenter = parseFloat(latlng.lng());
    this.ycenter = parseFloat(latlng.lat());
   
    this.zoomLevel = parseFloat(zoom);
    if (this.bcenterflag)
    {
      this.initmap();
      this.bcenterflag = false;
    }
    this.setZoom(this.zoomLevel)
  },
  initmap: function()
  {
    this.mapContainer = new Div("MapContainer", 0, 0, this.width, this.height, true, 2, '', this.holder);
    this.layerMap = new Div("LayerMap", 0, 0, this.width, this.height, true, 2, '地图装载中...', this.mapContainer);
    this.sg = (this.width > 360) ? 85 : 58;

    this.layerLogo = new Div("LayerLogo", this.width - this.sg, this.height - 24, 50, 23, this.blogo, 3, '', this.holder);
    this.layerLogo.style.cursor = 'hand'
    if (this.ovw)
			this.onresize();
    this.layerDrawMap = new Div("LayerDrawMap", 0, 0, this.width, this.height, true, 4, '', this.mapContainer);
		onmousewheel(this.holder);
    GSEvent.addListener(this.holder, "mousedown", this, this.mousedownFun);
    GSEvent.addListener(this.holder, "mousemove", this, this.mousemoveFun);
    GSEvent.addListener(this.holder, "mouseup", this, this.mouseupFun);
    GSEvent.addListener(this.holder, "click", this, this.clickFun);
    GSEvent.addListener(this.holder, "dblclick", this, this.dblclickFun);
    GSEvent.addListener(this.holder, "mousewheel", this, this.mousewheelFun);
    GSEvent.addListener(this.holder, "drag", this, this.mousemoveFun);
    GSEvent.addListener(this.holder, "dragstart", this, this.mousemoveFun);
    GSEvent.addListener(this.holder, "dragend", this, this.mousemoveFun);
  },

  getZoom: function()
  {
		return this.zoomLevel;
  },
  setZoom: function(zoom)
  {
    if (zoom < this.LeastZoom || zoom > this.BiggestZoom)
			return;
    if (this.zoomLevel != zoom)
			this.zoomLevel = zoom;
    var barzoom = this.zoomLevel;
    for (i = this.LevelIgnore.length; i > 0; i--)
    {
      if (this.zoomLevel > this.LevelIgnore[i - 1])
      {
				barzoom = barzoom - 1;
      }
    }
    if (this.controlBar)
			this.controlBar.S85(barzoom)
    this.refresh();
  },
  refresh: function()
  {
    this.showMap(); //更新地图主窗口
    this.updateOthers()//更新窗口上别的
  },
  showMap: function()
  {
  	this.mapContainer.moveTo(0, 0);
    this.mapContainer.objDiv.style.zoom = 1;
    this.layerMap.moveTo(0, 0);
    this.layerMap.show();
    this.layerMap.objDiv.innerHTML = '';
    clearOnerror();
    var innerHtmlImg='';
    if(this.Projection == "toogo"||this.Projection == "Toogo"||this.Projection == "TooGo"||this.Projection == "TOOGO")
    {
    	innerHtmlImg=this.toogo(this.width,this.height,this.zoomLevel,"toogomapinfo")
    }
    else if(this.Projection == "google"||this.Projection == "Google"||this.Projection == "GooGle"||this.Projection == "GOOGLE")
    {
    	innerHtmlImg=this.google(this.width,this.height,this.zoomLevel,"toogomapinfo")
    }
    else if(this.Projection == "Yahoo"||this.Projection == "YaHoo"||this.Projection == "yahoo"||this.Projection == "YAHOO")
    {
    	innerHtmlImg=this.yahoo(this.width,this.height,this.zoomLevel,"toogomapinfo")
    }
    else if(this.Projection == "Sogou"||this.Projection == "SoGou"||this.Projection == "sogou"||this.Projection == "SOGOU")
    {
    	innerHtmlImg=this.sogou(this.width,this.height,this.zoomLevel,"toogomapinfo")
    }
    else if(this.Projection == "bing")
    {
    	innerHtmlImg=this.bing(this.width,this.height,this.zoomLevel,"toogomapinfo")
    }
    else if(this.Projection == "51ditu"||this.Projection == "51DiTu"||this.Projection == "51Ditu"||this.Projection == "51DITU")
    {
    	this.mapsize=200;
    	var zoom=17-parseInt(this.zoomLevel);
    	if(zoom>14)
    		zoom=14
    	this.zoomUnits=Math.pow(2,(17-this.zoomLevel))*256/this.mapsize;
    	innerHtmlImg=this.ditu51(this.width,this.height,this.zoomLevel,"toogomapinfo")
    }
    else if(this.Projection == "baidu"||this.Projection == "Baidu"||this.Projection == "BaiDu"||this.Projection == "BAIDU")
    {
    	this.longStep=longStepArr[this.zoomLevel];
			this.latStep=latStepArr[this.zoomLevel];
    	innerHtmlImg=this.baidu(this.width,this.height,this.zoomLevel,"toogomapinfo")
    }
    while (this.xcenter < -180)
			this.xcenter += 360
    while (this.xcenter > 180)
			this.xcenter -= 360
    this.layerMap.objDiv.innerHTML = innerHtmlImg;
    innerHtmlImg = null;
    if (this.layerMap.objDiv.parentNode != this.mapContainer.objDiv)
    {
			this.mapContainer.objDiv.appendChild(this.layerMap.objDiv);
    }
    if (this.ovw)
			this.ovw.paint();
    for (var qi in this.u5)
    {
      if (this.u5[qi] && this.u5[qi].paint)
      {
				this.u5[qi].paint()
      }
    }
  },
	toogo:function(width,height,zoom,mapid)
	{
    var innerHtmlImg = '';
    this.mapsize = 256;
    this.xLoop = Math.ceil((width) / (this.mapsize) / 2);
  	this.yLoop = Math.ceil((height) / (this.mapsize) / 2);
    this.nTotMN = Math.floor(Math.pow(2, zoom) / 2);
    var nOriX, nOriY;
    nOriX = Math.round(width / 2 - Math.round(this.xcenter * (this.mapsize * Math.pow(2, zoom) / earth) % this.mapsize));
    nOriY = Math.round(height / 2 - this.mapsize + Math.round(this.ycenter * (this.mapsize * Math.pow(2, zoom) / earth) % this.mapsize));
    if (zoom == 0)//第０层只有一块，０，０在中心
    {
      nOriX -= this.mapsize / 2;
      nOriY += this.mapsize / 2;
    }
    var mapUrl = strImgurl + this.Version;
		if (this.xcenter >= 0)
			var x = Math.floor(this.xcenter / (earth / Math.pow(2, zoom)));
		else
			var x = Math.floor(this.xcenter / (earth / Math.pow(2, zoom))) + 1;
		if (this.ycenter >= 0)
			var y = Math.floor(this.ycenter / (earth / Math.pow(2, zoom)));
		else
			var y = Math.floor(this.ycenter / (earth / Math.pow(2, zoom))) + 1;
    for (xCount = -this.xLoop - 1; xCount <= this.xLoop + 1; xCount++)
    {
      for (yCount = -this.yLoop - 1; yCount <= this.yLoop + 1; yCount++)
      {    
        if (y >= -this.nTotMN && y < this.nTotMN || this.nTotMN == 0 && y == 0)
        {
          var m = x + xCount;
          var n = y + yCount;
          if (this.nTotMN > 0)
          {
            if (m < -this.nTotMN)//东西方向循环
							m = this.nTotMN - (this.nTotMN - m) % (2 * this.nTotMN);
            if (m >= this.nTotMN)
							m = (m + this.nTotMN) % (2 * this.nTotMN) - this.nTotMN;
          }
          else
        	{
            m = 0;
          }
          var imgLeft = Math.round(nOriX + xCount * this.mapsize);
          var imgTop = Math.round(nOriY + (-yCount * this.mapsize));
          if (imgLeft < -this.mapsize || imgLeft > width || imgTop > height || imgTop < -this.mapsize)
						continue;
          if ((zoom == 0 && (n > this.nTotMN || n < -this.nTotMN))||(zoom == 1 && (n > this.nTotMN / 2 || n < -this.nTotMN / 2 - 1))||(zoom > 1 && (n > this.nTotMN / 2 - 1 || n < -this.nTotMN / 2)))
						continue;
          mURL =mapUrl+"&d=" + zoom + "&m=" + m + "&n=" + n;
          var imginfo = ((x).toString(16) + ',' + (y).toString(16) + ',' + (zoom).toString(16)).toLowerCase();
          if (mURL && mapUrl.indexOf("NaN") < 0)
          {
						innerHtmlImg += '<img id="'+mapid + imginfo + '" name=' + imginfo + ' src="' + mURL + '" ntry="0" unselectable=on onerror="javascript:imageTileError(this);" style="position:absolute;top:' + imgTop + 'px;left:' + imgLeft + 'px;">'
          }
					mURL = null
        }
      }
    }
		return innerHtmlImg
	},
	
	google:function(width,height,zoom,mapid)
	{
    var innerHtmlImg = '';
    this.mapsize = 256;
    this.xLoop = Math.ceil((width) / (this.mapsize) / 2);
  	this.yLoop = Math.ceil((height) / (this.mapsize) / 2);
    this.nTotMN = Math.floor(Math.pow(2, zoom));
    var nOriX, nOriY;
    var yx = this.LatlngToEarth(this.xcenter, this.ycenter);
    if(this.xcenter>=0)
    	nOriX = Math.round(width / 2 - Math.round(yx.x() * (this.mapsize * Math.pow(2, zoom) / dEarthLength) % this.mapsize));
    else
    	nOriX = Math.round(width / 2-this.mapsize - Math.round(yx.x() * (this.mapsize * Math.pow(2, zoom) / dEarthLength) % this.mapsize));
    if(this.ycenter>0)
    	nOriY = Math.round(height / 2-this.mapsize + Math.round(yx.y() * (this.mapsize * Math.pow(2, zoom) / dEarthLength) % this.mapsize));
    else
    	nOriY = Math.round(height / 2 + Math.round(yx.y() * (this.mapsize * Math.pow(2, zoom) / dEarthLength) % this.mapsize));
    if (zoom == 0)//第０层只有一块，０，０在中心
    {
      nOriX -= this.mapsize / 2;
      if(this.ycenter>0)
      	nOriY += this.mapsize / 2
      else
      	nOriY -= this.mapsize / 2
    }
		
		var mn=this.latlngToXYZoom(this.xcenter,this.ycenter,zoom);
		var m=mn.x();
		var n=mn.y();
    for (xCount = -this.xLoop - 1; xCount <= this.xLoop + 1; xCount++)
    {
      for (yCount = -this.yLoop - 1; yCount <= this.yLoop + 1; yCount++)
      {
      	if(this.Version=="0014")
      	{
      		var mapUrl = 'http://khm0.google.com/kh/v=45';
      		var mapUrl1 ='http://mt.google.cn/vt/v=w2t.107&hl=zh-CN'
      	}
      	else if(this.Version=="0018")
      		var mapUrl = 'http://mt.google.com/mt/v=cnw2p.98&hl=zh-CN&gl=cn'
      	else
      		var mapUrl = 'http://mt.google.cn/vt/v=w2.107&hl=zh-CN&gl=cn'
				var x = m + xCount;
        var y = n + yCount;
        if (this.nTotMN > 1)
        {
          if (x < 0)//东西方向循环
						x = this.nTotMN+x;
          if (x >= this.nTotMN)
						x = (x + this.nTotMN) % (2 * this.nTotMN);
        }
        else
      	{
          x = 0;
        }
        var imgLeft = Math.round(nOriX + xCount * this.mapsize);
        var imgTop = Math.round(nOriY + (yCount * this.mapsize));
        if (imgLeft < -this.mapsize || imgLeft > width || imgTop > height || imgTop < -this.mapsize)
					continue;
				if (y > this.nTotMN-1 || y < 0)
					continue;  
        mapUrl +=  "&x=" + x + "&y=" + y + "&z=" + zoom;
        if(this.Version=="0014")
        	mapUrl1 +=  "&x=" + x + "&y=" + y + "&z=" + zoom;
        var imginfo = ((x).toString(16) + ',' + (y).toString(16) + ',' + (zoom).toString(16)).toLowerCase();
        if (mapUrl && mapUrl.indexOf("NaN") < 0)
        {
					innerHtmlImg += '<img id="'+mapid+ imginfo + '" name=' + imginfo + ' src="' + mapUrl + '" ntry="0" unselectable=on onerror="javascript:imageTileError(this);" style="position:absolute;top:' + imgTop + 'px;left:' + imgLeft + 'px;">'
					if(this.Version=="0014")
						innerHtmlImg += '<img id="'+mapid+ imginfo + '" name=' + imginfo + ' src="' + mapUrl1 + '" ntry="0" unselectable=on onerror="javascript:imageTileError(this);" style="position:absolute;top:' + imgTop + 'px;left:' + imgLeft + 'px;">'
        }
        mapUrl = null;
      }
    }
    return innerHtmlImg
	},
	latlngToXYZoom:function(lng, lat,zoom)
  {
		var x = (180.000000 + lng) / 360.000000;
    var y = -lat * Math.PI / 180.000000;
    y = 0.5 * Math.log((1 + Math.sin(y)) / (1 - Math.sin(y)));
    y *= 1.000 / (2 * Math.PI);
    y += 0.5;
    var addr = [];
    addr[0]='t';
    var i=1;
   	var lookup = new Array( 'q', 'r', 't', 's' );

   	var digits = zoom;
    while (digits > 0)
    {
      x -= Math.floor(x);
      y -= Math.floor(y);
      var idd = (x >= 0.5 ? 1 : 0) + (y >= 0.5 ? 2 : 0);
      addr[i++] = lookup[idd];
      x *= 2;
      y *= 2;
      digits--;
    }
		var str='';
    var x = 0;
    var y = 0;
    var zoom;
    zoom = addr.length - 1;
    if (addr == "t")
    {
      x = y = 0;
      zoom = 0;
    }
    var j = addr.length - 1;
    var i = 1;
    while (i <= zoom)
    {
    var last = addr[i];
    switch (last)
    {
    	case 'q':
      	x += 0;
        y += 0;
        break;
      case 'r':
        x += Math.pow(2, j - i);
        y += 0;
        break;
      case 's':
        x += Math.pow(2, j - i);
        y += Math.pow(2, j - i);
        break;
      case 't':
        x += 0;
        y += Math.pow(2, j - i);
        break;
      }
      i++;
		}
    str=new GSPoint(x,y);
    return str;
  },
  baidu:function(width,height,zoom,mapid)
  {
  	var innerHtmlImg = '';
  	this.mapsize = 300;
    this.xLoop = Math.ceil((width) / (this.mapsize) / 2);
  	this.yLoop = Math.ceil((height) / (this.mapsize) / 2);		
		var strImgsvrUrl='http://mappng.baidu.com/maplite/mapbank/baidu/';//http://mappng.baidu.com/maplite/mapbank/baidu/7/60_18/1_8.png
		if(zoom<0||zoom>13)
			return;
		var longStep=longStepArr[zoom];
		var latStep=latStepArr[zoom];
		this.B14=zoomArr[zoom]+"/";
		this.tempX=Math.floor((this.xcenter+longStep/hunThousand)/longStep);
		this.tempY=Math.floor((this.ycenter+latStep/hunThousand)/latStep);
		if(this.tempX<0)
			this.tempX+=1;
		this.SU4=width/2-Math.round(((this.xcenter*hunThousand)%(longStep*hunThousand))*this.mapsize/(longStep*hunThousand));
		if(this.ycenter>=0)
		{
			this.EH857=height/2-this.mapsize+Math.round(((this.ycenter*hunThousand)%(latStep*hunThousand))*this.mapsize/(latStep*hunThousand))
		}
		else
		{
			this.EH857=height/2+Math.round(((this.ycenter*hunThousand)%(this.latStep*hunThousand))*this.mapsize/(this.latStep*hunThousand))
		}
		for(xCount=-this.xLoop;xCount<=this.xLoop;xCount++)
		{
			for(yCount=-this.yLoop;yCount<=this.yLoop;yCount++)
			{		
				var strImgsvrUrl='http://img.mapbar.com/maplite/mapbank/baidu';//http://mappng.baidu.com/maplite/mapbank/baidu/7/60_18/1_8.png
				strImgsvrUrl=strImgsvrUrl+"/"+this.B14;
				
				var gridStep=gridStepArr[zoom];
				//图片的文件夹
				var xFolder=parseInt(Math.floor((this.tempX+xCount)/gridStep));
				var yFolder=parseInt(Math.floor((this.tempY+yCount)/gridStep));
				{
				if(xFolder<0)
					xFolder+=1;
				if(yFolder<0)
					yFolder+=1
				}
				strImgsvrUrl+=xFolder+"_"+yFolder+"/"
				var xTile=(this.tempX+xCount)-xFolder*gridStep;
				var yTile=(this.tempY+yCount)-yFolder*gridStep;
				strImgsvrUrl+=xTile+"_"+yTile+".png";

				var imgLeft=(xCount*this.mapsize)+this.SU4;
				var imgTop=(-(yCount*this.mapsize)+this.EH857);
				imgTop=imgTop+uGE$[zoom]
				if(imgLeft<-this.mapsize||imgLeft>width||imgTop>height||imgTop<-this.mapsize)
					continue;
				var imginfo=((zoom).toString(16)+(this.tempX+xCount).toString(16)+'l'+(this.tempY+yCount).toString(16)).toLowerCase();

				if(strImgsvrUrl&&strImgsvrUrl.indexOf("NaN")<0)
				{
					innerHtmlImg+='<img id='+mapid+imginfo+' name='+imginfo+' src="'+strImgsvrUrl+'" ntry="0" unselectable=on onerror="javascript:imageTileError(this);" style="position:absolute;top:'+imgTop+';left:'+imgLeft+';">'
				}
				strImgsvrUrl=null;
			}
		}
		return innerHtmlImg
  },
  yahoo:function(width,height,zoom,mapid)
	{
    var innerHtmlImg = '';
    this.mapsize = 256;
    this.xLoop = Math.ceil((width) / (this.mapsize) / 2);
  	this.yLoop = Math.ceil((height) / (this.mapsize) / 2);
    this.nTotMN = Math.floor(Math.pow(2, zoom) / 2);
    var nOriX, nOriY;
    var yx = this.LatlngToEarth(this.xcenter, this.ycenter);
    nOriX = Math.round(width / 2 - Math.round(yx.x() * (this.mapsize * Math.pow(2, zoom-1) / dEarthLength) % this.mapsize));
    nOriY = Math.round(height / 2-this.mapsize + Math.round(yx.y() * (this.mapsize * Math.pow(2, zoom-1) / dEarthLength) % this.mapsize));
    if(this.Version=="0014")
    {
      var mapUrl = 'http://maps.yimg.com/ae/ximg?v=1.9&t=a&s=256&.intl=zh-CN';
      var mapUrl1 ='http://maps.yimg.com/hx/tl?v=4.2&t=h&.intl=zh-CN'
    }
    else
    	var mapUrl = "http://maps.yimg.com/hx/tl?v=4.2&.intl=zh-CN";
		if (this.xcenter >= 0)
			var m = Math.floor(yx.x() / (dEarthLength / Math.pow(2, zoom-1)));
		else
			var m = Math.floor(yx.x() / (dEarthLength / Math.pow(2, zoom-1))) + 1;
		if (this.ycenter >= 0)
			var n = Math.floor(yx.y() / (dEarthLength / Math.pow(2, zoom-1)));
		else
			var n = Math.floor(yx.y() / (dEarthLength / Math.pow(2, zoom-1))) + 1;
		m=m-Math.pow(2, (zoom-2))
    for (xCount = -this.xLoop - 1; xCount <= this.xLoop + 1; xCount++)
    {
      for (yCount = -this.yLoop - 1; yCount <= this.yLoop + 1; yCount++)
      {    
        if (n >= -this.nTotMN && n < this.nTotMN || this.nTotMN == 0 && n == 0)
        {
          var x = m + xCount;
          var y = n + yCount;
          if (this.nTotMN > 0)
          {
            if (x < 0)//东西方向循环
							x = this.nTotMN - (this.nTotMN - x) % ( this.nTotMN);
            if (x >= this.nTotMN)
							x = (x + this.nTotMN) % (this.nTotMN) ;
          }
          else
        	{
            x = 0;
          }
          var imgLeft = Math.round(nOriX + xCount * this.mapsize);
          var imgTop = Math.round(nOriY + (-yCount * this.mapsize));
          if (imgLeft < -this.mapsize || imgLeft > width || imgTop > height || imgTop < -this.mapsize)
						continue;
          
          mURL =mapUrl + "&x=" + x + "&y=" + y +"&z=" + zoom + "&r=1";
          if(this.Version=="0014")
        		mapUrl1 +=  "&x=" + x + "&y=" + y + "&z=" + zoom + "&r=1";
          var imginfo = ((x).toString(16) + ',' + (y).toString(16) + ',' + (zoom).toString(16)).toLowerCase();
          if (mURL && mapUrl.indexOf("NaN") < 0)
          {
						innerHtmlImg += '<img id="'+mapid + imginfo + '" name=' + imginfo + ' src="' + mURL + '" ntry="0" unselectable=on onerror="javascript:imageTileError(this);" style="position:absolute;top:' + imgTop + 'px;left:' + imgLeft + 'px;">'
						if(this.Version=="0014")
							innerHtmlImg += '<img id="'+mapid+ imginfo + '" name=' + imginfo + ' src="' + mapUrl1 + '" ntry="0" unselectable=on onerror="javascript:imageTileError(this);" style="position:absolute;top:' + imgTop + 'px;left:' + imgLeft + 'px;">'
          }
					mURL = null
        }
      }
    }
		return innerHtmlImg
	},
	sogou:function(width,height,zoom,mapid)
	{
    var innerHtmlImg = '';
    this.mapsize = 256;
    this.xLoop = Math.ceil((width) / (this.mapsize) / 2);
  	this.yLoop = Math.ceil((height) / (this.mapsize) / 2);
    this.nTotMN = Math.floor(Math.pow(2, zoom) / 2);
    var nOriX, nOriY;
    var yx = this.LatlngToEarth(this.xcenter, this.ycenter);
    nOriX = Math.round(width / 2 - Math.round(yx.x() * (this.mapsize * Math.pow(2, zoom-1) / dEarthLength) % this.mapsize));
    nOriY = Math.round(height / 2-this.mapsize + Math.round(yx.y() * (this.mapsize * Math.pow(2, zoom-1) / dEarthLength) % this.mapsize));
    if(this.Version=="0014")
    {
      var mapUrl = 'http://hbpic0.go2map.com/seamless/0/180/'//717/4/1/837_220.JPG';
      var mapUrl1 ='http://hbpic0.go2map.com/seamless/0/179/'//717/4/1/836_220.PNG'
    }
    else
    	var mapUrl = 'http://pic0.go2map.com/seamless/0/174/'//717/4/1/837_219.GIF;
		if (this.xcenter >= 0)
			var m = Math.floor(yx.x() / (dEarthLength / Math.pow(2, zoom)));
		else
			var m = Math.floor(yx.x() / (dEarthLength / Math.pow(2, zoom))) + 1;
		if (this.ycenter >= 0)
			var n = Math.floor(yx.y() / (dEarthLength / Math.pow(2, zoom)));
		else
			var n = Math.floor(yx.y() / (dEarthLength / Math.pow(2, zoom))) + 1;
    for (xCount = -this.xLoop - 1; xCount <= this.xLoop + 1; xCount++)
    {
      for (yCount = -this.yLoop - 1; yCount <= this.yLoop + 1; yCount++)
      {
        if (n >= -this.nTotMN && n < this.nTotMN || this.nTotMN == 0 && n == 0)
        {
          var x = m + xCount;
          var y = n + yCount;
          
          var imgLeft = Math.round(nOriX + xCount * this.mapsize);
          var imgTop = Math.round(nOriY + (-yCount * this.mapsize));
          if (imgLeft < -this.mapsize || imgLeft > width || imgTop > height || imgTop < -this.mapsize)
						continue;
          if(x<0)
					{
						x1='M'+Math.abs(x);
						xFolder='M'+(Math.round(Math.abs(x)/200)+1)
					}
					else
					{
						x1=x;
						xFolder=Math.round(x/200)
					}
					if(y<0)
					{
						y1='M'+Math.abs(y);
						yFolder='M'+(Math.round(Math.abs(y)/200)+1)
					}
					else
					{
						y1=y;
						yFolder=Math.round(y/200)
					}
					zoom1=728-zoom;
          if(this.Version=="0014")
          {
          	mURL =mapUrl +zoom1+'/'+xFolder+'/'+yFolder + '/' + x1 +'_'+ y1 +'.JPG';
        		mapUrl1 +=zoom1+'/'+xFolder+'/'+yFolder + '/' + x1 +'_'+ y1 +'.PNG'
        	}
        	else
        		mURL =mapUrl+zoom1+'/'+xFolder+'/'+yFolder +'/' + x1 +'_'+ y1 +'.GIF'
          var imginfo = ((x).toString(16) + ',' + (y).toString(16) + ',' + (zoom1).toString(16)).toLowerCase();
          if (mURL && mapUrl.indexOf("NaN") < 0)
          {
						innerHtmlImg += '<img id="'+mapid + imginfo + '" name=' + imginfo + ' src="' + mURL + '" ntry="0" unselectable=on onerror="javascript:imageTileError(this);" style="position:absolute;top:' + imgTop + 'px;left:' + imgLeft + 'px;">'
						if(this.Version=="0014")
							innerHtmlImg += '<img id="'+mapid+ imginfo + '" name=' + imginfo + ' src="' + mapUrl1 + '" ntry="0" unselectable=on onerror="javascript:imageTileError(this);" style="position:absolute;top:' + imgTop + 'px;left:' + imgLeft + 'px;">'
          }
					mURL = null
        }
      }
    }
		return innerHtmlImg
	},
	ditu51:function(width,height,zoom,mapid)
	{
		var innerHtmlImg = '';
		var zoom1=17-parseInt(zoom);
    if(zoom1>14)
    	zoom1=14
    this.mapsize = 200;
  
		var nPositionx = this.xcenter.toString().indexOf(".")
		var nPositiony = this.ycenter.toString().indexOf(".")
		if(nPositionx!=-1)
		{
			var xlng=this.xcenter.toString().substring(nPositionx+1,nPositionx+6);
			for(var i=xlng.length;i<5;i++)
			{
				xlng+='0'
			}
		}
		else
		{
			var xlng=this.xcenter.toString()+'00000'
		}
		if(nPositiony!=-1)
		{
			var ylat=this.ycenter.toString().substring(nPositiony+1,nPositiony+6);
			for(var j=ylat.length;j<5;j++)
			{
				ylat+='0'
			}
		}
		else
		{
			var ylat=this.ycenter.toString()+'00000'
		}
		var lng = Math.round(this.xcenter.toString().substring(0,nPositionx)+xlng);
		var lat = Math.round(this.ycenter.toString().substring(0,nPositiony)+ylat);
    var zoomUnits=Math.pow(2,zoom1)*256/this.mapsize;
    var dw=this.toMapId([lng,lat],zoom1);
    var gw=dw[0]-Math.ceil((width/2-dw[2])/this.mapsize);
		var hw=dw[1]-Math.ceil((height/2-dw[3])/this.mapsize);
		var jw=dw[0]+Math.ceil((width/2+dw[2])/this.mapsize)-1;
		var kw=dw[1]+Math.ceil((height/2+dw[3])/this.mapsize)-1;
		var zw=[-lng/zoomUnits,lat/zoomUnits];
		for(var bw=gw;bw<=jw;bw++)
		{
			for(var nw=hw;nw<=kw;nw++)
			{
				var imgLeft = (bw*this.mapsize)+parseInt(zw[0])+width/2;
				var imgTop = (-1-nw)*this.mapsize+parseInt(zw[1])+height/2;
				if (imgLeft < -this.mapsize || imgLeft > width || imgTop > height || imgTop < -this.mapsize)
					continue;
				var mapUrl=this.getMapImagesUrl(bw,nw,zoom1);
				var imginfo = ((bw).toString(16) + ',' + (nw).toString(16) + ',' + (zoom1).toString(16)).toLowerCase();
				if (mapUrl && mapUrl.indexOf("NaN") < 0)
				{
					innerHtmlImg += '<img id="'+mapid + imginfo + '" name=' + imginfo + ' src="' + mapUrl + '" ntry="0" unselectable=on onerror="javascript:imageTileError(this);" style="position:absolute;top:' + imgTop + 'px;left:' + imgLeft + 'px;">'
				}
				mapUrl = null
			};
		};
		return innerHtmlImg
	},
	toMapId:function(latlng,zoom)
	{
		var iw=256*Math.pow(2,zoom);
		var ow=parseInt(latlng[0]/iw);
		var pw=parseInt(latlng[1]/iw);
		return[ow,pw,(latlng[0]-ow*iw)/iw*this.mapsize,(latlng[1]-pw*iw)/iw*this.mapsize];
	},
	getMapImagesUrl:function(yw,uw,iw)//1420 486 5
	{
		iw+=0;
		var ow=Math.ceil((12-iw)/4);//ow=2
		var pw=0,aw=0,sw=0;
		var dw="";
		for(var fw=0;fw<ow;fw++)
		{
			var gw=1<<(4*(ow-fw));//gw=256
			var hw=parseInt((yw-pw*sw)/gw);//hw=5
			var jw=parseInt((uw-aw*sw)/gw);//jw=1
			dw+=((hw>9)?hw:"0"+hw)+""+((jw>9)?jw:"0"+jw)+"/";//0501/
			pw=hw;
			aw=jw;
			sw=gw;
		};
		var kw="http://cache4.51ditu.com/"
		var lw=(((yw)&((1<<20)-1))+(((uw)&((1<<20)-1))*Math.pow(2,20))+(((iw)&((1<<8)-1))*Math.pow(2,40)));//5498067748236
		return kw+iw+"/"+dw+lw+".png";//"http://cache4.51ditu.com/5/0501/0814/5498067748236.png"
	},
	bing:function(width,height,zoom,mapid)
	{
		var innerHtmlImg = '';
    this.mapsize = 256;
    this.xLoop = Math.ceil((width) / (this.mapsize) / 2);
  	this.yLoop = Math.ceil((height) / (this.mapsize) / 2);
    this.nTotMN = Math.floor(Math.pow(2, zoom));
    var nOriX, nOriY;
    var yx = this.LatlngToEarth(this.xcenter, this.ycenter);
    if(this.xcenter>=0)
    	nOriX = Math.round(width / 2 - Math.round(yx.x() * (this.mapsize * Math.pow(2, zoom) / dEarthLength) % this.mapsize));
    else
    	nOriX = Math.round(width / 2-this.mapsize - Math.round(yx.x() * (this.mapsize * Math.pow(2, zoom) / dEarthLength) % this.mapsize));
    if(this.ycenter>0)
    	nOriY = Math.round(height / 2-this.mapsize + Math.round(yx.y() * (this.mapsize * Math.pow(2, zoom) / dEarthLength) % this.mapsize));
    else
    	nOriY = Math.round(height / 2 + Math.round(yx.y() * (this.mapsize * Math.pow(2, zoom) / dEarthLength) % this.mapsize));
		
		var mn=this.getbingmapxy(this.xcenter,this.ycenter,zoom);
    for (xCount = -this.xLoop - 1; xCount <= this.xLoop + 1; xCount++)
    {
      for (yCount = -this.yLoop - 1; yCount <= this.yLoop + 1; yCount++)
      {
      	var x = mn[0] + xCount;
        var y = mn[1] + yCount;
      	if(this.Version=="0014")
      	{
      		var mapUrl = 'http://khm.google.com/kh/v=42';
      		var mapUrl1 ='http://mt.google.cn/vt/v=w2t.101&hl=zh-CN&gl=cn'
      	}
      	else if(this.Version=="0018")
      		var mapUrl = 'http://mt.google.com/mt/v=cnw2p.98&hl=zh-CN&gl=cn'
      	else
      		var mapUrl = 'http://r3.tiles.ditu.live.com/tiles/'
				if (this.nTotMN > 1)
        {
          if (x < 0)//东西方向循环
						x = this.nTotMN+x;
          if (x >= this.nTotMN)
						x = (x + this.nTotMN) % (2 * this.nTotMN);
        }

        var imgLeft = Math.round(nOriX + xCount * this.mapsize);
        var imgTop = Math.round(nOriY + (yCount * this.mapsize));      
        if (imgLeft < -this.mapsize || imgLeft > width || imgTop > height || imgTop < -this.mapsize)
					continue
				if (y > this.nTotMN-1 || y < 0)
					continue;
				var bingurl=this.getbingmapurl(x,y,zoom)
        mapUrl = mapUrl + bingurl + '.png?g=45';
//        if(this.Version=="0014")
//        	mapUrl1 +=  "&x=" + x + "&y=" + y + "&z=" + zoom;
        var imginfo = (bingurl).toString(16).toLowerCase();
        if (mapUrl && mapUrl.indexOf("NaN") < 0)
        {
					innerHtmlImg += '<img id="'+mapid+ imginfo + '" name=' + imginfo + ' src="' + mapUrl + '" ntry="0" unselectable=on onerror="javascript:imageTileError(this);" style="position:absolute;top:' + imgTop + 'px;left:' + imgLeft + 'px;">'
					if(this.Version=="0014")
						innerHtmlImg += '<img id="'+mapid+ imginfo + '" name=' + imginfo + ' src="' + mapUrl1 + '" ntry="0" unselectable=on onerror="javascript:imageTileError(this);" style="position:absolute;top:' + imgTop + 'px;left:' + imgLeft + 'px;">'
        }
        mapUrl = null;
      }
    }
    return innerHtmlImg
	},
	getbingmapxy:function(lng,lat,zoom)
	{
		var x = (180.000000 + lng) / 360.000000;
    var y = -lat * Math.PI / 180.000000;
    y = 0.5 * Math.log((1 + Math.sin(y)) / (1 - Math.sin(y)));
    y *= 1.000 / (2 * Math.PI);
    y += 0.5;
    var addr=[];
    addr[0]='r'
    var i=1;
   	var lookup = new Array( '0', '1', '2', '3' );

   	var digits = zoom;
    while (digits > 0)
    {
      x -= Math.floor(x);
      y -= Math.floor(y);
      var idd = (x >= 0.5 ? 1 : 0) + (y >= 0.5 ? 2 : 0);
      addr[i++] = lookup[idd];
      x *= 2;
      y *= 2;
      digits--;
    }
    var a = 0;
    var b = 0;
    var zoom;
    zoom = addr.length - 1;
    var j = addr.length - 1;
    var i = 1;
    while (i <= zoom)
    {
    	var last = addr[i];
    	switch (last)
    	{
    	case '0':
      	a += 0;
        b += 0;
        break;
      case '1':
        a += Math.pow(2, j - i);
        b += 0;
        break;
      case '3':
        a += Math.pow(2, j - i);
        b += Math.pow(2, j - i);
        break;
      case '2':
        a += 0;
        b += Math.pow(2, j - i);
        break;
      }
      i++;
		}
    return [a,b]
	},
	getbingmapurl:function(x,y,zoom)
	{	
		var str = "r";
		var ZM = zoom;
		var ZMD = Math.pow(2,ZM);

		for(var g=0; g<ZM; g++)
		{
			ZMD = ZMD/2;
			if(y < ZMD)
			{
				if(x < ZMD)
				{
					str+="0";
				}
				else
				{
					str+="1";
					x -= ZMD;
				}
			}
			else
			{
				if(x < ZMD)
				{
					str+="2";
					y -= ZMD;
				}
				else
				{
					str+="3";
					x -= ZMD;
					y -= ZMD;
				}
			}
		}
		return str;
	},
	
  updateOthers: function()
  {
    if (this.bscale && this.layerScale)//调整比例尺显示
    {
      var nLevelScale = Math.pow(2, this.zoomLevel);
      var nTotPixelXY = nLevelScale * this.mapsize;
      var dMeterPerPixel = Math.max(this.dW / nTotPixelXY, this.dH / nTotPixelXY);
      var nScaleRule = Math.floor(dMeterPerPixel * 50);
      var nDec = Math.floor(Math.log(nScaleRule) / Math.log(10));
      if (nDec > 1)
				nDec = Math.floor(Math.pow(10, nDec - 1));
      nScaleRule = Math.round(nScaleRule * 1.0 / nDec / 5) * nDec * 5;
      var nPixelRuler = Math.floor(nScaleRule / dMeterPerPixel);

      var sUnit = '';
      var nValue = 0;
      if (nScaleRule < 10000)
      {
        sUnit = "m";
        nValue = nScaleRule;
      }
      else
    	{
        sUnit = "km";
        nValue = nScaleRule / 1000;
      }
      nValue += sUnit;
      this.layerScale.objDiv.innerHTML = '';
      var scaleColor = "black";
      var line = '<div unselectable="on" style="position:absolute;top:2px;left:1px;z-Index:0"><v:line from="0,10" to="' + nPixelRuler + ',10" style="position:absolute;left:0px;top:0px;" StrokeColor="' + scaleColor + ';"strokeweight="2"></v:line><v:line from="0,10" to="0,5" style="position:absolute;left:0px;top:0px;" StrokeColor="' + scaleColor + '"></v:line><v:line from="' + nPixelRuler + ',10" to="' + nPixelRuler + ',5" style="position:absolute;left:0px;top:0px;" StrokeColor="' + scaleColor + '"></v:line></div>';
      line += '<div unselectable="on" style="position:absolute;top:0px;left:-1px;z-Index:1"><TABLE cellSpacing=0 cellPadding=0 border=0><TBODY><TR><TD unselectable="on" style="z-Index:1;FONT-SIZE: 12px; COLOR:' + scaleColor + ';FONT-WEIGHT: bold;" width="100%">&nbsp;' + nValue + '</TD></TR></TBODY></TABLE></div>';
      this.layerScale.objDiv.innerHTML = line;
    }

    if (this.blogo)
    {
      this.layerLogo.objDiv.innerHTML = '';
      var logoContent = '<u>&copy;Toogo.info</u>&nbsp;'; //右下角版权标识
      var logoInfo = '<div unselectable="on" style="position:absolute;top:0px;left:0px;width:50px;height:23px;z-Index:1"><TABLE cellSpacing=0 cellPadding=0 border=0 align=right><TBODY><TR><TD unselectable="on" style="z-Index:1;top:8px;left:1px;FONT-SIZE: 12px; font-family: arial;COLOR:black;" width="100%" >' + logoContent + '</TD></TR></TBODY></TABLE></div>';
      this.layerLogo.objDiv.innerHTML = logoInfo
    }
    else
  	{
      this.layerLogo.objDiv.innerHTML = ''
    }
  },

  removeTagControl1: function()
  {
		this.layerMarker.objDiv.innerHTML = ''
  },
	
	getMaxlatMinlng:function()
	{
		return this.xyTolatlng(0,0)
	},
	
	getMinlatMaxlng:function()
	{
		return this.xyTolatlng(this.width,this.height)
	},
	
  getSphereDis: function(pt1, pt2)
  {
    this.pt1 = pt1;
    this.pt2 = pt2;
    var val = Math.sin(this.pt1.lat() * PI / 180) * Math.sin(this.pt2.lat() * PI / 180) + Math.cos(this.pt1.lat() * PI / 180) * Math.cos(this.pt2.lat() * PI / 180) * Math.cos(this.pt1.lng() * PI / 180 - this.pt2.lng() * PI / 180);
    var RInclication = Math.acos(val);
    var SphereDis = WGS_LRADIUS * (RInclication);
    return SphereDis;
  },
  zoom: function(pt1, pt2)
  {
    this.pt1 = pt1;
    this.pt2 = pt2;
    var ptlng = this.pt1.lng() - this.pt2.lng();
    ptlng = (ptlng > 0) ? ptlng : -ptlng;
    var ptlat = this.pt1.lat() - this.pt2.lat();
    ptlat = (ptlat > 0) ? ptlat : -ptlat;
    var zoomlevel1 = Math.floor(Math.log((earth * this.width) / (parseFloat(ptlng) * this.mapsize)) / Math.log(2));
		var zoomlevel2 = Math.floor(Math.log((earth * this.height) / (parseFloat(ptlat) * this.mapsize)) / Math.log(2));
    if (ptlng == 0 || ptlat == 0)
			return 15;
    else
			return zoomlevel1 >= zoomlevel2 ? zoomlevel2 : zoomlevel1
  },
  moveTo: function(pt)
  {
    this.pt = pt;
    var xy=this.LatlngToScreen(parseFloat(this.pt.lng()),parseFloat(this.pt.lat()));
		var x =xy.x();
		var y =xy.y();
    if ((x <= 0) || (x >= this.width) || (y <= 0) || (y >= this.height))
    {
      if (this.Projection == "baidu" || this.Projection == "Baidu" || this.Projection == "BaiDu" || this.Projection == "BAIDU")
      {
				this.setCenter(new GSLatLng(parseFloat(this.pt.lat()) + parseFloat(baidulatdif), parseFloat(this.pt.lng()) - parseFloat(baidulngdif)), this.zoomLevel)
			}
			else if (this.Projection == "toogo" || this.Projection == "Toogo" || this.Projection == "TooGO" || this.Projection == "TOOGO")
			{
				this.setCenter(new GSLatLng(parseFloat(this.pt.lat()) + parseFloat(toogolatdif), parseFloat(this.pt.lng()) - parseFloat(toogolngdif)), this.zoomLevel)
			}
			else
				this.setCenter(new GSLatLng(parseFloat(this.pt.lat()), parseFloat(this.pt.lng())), this.zoomLevel)   
      markertagBox(markerinfo, this.width / 2 + this.left, this.height / 2 + this.top)
    }
    else if ((x < tagwidth / 2 + 60) && (y < tagheight + 110))
  	{
      this.updateAfterChangeView((tagwidth / 2 + 60 - x), (tagheight + 110 - y));
      markertagBox(markerinfo, (this.left + tagwidth / 2 + 60), this.top + tagheight + 110)
    }
    else if (x > this.width - (tagwidth / 2 + 15) && (y < tagheight + 110))
  	{
      this.updateAfterChangeView((this.width - (tagwidth / 2 + 15) - x), (tagheight + 110 - y));
      markertagBox(markerinfo, (this.left + this.width - (tagwidth / 2 + 15)), this.top + tagheight + 110)
    }
    else if (x < (tagwidth / 2 + 60))
  	{
      this.updateAfterChangeView((tagwidth / 2 + 60 - x), 0);
      markertagBox(markerinfo, this.left + tagwidth / 2 + 60, y + this.top)
    }
    else if (y < tagheight + 110)
  	{
      this.updateAfterChangeView(0, (tagheight + 110 - y));
      markertagBox(markerinfo, (x + this.left), this.top + tagheight + 110)
    }
    else if (x > this.width - (tagwidth / 2 + 15))
  	{
      this.updateAfterChangeView(this.width - (tagwidth / 2 + 15) - x, 0);
      markertagBox(markerinfo, (this.left + this.width - (tagwidth / 2 + 15)), y + this.top)
    }
    else
			markertagBox(markerinfo, (this.left +x), y + this.top)
  },
  OYos: function(zoom, x, y)
  {
    if (typeof x == "undefined")
    {
			x = 0
    }
    if (typeof y == "undefined")
    {
			y = 0
    }
    var zoomto = Math.pow(2, parseFloat(zoom)) / Math.pow(2, this.zoomLevel);
    this.mapContainer.objDiv.style.zoom = zoomto;
    this.mapContainer.objDiv.style.left = (this.width / 2 - this.width * zoomto / 2 + x) + "px";
    this.mapContainer.objDiv.style.top = (this.height / 2 - this.height * zoomto / 2 + y) + "px"
  },
  bothInRect: function()
  {
    if ((this.movex > 0) && (this.movex < this.width) && (this.movey > 0) && (this.movey < this.height)&& (this.downx > 0) && (this.downx < this.width) && (this.downy > 0) && (this.downy < this.height))
			return true;
    else
			return false
  },

  updateAfterChangeView: function(x, y)
  {
    this.num20 = 20.0;
    this.time = null;
    this.xoffset = parseInt(x);
    this.yoffset = parseInt(y);
    this.wNR0 = 0;
    this.r0mA = 0;
    this.offsetDistance = parseInt(Math.sqrt(this.xoffset * this.xoffset + this.yoffset * this.yoffset));
    if (!this.bPanning)
    {
			this.doPan()
    }
  },

  doPan: function()
  {
    this.bPanning = true;
    var X90rQ = parseInt(Math.sqrt(this.wNR0 * this.wNR0 + this.r0mA * this.r0mA));
    if (Math.abs(this.offsetDistance - X90rQ) <= (1.2 * this.num20))
    {
      this.mapContainer.moveTo(this.xoffset, this.yoffset);
      this.wNR0 = this.xoffset;
      this.r0mA = this.yoffset;
      this.time = null;
      this.time = getTimeout(this, this.finishupPan, 10);

    }
    else
  	{
      this.wNR0 += this.xoffset * this.num20 / this.offsetDistance;
      this.r0mA += this.yoffset * this.num20 / this.offsetDistance;
      this.mapContainer.moveTo(this.wNR0, this.r0mA);
      this.time = null;
      this.time = getTimeout(this, this.doPan, 10);
    }
  },

  finishupPan: function()
  {
  	var latlng=this.ScreenToLatlng(-this.xoffset,-(this.yoffset),this.zoomLevel);
		this.ycenter=latlng.lat();
		this.xcenter=latlng.lng(); 	
    this.setZoom(this.zoomLevel);
    this.bPanning = false;
    this.time = null
  },
  getStartDownPot: function(x1, y1, x2, y2, len)
  {
    var x = x1 - len * ((y2 - y1) / Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2)));
    var y = y1 + len * ((x2 - x1) / Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2)));
    var latlng=this.ScreenToLatlng(x,y);
		var lat=latlng.lat();
		var lng=latlng.lng();
    return new GSLatLng(lat, lng)
  },
  getStartUpPot: function(x1, y1, x2, y2, len)
  {
    var x = x1 + len * ((y2 - y1) / Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2)));
    var y = y1 - len * ((x2 - x1) / Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2)));
    var latlng=this.ScreenToLatlng(x,y);
		var lat=latlng.lat();
		var lng=latlng.lng();
    return new GSLatLng(lat, lng)
  },
  getMoveDownPot: function(x1, y1, x2, y2, len)
  {
    var x = x2 - len * ((y2 - y1) / Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2)));
    var y = y2 + len * ((x2 - x1) / Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2)));
    var latlng=this.ScreenToLatlng(x,y);
		var lat=latlng.lat();
		var lng=latlng.lng();
    return new GSLatLng(lat, lng)
  },
  getMoveUpPot: function(x1, y1, x2, y2, len)
  {
    var x = x2 + len * ((y2 - y1) / Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2)));
    var y = y2 - len * ((x2 - x1) / Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2)));
    var latlng=this.ScreenToLatlng(x,y);
		var lat=latlng.lat();
		var lng=latlng.lng();
    return new GSLatLng(lat, lng)
  },
  getMidPot: function(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5)
  {
    var a = x2 - x1;
    var b = y2 - y1;
    var c = x3 - x2;
    var d = y3 - y2;
    var x = 0;
    var y = 0;
    if (a == 0 || b == 0 || c == 0 || d == 0)
    {
      if (a == 0 && b == 0)
      {
        x = x4;
        y = y4
      }
      else if (c == 0 && d == 0)
    	{
        x = x5;
        y = y5
      }
      else if (a == 0 && c == 0)
    	{
        x = x4;
        y = y2
      }
      else if (b == 0 && d == 0)
    	{
        x = x2;
        y = y4
      }
      else if (a == 0 && d == 0)
    	{
        x = x4;
        y = y5
      }
      else if (b == 0 && c == 0)
    	{
        x = x5;
        y = y4
      }
      else if (a == 0)
    	{
        x = x4;
        y = ((x4 - x5) + c / d * y5 - a / b * y4) / (c / d - a / b)
      }
      else if (b == 0)
    	{
        x = ((y4 - y5) + d / c * x5 - b / a * x4) / (d / c - b / a);
        y = y4
      }
      else if (c == 0)
    	{
        x = x5;
        y = ((x4 - x5) + c / d * y5 - a / b * y4) / (c / d - a / b)
      }
      else
    	{
        x = ((y4 - y5) + d / c * x5 - b / a * x4) / (d / c - b / a);
        y = y5
      }
    }
    
    else
  	{
      x = ((y4 - y5) + d / c * x5 - b / a * x4) / (d / c - b / a);
      y = ((x4 - x5) + c / d * y5 - a / b * y4) / (c / d - a / b);
    }
    var latlng=this.ScreenToLatlng(x,y);
		var lat=latlng.lat();
		var lng=latlng.lng();
		return new GSLatLng(lat, lng)
  },
  xyTolatlng: function(x, y)
  {
  	var latlng=this.ScreenToLatlng(x- this.left,y- this.top);
		var lat=latlng.lat();
		var lng=latlng.lng();
    return new GSLatLng(lat, lng)
  },
  
  latlngToxy: function(lng,lat)
  {
  	var xy=this.LatlngToScreen(lng,lat);
  	var x=xy.x();
  	var y=xy.y();
  	return new GSPoint(x, y)
  },
  
	ScreenToEarth:function(x,y,zoom)
	{
		var yx = this.LatlngToEarth(this.xcenter, this.ycenter);
		if(typeof zoom == "undefined")
		{		
			var xDifference = parseInt(x) - this.width / 2;
    	var yDifference = parseInt(y) - this.height / 2;
			if(this.Projection == "yahoo"||this.Projection == "Yahoo"||this.Projection == "YaHoo"||this.Projection == "YAHOO")
  		{
  			var x1 = (yx.x() + xDifference * ((dEarthLength / Math.pow(2, this.zoomLevel-1)) / this.mapsize));
	    	var y1 = (yx.y() - yDifference * ((dEarthLength / Math.pow(2, this.zoomLevel-1)) / this.mapsize));
  		}
  		else
  		{
	    	var x1 = (yx.x() + xDifference * ((dEarthLength / Math.pow(2, this.zoomLevel)) / this.mapsize));
	    	var y1 = (yx.y() - yDifference * ((dEarthLength / Math.pow(2, this.zoomLevel)) / this.mapsize));
	    }
    }
    else
    {
    	var xDifference = parseInt(x);
    	var yDifference = parseInt(y);
    	if(this.Projection == "yahoo"||this.Projection == "Yahoo"||this.Projection == "YaHoo"||this.Projection == "YAHOO")
  		{
  			var x1 = yx.x() + xDifference * ((dEarthLength / Math.pow(2, zoom-1)) / this.mapsize);
	    	var y1 = yx.y() - yDifference * ((dEarthLength / Math.pow(2, zoom-1)) / this.mapsize);
  		}
  		else
  		{
	    	var x1 = yx.x() + xDifference * ((dEarthLength / Math.pow(2, zoom)) / this.mapsize);
	    	var y1 = yx.y() - yDifference * ((dEarthLength / Math.pow(2, zoom)) / this.mapsize);
	    }
    }   
    return new GSPoint(x1, y1)
  },
  ScreenToLatlng:function(x,y,zoom)
  {
  	var xy,latlng,lat,lng;
  	if(this.Projection == "baidu"||this.Projection == "Baidu"||this.Projection == "BaiDu"||this.Projection == "BAIDU")
  	{
  		if(typeof zoom == "undefined")
  		{
  			var xDifference = parseInt(x) - this.width / 2;
    		var yDifference = parseInt(y) - this.height / 2;
    		lng=this.xcenter+baidulngdif+(xDifference)*this.longStep/this.mapsize;
				lat=this.ycenter-baidulatdif-(yDifference)*this.latStep/this.mapsize
  		}
  		else
  		{
  			var longStep=longStepArr[zoom];
				var latStep=latStepArr[zoom];
	  		lng=this.xcenter+(x)*longStep/this.mapsize;
				lat=this.ycenter-(y)*latStep/this.mapsize
			}
  	}
  	else if(this.Projection == "toogo"||this.Projection == "Toogo"||this.Projection == "TooGo"||this.Projection == "TOOGO")
  	{
  		if(typeof zoom == "undefined")
  		{
  			var xDifference = parseInt(x) - this.width / 2;
    		var yDifference = parseInt(y) - this.height / 2;
    		lng=this.xcenter+toogolngdif+xDifference*((earth/Math.pow(2,this.zoomLevel))/this.mapsize);
				lat=this.ycenter-toogolatdif-yDifference*((earth/Math.pow(2,this.zoomLevel))/this.mapsize)
  		}
  		else
  		{
	  		lng=this.xcenter+(x)*((earth/Math.pow(2,zoom))/this.mapsize);
				lat=this.ycenter-(y)*((earth/Math.pow(2,zoom))/this.mapsize)
			}
  	}
  	else if(this.Projection == "51ditu"||this.Projection == "51DiTu"||this.Projection == "51Ditu"||this.Projection == "51DITU")
    {
    	var nPositionx = this.xcenter.toString().indexOf(".")
			var nPositiony = this.ycenter.toString().indexOf(".")
			if(nPositionx!=-1)
			{
				var xlo=this.xcenter.toString().substring(nPositionx+1,nPositionx+6);
				for(var i=xlo.length;i<5;i++)
				{
					xlo+='0'
				}
			}
			else
			{
				var xlo=this.xcenter.toString()+'00000'
			}
			if(nPositiony!=-1)
			{
				var yla=this.ycenter.toString().substring(nPositiony+1,nPositiony+6);
				for(var j=yla.length;j<5;j++)
				{
					yla+='0'
				}
			}
			else
			{
				var yla=this.ycenter.toString()+'00000';
			}
			var xlng = Math.round(this.xcenter.toString().substring(0,nPositionx)+xlo);
			var ylat = Math.round(this.ycenter.toString().substring(0,nPositiony)+yla);
			
  		if(typeof zoom == "undefined")
  		{
  			
  			var xDifference = parseInt(x) - this.width / 2;
    		var yDifference = parseInt(y) - this.height / 2;
    		this.zoomUnits=Math.pow(2,(17-this.zoomLevel))*256/this.mapsize;
				lng=parseInt(xlng+parseFloat(xDifference*this.zoomUnits));
				lat=parseInt(ylat-parseFloat(yDifference*this.zoomUnits))
  		}
  		else
  		{
  			zoom1=17-parseInt(zoom);
  			if(zoom1>14)
  				zoom1=14
  			var zoomUnits=Math.pow(2,zoom1)*256/this.mapsize;
				lng=parseInt(xlng+(x)*parseFloat(zoomUnits));
				lat=parseInt(ylat-(y)*parseFloat(zoomUnits))
			}
			lng = parseFloat(lng.toString().substring(0,lng.toString().length-5)+'.'+lng.toString().substring(lng.toString().length-5,lng.toString().length));
			lat = parseFloat(lat.toString().substring(0,lat.toString().length-5)+'.'+lat.toString().substring(lat.toString().length-5,lat.toString().length))
  	}
  	else
  	{	
	  	xy=this.ScreenToEarth(x,y,zoom);
			latlng=this.EarthToLatlng(xy.x(),xy.y());
			lat=latlng.lat();
			lng=latlng.lng()
		}
		return new GSLatLng(lat, lng)
  },
  LatlngToScreen:function(lng,lat)
  {
  	var yx,xy,x,y
  	if(this.Projection == "baidu"||this.Projection == "Baidu"||this.Projection == "BaiDu"||this.Projection == "BAIDU")
  	{
  		x=Math.round(this.width/2+(parseFloat(lng)-parseFloat(baidulngdif)-this.xcenter)/this.longStep*this.mapsize);
  		y=Math.round(this.height/2-(parseFloat(lat)+parseFloat(baidulatdif)-this.ycenter)/this.latStep*this.mapsize)
  	}
  	else if(this.Projection == "toogo"||this.Projection == "Toogo"||this.Projection == "TooGO"||this.Projection == "TOOGO")
  	{
  		x=Math.round(this.width/2+(parseFloat(lng)-parseFloat(toogolngdif)-this.xcenter)*this.mapsize/(earth/Math.pow(2,this.zoomLevel)))
  		y=Math.round(this.height/2-(parseFloat(lat)+parseFloat(toogolatdif)-this.ycenter)*this.mapsize/(earth/Math.pow(2,this.zoomLevel)))
  	}
  	else if(this.Projection == "51ditu"||this.Projection == "51DiTu"||this.Projection == "51Ditu"||this.Projection == "51DITU")
		{
    	var nPositionx = this.xcenter.toString().indexOf(".")
			var nPositiony = this.ycenter.toString().indexOf(".")
			if(nPositionx!=-1)
			{
				var xlo=this.xcenter.toString().substring(nPositionx+1,nPositionx+6);
				for(var i=xlo.length;i<5;i++)
				{
					xlo+='0'
				}
			}
			else
			{
				var xlo=this.xcenter.toString()+'00000'
			}
			if(nPositiony!=-1)
			{
				var yla=this.ycenter.toString().substring(nPositiony+1,nPositiony+6);
				for(var j=yla.length;j<5;j++)
				{
					yla+='0'
				}
			}
			else
			{
				var yla=this.ycenter.toString()+'00000'
			}
			var xlng = Math.round(this.xcenter.toString().substring(0,nPositionx)+xlo);
			var ylat = Math.round(this.ycenter.toString().substring(0,nPositiony)+yla);
			
			var nPosx = lng.toString().indexOf(".")
			var nPosy = lat.toString().indexOf(".")
			if(nPosx!=-1)
			{
				var lox=lng.toString().substring(nPosx+1,nPosx+6);
				for(var i=lox.length;i<5;i++)
				{
					lox+='0'
				}
			}
			else
			{
				var lox=lng.toString()+'00000'
			}
			if(nPosy!=-1)
			{
				var lay=lat.toString().substring(nPosy+1,nPosy+6);
				for(var j=lay.length;j<5;j++)
				{
					lay+='0'
				}
			}
			else
			{
				var lay=lat.toString()+'00000'
			}	
			lng = Math.round(lng.toString().substring(0,nPosx)+lox);
			lat = Math.round(lat.toString().substring(0,nPosy)+lay);
			var zoom=17-parseInt(this.zoomLevel);
    	if(zoom>14)
    		zoom=14
			this.zoomUnits=Math.pow(2,zoom)*256/this.mapsize;
  		x = Math.round(this.width/2+(lng-xlng)/this.zoomUnits)
  		y = Math.round(this.height/2-(lat-ylat)/this.zoomUnits)
  	}
  	else
  	{
	  	yx=this.LatlngToEarth(lng,lat);
	  	xy=this.EarthToScreen(yx.x(),yx.y());
	  	x=xy.x();
	  	y=xy.y()
  	}
  	return new GSPoint(x, y)
  },
	R2D:function(dRad)
	{
		return dRad*180/PI;
	},
	D2R:function(dDeg)
	{
		return dDeg*PI/180;
	},
	GetMarkLatiK:function(dMarkLati)
	{
		var dMarkLatiK, N, dRMarkLati;
		dRMarkLati = this.D2R(dMarkLati);
		N = WGS_LRADIUS / Math.sqrt(1 - WGS_FER * WGS_FER * Math.sin(dRMarkLati) * Math.sin(dRMarkLati));
		dMarkLatiK = N * Math.cos(dRMarkLati);
		return dMarkLatiK;
	},
	EDCyToEarth:function(x, y, dMarkLati, dOrginLongi)
	{
		var dROrginLongi,dROrginLati,dRLongi,dRLati;
		var dOrginLati = 0;
		var AT,BT,CT, dS;
		var dMarkLatiK;
		var dT1;
		var dLongi, dLati;
		//计算基准纬线半径
		dMarkLatiK = this.GetMarkLatiK(dMarkLati);
		AT = 1.0050517739;
		BT = 0.0050623776;
		CT = 0.0000106245;
		dROrginLati = this.D2R(dOrginLati);
		dROrginLongi = this.D2R(dOrginLongi);
		dRLongi = x / dMarkLatiK + dROrginLongi;
		dS = y;
		dRLati = dS/(WGS_LRADIUS*(1-WGS_FER*WGS_FER)*AT);
		for (var i=0;i<5;i++)
		{
			dT1 = BT/2*(Math.sin(2*dRLati)-Math.sin(2*dOrginLati))-CT/4*(Math.sin(4*dRLati)-Math.sin(4*dOrginLati));
			dRLati = (dS+WGS_LRADIUS*(1-WGS_FER*WGS_FER)*dT1)/(WGS_LRADIUS*(1-WGS_FER*WGS_FER)*AT);
		}
		dLongi = this.R2D(dRLongi) + 0.000000001;
		dLati = this.R2D(dRLati) + 0.000000001;
		return new GSLatLng(dLati, dLongi)
	},
	MercatorToEarth:function(x, y, dMarkLati, dOrginLongi)
	{
		//N表示卯酉圈曲率半径，K表示中间变量
		var dLastB, dEXP;
		var dROrginLongi, dROrginlati;
		var dOrginLati = 0;
		var dLongi, dLati;
		dROrginlati = this.D2R(dOrginLati);
		dROrginLongi = this.D2R(dOrginLongi);
		
		//计算基准纬线半径
		dMarkLatiK = this.GetMarkLatiK(dMarkLati);
		dOrginLati = 0;
		dEXP = Math.exp((y) / (dMarkLatiK));
		dLongi = (x) / dMarkLatiK + this.D2R(dOrginLongi);
		dLastB = 2 *(Math.atan(dEXP)-PI/4);
		if(this.Version=="0014")
		{	
			dLongi = this.R2D(dLongi) + 0.0000000001;
			dLati = this.R2D(dLastB) + 0.0000000001;
		}
		else
		{
			dLongi = this.R2D(dLongi) + 0.0000000001;
			dLati = this.R2D(dLastB) + 0.0000000001;
		}
		return new GSLatLng(dLati, dLongi)
	},
	EACyToEarth:function(x, y, dMarkLati, dOrginLongi)
	{
		var dROrginLongi,dROrginLati,dRLongi,dRLati;
		var dOrginLati = 0;
		var dK0, dK1, dK2, dK3, dF;
		var dT1;
		var dLongi, dLati;

		//计算基准纬线半径
		dMarkLatiK = this.GetMarkLatiK(dMarkLati);
		dROrginLati = this.D2R(dOrginLati);
		dROrginLongi = this.D2R(dOrginLongi);

		dK0 = 2*WGS_LRADIUS*WGS_LRADIUS*(1-WGS_FER*WGS_FER);
		dK1 = 1+1/2.0* WGS_FER*WGS_FER+3.0/8* WGS_FER*WGS_FER*WGS_FER*WGS_FER;
		dK2 = 1/6.0* WGS_FER*WGS_FER+3.0/16* WGS_FER*WGS_FER*WGS_FER*WGS_FER;
		dK3 = 3.0/80* WGS_FER*WGS_FER*WGS_FER*WGS_FER;

		dRLongi = x / dMarkLatiK + dROrginLongi;
		dF = y * dMarkLatiK;

		dT1 = 2/dK1 * dF/dK0;
		if(dT1 > 1)
			dT1 = 1;
		if (dT1 < -1)
			dT1 = -1;
		dRLati = Math.asin(dT1);
		for (var i = 0; i < 5; i++)
		{
			dT1 = dF/dK0 + dK2*Math.sin(3*dRLati)/2-dK3*Math.sin(5*dRLati)/2;
			dT1 = 2/dK1 * dT1;
			if(dT1 > 1)
				dT1 = 1;
			if (dT1 < -1)
				dT1 = -1;
			dRLati = Math.asin(dT1);
		}

		dLongi = this.R2D(dRLongi)+ 0.000000001;
		dLati = this.R2D(dRLati)+ 0.000000001;
		return new GSLatLng(dLati, dLongi)
	},
	EarthToLatlng:function(x,y)
	{
		var lng;
		var lat;
		var latlng;
		latlng=this.MercatorToEarth(x, y, 0, 0);
		lng=latlng.lng();
		lat=latlng.lat();
		return new GSLatLng(lat, lng)
	},
	EarthToEDCy:function(dLongi, dLati, dMarkLati, dOrginLongi)
	{
		var dROrginLongi,dROrginLati,dRLongi,dRLati;
		var dOrginLati = 0;
		var AT,BT,CT, dS;
		var dMarkLatiK;
		var dT1;
		var dRB1;
		var dXEast, dYNorth;
		//计算基准纬线半径
		dMarkLatiK = this.GetMarkLatiK(dMarkLati);
		AT = 1.0050517739;
		BT = 0.0050623776;
		CT = 0.0000106245;
		dROrginLati = this.D2R(dOrginLati);
		dROrginLongi = this.D2R(dOrginLongi);
		dRLongi = this.D2R(dLongi);
		dRLati = this.D2R(dLati);
		dRB1 = dRLati;

		//计算弧长
		dS = WGS_LRADIUS*(1-WGS_FER*WGS_FER)*(AT*(dRB1-dROrginLati)-BT/2*(Math.sin(2*dRB1)-Math.sin(2*dOrginLati))
			+CT/4*(Math.sin(4*dRB1)-Math.sin(4*dOrginLati)));

		dXEast = dMarkLatiK* (dRLongi - dROrginLongi);
		dYNorth = dS;
		return new GSPoint(dXEast, dYNorth)
	},
	EarthToMercator:function(dLongi, dLati, dMarkLati, dOrginLongi)
	{
		//N表示卯酉圈曲率半径，K表示中间变量
		var dROrginLongi, dROrginlati,dRLongi,dRLati;
		var dOrginLati = 0;
		var dXEast, dYNorth;
		dROrginlati = this.D2R(dOrginLati);
		dROrginLongi = this.D2R(dOrginLongi);
		if(this.Version=="0014")
		{
			dRLongi = this.D2R(dLongi);
			dRLati = this.D2R(dLati);
		}
		else
		{
			dRLongi = this.D2R(dLongi);
			dRLati = this.D2R(dLati);
		}
		
		//计算基准纬线半径
		dMarkLatiK = this.GetMarkLatiK(dMarkLati);				

		Q = Math.log(Math.tan(PI / 4 + dRLati / 2));
		if (Q < 0.000000001 && Q > -0.000000001)
			Q = 0;

		dXEast = dMarkLatiK * (dRLongi - dROrginLongi);
		dYNorth = dMarkLatiK * Q;
		return new GSPoint(dXEast, dYNorth)
	},
	EarthToEACy:function(dLongi, dLati, dMarkLati, dOrginLongi)
	{
		var dROrginLongi,dROrginLati,dRLongi,dRLati;
		var dOrginLati = 0;
		var dK0, dK1, dK2, dK3, dF;
		var dT1, dB1, dB2;
		var dXEast, dYNorth;

		//计算基准纬线半径
		dMarkLatiK = this.GetMarkLatiK(dMarkLati);

		dROrginLati = this.D2R(dOrginLati);
		dROrginLongi = this.D2R(dOrginLongi);

		dK0 = 2*WGS_LRADIUS*WGS_LRADIUS*(1-WGS_FER*WGS_FER);
		dK1 = 1+1/2.0* WGS_FER*WGS_FER+3.0/8* WGS_FER*WGS_FER*WGS_FER*WGS_FER;
		dK2 = 1/6.0* WGS_FER*WGS_FER+3.0/16* WGS_FER*WGS_FER*WGS_FER*WGS_FER;
		dK3 = 3.0/80* WGS_FER*WGS_FER*WGS_FER*WGS_FER;

		dRLongi = this.D2R(dLongi);
		dRLati = this.D2R(dLati);
		dB1 = (dRLati - dROrginLati);
		dB2 = (dRLati + dROrginLati)/2;
		dT1 = dK1*Math.sin(dB1/2)*Math.cos(dB2)-dK2*Math.sin(3*dB1/2)*Math.cos(3*dB2)+dK3*Math.sin(5*dB1/2)*Math.cos(5*dB2);
		//梯形面积
		dF = dK0 * dT1;

		dXEast = dMarkLatiK* (dRLongi - dROrginLongi);
		dYNorth = dF / dMarkLatiK;
		return new GSPoint(dXEast, dYNorth)
	},
	LatlngToEarth:function(lng,lat)
	{
		var x;
		var y;
		var xy;
		xy=this.EarthToMercator(lng, lat, 0, 0);
		x=xy.x();
		y=xy.y();
		return new GSPoint(x, y)
	},
	EarthToScreen:function(lng,lat)
	{
		var yx = this.LatlngToEarth(this.xcenter, this.ycenter);
		if(this.Projection == "yahoo"||this.Projection == "Yahoo"||this.Projection == "YaHoo"||this.Projection == "YAHOO")
  	{
  		var x = Math.round(this.width / 2 + (parseFloat(lng) - yx.x()) * this.mapsize / (dEarthLength / Math.pow(2, this.zoomLevel-1)));
			var y = Math.round(this.height / 2 - (parseFloat(lat) - yx.y()) * this.mapsize / (dEarthLength / Math.pow(2, this.zoomLevel-1)));
  		
  	}
  	else
  	{
			var x = Math.round(this.width / 2 + (parseFloat(lng) - yx.x()) * this.mapsize / (dEarthLength / Math.pow(2, this.zoomLevel)));
			var y = Math.round(this.height / 2 - (parseFloat(lat) - yx.y()) * this.mapsize / (dEarthLength / Math.pow(2, this.zoomLevel)));
		}
    return new GSPoint(x, y)
	},
  zoomIn: function()
  {
    var zoomPara = this.zoomLevel + 1;
    for (i = 0; i < this.LevelIgnore.length; i++)
    {
      if (zoomPara == this.LevelIgnore[i])
      {
				zoomPara = zoomPara + 1;
      }
    }
    this.zoomTo(Math.min(this.BiggestZoom, (parseInt(zoomPara))))
  },

  zoomOut: function()
  {
    var zoomPara = this.zoomLevel - 1;
    for (i = this.LevelIgnore.length; i > 0; i--)
    {
      if (zoomPara == this.LevelIgnore[i - 1])
      {
				zoomPara = zoomPara - 1;
      }
    }
    this.zoomTo(Math.max(this.LeastZoom, (parseInt(zoomPara))))
  },

  zoomTo: function(ZOOM, x, y)
  {
    if (IE)
    {
      if (this.time != null)
      {
				clearTimeout(this.time)
      };
      this.time = null;
      if (typeof ZOOM != "undefined")
      {
        this.Zoom = parseInt(ZOOM);
        if (typeof x == "undefined")
        {
					this.offsetx = 0
        }
        else
      	{
          this.offsetx = parseInt(x)
        }
        if (typeof y == "undefined")
        {
					this.offsety = 0
        }
        else
      	{
          this.offsety = parseInt(y)
        }
        this.time = getTimeout(this, this.zoomTo, 100)
      }
      else
    	{
        if (this.Zoom > this.getZoom())
        {
          if (this.bzoom <= (this.Zoom - this.zoomnum) && this.bcontZoom)
          {
            if (this.bzoom == -1)
            {
							this.bzoom = this.getZoom() + this.zoomnum
            }
            else
          	{
              this.bzoom += this.zoomnum
            }
            var zoomdis = (this.bzoom - this.getZoom());
            this.OYos(this.bzoom, -2 * this.offsetx * zoomdis, 2 * this.offsety * zoomdis);
            this.time = getTimeout(this, this.zoomTo, 20)
          }
          else
        	{
            this.bzoom = -1;
            var latlng=this.ScreenToLatlng(this.offsetx,(-this.offsety),this.zoomLevel);
						this.ycenter=latlng.lat();
						this.xcenter=latlng.lng();
            this.setZoom(this.Zoom);
          }
        }
        else if (this.Zoom < this.getZoom())
      	{
          if ((this.bzoom == -1 || this.bzoom >= (this.Zoom + this.AY)) && this.bcontZoom)
          {
            if (this.bzoom == -1)
            {
							this.bzoom = this.getZoom() - this.zoomnum
            }
            else
          	{
              this.bzoom -= this.zoomnum
            }
            var zoomdis = Math.abs(this.bzoom - this.getZoom());
            this.OYos(this.bzoom, 2 * this.offsetx * zoomdis, 2 * this.offsety * zoomdis);
            this.time = getTimeout(this, this.zoomTo, 20)
          }
          else
        	{
            this.bzoom = -1;
           	var latlng=this.ScreenToLatlng(this.offsetx,(-this.offsety),this.zoomLevel);
						this.ycenter=latlng.lat();
						this.xcenter=latlng.lng();
            this.setZoom(this.Zoom);
          }
        }
      }
    }
    else
    {
			this.setZoom(ZOOM)
    }
  },
  addOverlay: function(obj)
  {
    if (typeof obj == "object")
    {
      if (this.u5[obj.id])
      {
				return
      }
      obj.qc(this, obj.id);
      this.u5[obj.id] = obj
    }
  },
  removeOverlay: function(obj)
  {
    if (typeof obj == "object" && this.u5[obj.id])
    {
      this.u5[obj.id].remove();
      this.u5[obj.id] = null
    }
  },
  removeOverlayByObjID: function(objID)     //通过对象ID来删除添加到地图上的元素对象 wgf 090917
  {
    if ( objID !=null && this.u5[objID])
    {
      this.u5[objID].remove();
      this.u5[objID] = null;
    }
  },
  addControl: function(obj)
  {
    if (typeof obj == "object")
    {
      if (this.gc[obj.id])
      {
				return
      }
      obj.qc(this);
      this.gc[obj.id] = obj;
    }
  },
  removeControl: function(obj)
  {
    if (typeof obj == "object" && this.gc[obj.id])
    {
      this.gc[obj.id].remove();
      this.gc[obj.id] = null
    }
  },

  mousedownFun: function(EVT)
  {
    var event = window.event;
    if (this.holder.setCapture)
    {
			this.holder.setCapture();
    }
    else if (window.captureEvents)
  	{
      window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
    }
    var xclient = parseInt((IE) ? event.clientX : EVT.clientX)+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
    var yclient = parseInt((IE) ? event.clientY : EVT.clientY)+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
    this.eventID = (IE) ? event.srcElement.id : EVT.target.id;
    this.downx = xclient - this.left;
    this.downy = yclient - this.top;
    if (this.eventID.indexOf("ctrl") >= 0 && this.controlBar)
    {
      this.controlBar.onmousedown(EVT);
      return
    }
    if (this.eventID.indexOf("toogoovwinfo") >= 0 && this.ovw != null)
    {
      this.ovw.mousedownfun(EVT);
      return
    }
    if (IE && this.bmove && this.eventID.indexOf("toogomapinfo") >= 0)
    {
      this.bmousedown = true;
      this.holder.style.cursor = "move"
    }
    else if (!IE && this.bmove && this.eventID != null)
  	{
      this.bmousedown = true;
      this.holder.style.cursor = "move"
    }
  },

  mousemoveFun: function(EVT)
  {
    var event = window.event;
    var xclient = parseInt((IE) ? event.clientX : EVT.clientX)+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
    var yclient = parseInt((IE) ? event.clientY : EVT.clientY)+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
    this.movex = xclient - this.left;
    this.movey = yclient - this.top;
    var latlng=this.ScreenToLatlng(this.movex,this.movey);
		this.latMove=latlng.lat();
		this.lonMove=latlng.lng();
		if (this.controlBar)
    {
      if (this.controlBar.onmousemove(EVT))
      {
				return
      }
    }
    if (this.bmove && this.bmousedown)
    {
      this.bmousemove = true;
      this.holder.style.cursor = "move";
      this.mapContainer.moveTo(this.movex - this.downx, this.movey - this.downy);
    }
    else if (this.bmeasure || this.bPolyline || this.bPolygon || this.bParallel || this.bpoint || this.bSideway || this.bOverheadRoad)
  	{
      this.bmove = false;
      this.holder.style.cursor = "default";
      showMouseTipBox((this.movex), (this.movey), "请双击结束", this.holder);
      if (this.bmeasure || this.bPolyline)
      {
        if (this.Polyline != null)
        {
          this.linemove.pts[0] = this.Polyline.pts[this.Polyline.pts.length - 1];
          this.linemove.pts[1] = new GSLatLng(this.latMove, this.lonMove);
          this.linemove.S85()
        }
      }
      else if (this.bPolygon)
      {
        if (this.Polygon != null)
        {
          this.linemove.pts[0] = this.Polygon.pts[this.Polygon.pts.length - 1];
          this.linemove.pts[1] = new GSLatLng(this.latMove, this.lonMove);
          this.linemove.S85()
        }
      }
      else if (this.bParallel)
    	{
        if (this.Parallel != null)
        {
          if (this.i != 1)
          {
            this.linemove.pts[0] = this.Parallel.pts[this.Parallel.pts.length - 1];
            this.linemove.pts[1] = new GSLatLng(this.latMove, this.lonMove)
          }
          else
        	{
            this.linemove.pts[0] = this.Parallel.pts[this.Parallel.pts.length - 2];
            this.linemove.pts[1] = this.Parallel.pts[this.Parallel.pts.length - 1];
            this.linemove.pts[2] = new GSLatLng(this.latMove, this.lonMove)
          }
          this.linemove.S85()
        }
      }
      else if (this.bSideway)
    	{
        if (this.Sideway != null)
        {
          if (this.j != 1)
          {
            this.linemove.pts[0] = this.Sideway.pts[this.Sideway.pts.length - 1];
            this.linemove.pts[1] = new GSLatLng(this.latMove, this.lonMove)
          }
          else
        	{
            this.linemove.pts[0] = this.Sideway.pts[this.Sideway.pts.length - 2];
            this.linemove.pts[1] = this.Sideway.pts[this.Sideway.pts.length - 1];
            this.linemove.pts[2] = new GSLatLng(this.latMove, this.lonMove)
          }
					this.linemove.S85()
        }
      }
      else if (this.bOverheadRoad)
    	{
        if (this.OverheadRoad != null)
        {
          if (this.j != 1)
          {
            this.linemove.pts[0] = this.OverheadRoad.pts[this.OverheadRoad.pts.length - 1];
            this.linemove.pts[1] = new GSLatLng(this.latMove, this.lonMove)
          }
          else
        	{
            this.linemove.pts[0] = this.OverheadRoad.pts[this.OverheadRoad.pts.length - 2];
            this.linemove.pts[1] = this.OverheadRoad.pts[this.OverheadRoad.pts.length - 1];
            this.linemove.pts[2] = new GSLatLng(this.latMove, this.lonMove)
          }
          this.linemove.S85()
        }
      }
      else if (this.bpoint)
    	{
        removeTipbox();
        this.Point.icon.paint(this, this.movex, this.movey)
      }
    }
    else
  	{
      removeTipbox()
    }
  },

  mouseupFun: function(EVT)
  {
    var event = window.event;
    if (this.holder.releaseCapture)
    {
			this.holder.releaseCapture();
    }
    else if (window.captureEvents)
  	{
      window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
    }

    var xclient = parseInt((IE) ? event.clientX : EVT.clientX)+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
    var yclient = parseInt((IE) ? event.clientY : EVT.clientY)+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);

    this.upx = xclient - this.left;
    this.upy = yclient - this.top;
    this.holder.style.cursor = "default";
    if (this.controlBar)
    {
			this.controlBar.onmouseup(EVT);
    }
    if (this.bmousedown && this.bmousemove)
    {
    	var latlng=this.ScreenToLatlng((this.downx-this.upx),(this.downy-this.upy),this.zoomLevel);
			this.ycenter=latlng.lat();
			this.xcenter=latlng.lng();
      this.setZoom(this.zoomLevel);
    }
    this.bmousedown = false;
    this.bmousemove = false;
  },

  /*响应鼠标单击函数*/
  clickFun: function(EVT)
  {
    var event = window.event;
    var eventID = (IE) ? event.srcElement.id : EVT.target.id;
    var xclient = parseInt((IE) ? event.clientX : EVT.clientX)+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
    var yclient = parseInt((IE) ? event.clientY : EVT.clientY)+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
    this.xClick = xclient - this.left;
    this.yClick = yclient - this.top;
    if (this.eventID != null && this.eventID.indexOf("ctrl") >= 0)
			return false;
    //当鼠标在右下角logo标志时打开该链接
    if (this.blogo && this.layerLogo != null && this.layerLogo.inRect(this.xClick, this.yClick))
    {
      window.open("http://www.mapdiy.com");
      return
    }

    if (this.eventID != null && this.eventID.toString().indexOf("toogoovwinfo") >= 0)
			return false;
    if (this.bothInRect())
    {
      if (this.eventID != null && this.eventID.indexOf("ctrl") >= 0)
				return false;
			if (this.eventID != null && this.eventID.indexOf("tool") >= 0)
				return false;
			var latlng=this.ScreenToLatlng(this.xClick,this.yClick);
			this.latClick=latlng.lat();
			this.lonClick=latlng.lng();
			if (this.bPolyline || this.bPolygon || this.bmeasure || this.bpoint || this.bParallel || this.bSideway ||this.bOverheadRoad)
      {
        this.bdbclick = false
        if (this.bPolyline || this.bmeasure)
        {
          if (this.Polyline == null && this.eventID.indexOf("toogomapinfo") >= 0)
          {
            this.Polyline = new GSPolyline([new GSLatLng(this.latClick, this.lonClick)], "#FF0000", (this.bPolyline ? 3 : 2));
            this.linemove = new GSPolyline([new GSLatLng(this.latClick, this.lonClick)], "#FF0000", (this.bPolyline ? 3 : 2));
            if (this.bPolyline)
							this.lines.push({ Polyline: this.Polyline, flag: 1 });
            this.addOverlay(this.Polyline);
            this.linemove.qc(this);
          }
          else if (this.Polyline != null)
        	{
            this.Polyline.pts[this.Polyline.pts.length] = new GSLatLng(this.latClick, this.lonClick);
            this.linemove.pts[0] = new GSLatLng(this.latClick, this.lonClick);
            this.Polyline.S85();
            this.linemove.S85()
          }
				}
        else if (this.bPolygon)
      	{
          if (this.Polygon == null && this.eventID.indexOf("toogomapinfo") >= 0)
          {
            this.Polygon = new GSPolygon([new GSLatLng(this.latClick, this.lonClick)], "#FF0000", 2);
            this.linemove = new GSPolygon([new GSLatLng(this.latClick, this.lonClick)], "#FF0000", 2);
            this.gons.push({ Polygon: this.Polygon, flag: 1 });
            this.addOverlay(this.Polygon);
            this.linemove.qc(this);
          }
          else if (this.Polygon != null)
        	{
            this.Polygon.pts[this.Polygon.pts.length] = new GSLatLng(this.latClick, this.lonClick);
            this.linemove.pts[0] = new GSLatLng(this.latClick, this.lonClick);
            this.Polygon.S85();
            this.linemove.S85()
          }
        }
        else if (this.bpoint)
      	{
          this.bpoint = false
          this.bmove = true;
          this.bdbclick = true;
          if (this.toolBar)
						this.toolBar.dbclick();
          this.Point.pt = new GSLatLng(this.latClick, this.lonClick);
          this.Point.icon.paint(this, this.xClick, this.yClick);
          this.pots.push({ Point: this.Point, flag: 1 })
	        this.bEditpoint=true;
				 	this.bEditline=true;
	    		this.bEditgon=true;
	  			this.bEditParallel=true;
	        this.bEditSideway=true;
	  			this.bEditOverheadRoad=true;
        }
        else if (this.bParallel)
      	{
          this.i = 0
          if (this.Parallel == null && this.eventID.indexOf("toogomapinfo") >= 0)
          {
            this.Parallel = new GSParallel([new GSLatLng(this.latClick, this.lonClick)]);
            this.linemove = new GSParallel([new GSLatLng(this.latClick, this.lonClick)]);
            this.parallels.push({ Parallel: this.Parallel, flag: 1 })
            this.addOverlay(this.Parallel);
            this.linemove.qc(this);
          }
          else if (this.Parallel != null)
        	{
            this.i = 1;
            this.Parallel.pts[this.Parallel.pts.length] = new GSLatLng(this.latClick, this.lonClick);
            this.linemove.pts[0] = new GSLatLng(this.latClick, this.lonClick);
            this.linemove.S85()
            this.Parallel.S85();
          }
        }
        else if (this.bSideway)
      	{
          this.j = 0
          if (this.Sideway == null && this.eventID.indexOf("toogomapinfo") >= 0)
          {
            this.Sideway = new GSSideway([new GSLatLng(this.latClick, this.lonClick)]);
            this.linemove = new GSSideway([new GSLatLng(this.latClick, this.lonClick)]);
            this.sideways.push({ Sideway: this.Sideway, flag: 1 })
            this.addOverlay(this.Sideway);
            this.linemove.qc(this);
          }
          else if (this.Sideway != null)
        	{
            this.j = 1;
            this.Sideway.pts[this.Sideway.pts.length] = new GSLatLng(this.latClick, this.lonClick);
            this.linemove.pts[0] = new GSLatLng(this.latClick, this.lonClick);
            this.linemove.S85()
            this.Sideway.S85();
          }
        }
        else if (this.bOverheadRoad)
      	{
          this.j = 0
          if (this.OverheadRoad == null && this.eventID.indexOf("toogomapinfo") >= 0)
          {
            this.OverheadRoad = new GSOverheadRoad([new GSLatLng(this.latClick, this.lonClick)]);
            this.linemove = new GSOverheadRoad([new GSLatLng(this.latClick, this.lonClick)]);
            this.overheadroad.push({ OverheadRoad: this.OverheadRoad, flag: 1 })
            this.addOverlay(this.OverheadRoad);
            this.linemove.qc(this);
          }
          else if (this.OverheadRoad != null)
        	{
            this.j = 1;
            this.OverheadRoad.pts[this.OverheadRoad.pts.length] = new GSLatLng(this.latClick, this.lonClick);
            this.linemove.pts[0] = new GSLatLng(this.latClick, this.lonClick);
            this.linemove.S85()
            this.OverheadRoad.S85();
          }
        }
      }
    }
  },
  /*响应鼠标双击函数*/
  dblclickFun: function(EVT)
  {
    var event = window.event;
    var eventID = (IE) ? event.srcElement.id : EVT.target.id;
    var xclient = parseInt((IE) ? event.clientX : EVT.clientX) - this.left+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
    var yclient = parseInt((IE) ? event.clientY : EVT.clientY) - this.top+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);

    if (this.bdbclick && this.bothInRect() && this.eventID.toString().indexOf("toogoovwinfo") < 0 && this.eventID.toString().indexOf("ctrl") < 0)
    {
      this.holder.style.cursor = "default";
      var xDifference = -(this.width / 2 - xclient);
      var yDifference = (this.height / 2 - yclient);
      var zoomPara = Math.min(this.BiggestZoom, this.zoomLevel + 1);
      if (this.zoomLevel < this.BiggestZoom)
      {
        if (IE)
        {
          for (i = 0; i < this.LevelIgnore.length; i++)
          {
            if (zoomPara == this.LevelIgnore[i])
            {
							zoomPara = zoomPara + 1;
            }
          }
          this.zoomTo(parseInt(zoomPara), xDifference, yDifference);
        }
        else
      	{
      		var latlng=this.ScreenToLatlng(xDifference,-yDifference,this.zoomLevel);
					this.ycenter=latlng.lat();
					this.xcenter=latlng.lng();
          this.setZoom(this.zoomLevel + 1);
        }
      }
    }
    if ((this.bmeasure || this.bPolyline || this.bPolygon || this.bParallel || this.bSideway ||this.bOverheadRoad) && this.bothInRect())
    {
      removeTipbox();
      var totalDistance = 0;
      this.bmove = true;
      this.bdbclick = true;
      if (this.toolBar)
				this.toolBar.dbclick();
      if (this.Polyline)
      {
        for (var i = 1; i < this.Polyline.pts.length; i++)
        {
          var latitude = this.Polyline.pts[i].lat() - this.Polyline.pts[i - 1].lat();
          var longitude = this.Polyline.pts[i].lng() - this.Polyline.pts[i - 1].lng();
          totalDistance += this.getSphereDis(new GSLatLng(this.Polyline.pts[i].lat(), this.Polyline.pts[i].lng()), new GSLatLng(this.Polyline.pts[i - 1].lat(), this.Polyline.pts[i - 1].lng()));
        }
        if (this.bmeasure)
        {
          totalDistance = Math.round(totalDistance / 100);
          if (totalDistance.toString() == Number.NaN.toString())
						totalDistance = 0;
          distanceBox(this.width / 2 + this.left, this.height / 2 + this.top, "总距离:" + (parseInt(totalDistance) / 10) + "公里");
          this.layerDrawMap.objDiv.removeChild(this.Polyline.elemDiv1);
          this.removeOverlay(this.Polyline)
        }
      }
      else if (this.Polygon)
    	{
        if(this.Polygon.pts.length>2)
        {   
          this.Polygon.pts[this.Polygon.pts.length] = this.Polygon.pts[0];
          this.Polygon.S85();
          this.Polygon.elemPolygon.path.value = this.Polygon.elemPolygon.path.value.replace(" e", "") + "x e";
        }
        else
      	{
          this.layerDrawMap.objDiv.removeChild(this.Polygon.elemDiv1);
          this.removeOverlay(this.Polygon)
        }
      }

      if (IE && this.linemove && this.linemove.elemDiv1.parentNode == this.layerDrawMap.objDiv)
      {
        this.layerDrawMap.objDiv.removeChild(this.linemove.elemDiv1)
        this.linemove.elemDiv1 = null
        if (this.bParallel || this.bSideway)
        {
          this.layerDrawMap.objDiv.removeChild(this.linemove.elemDiv)
          this.linemove.elemDiv = null
        }
        if(this.bOverheadRoad)
        {
        	this.layerDrawMap.objDiv.removeChild(this.linemove.elemDiv2)
          this.linemove.elemDiv2 = null
          this.layerDrawMap.objDiv.removeChild(this.linemove.elemDiv3)
          this.linemove.elemDiv3 = null
        }
      }
	    this.Polyline = null;
	    this.Polygon = null;
	    this.Parallel = null;
	    this.linemove = null;
	    this.Sideway = null;
	    this.OverheadRoad=null;
	    this.bEditpoint=true;
	    this.bEditline=true;
			this.bEditgon=true;
			this.bEditParallel=true;
	    this.bEditSideway=true;
			this.bEditOverheadRoad=true;
	    this.bmeasure = false;
	    this.bPolygon = false;
	    this.bPolyline = false;
	    this.bParallel = false;
	    this.bSideway = false;
	    this.bOverheadRoad = false
    }
  },
  /*响应鼠标滚动函数*/
  mousewheelFun: function(EVT)
  {
    var event = window.event;
    if (event != null && this.bwheel)
    {
      hidden();
      var tK = 0
      tK += event.wheelDelta > 0 ? 1 : -1;
      var zoom = parseInt(this.getZoom());
      if (zoom < this.LeastZoom || zoom > this.BiggestZoom)
				return;
      else
    	{
        if (tK > 0)
        {
					this.zoomIn(this.getZoom());
        }
        else
      	{
          this.zoomOut(this.getZoom());
        }
      }
    }
  },
  /*显示或隐藏缩放工具条,true为显示,false为隐藏*/
  showControl: function(bflag)
  {
    this.bControl = bflag;
    if (this.bControl)
    {
      if (this.controlBar)
				this.controlBar.show()
    }
    else
  	{
      if (this.controlBar)
				this.controlBar.hide()
    }
  },
  /*显示或隐藏比例框,true为显示,false为隐藏*/
  showScale: function(bflag)
  {
    this.bscale = bflag;
    if (this.bscale)
    {
			this.layerScale.show()
    }
    else
    {
			this.layerScale.hide()
    }
  },
  /*显示或隐藏LOGO框,true为显示,false为隐藏*/
  showLogo: function(bflag)
  {
    this.blogo = bflag;
    if (this.blogo)
    {
      if (this.layerLogo)
				this.layerLogo.show()
    }
    else
  	{
			if (this.layerLogo)
				this.layerLogo.hide()
    }
  },
  /*显示或隐藏导航框,true为显示,false为隐藏*/
  showOverview: function(bflag)
  {
    if (bflag)
    {
      if (this.ovw)
				this.ovw.open()
    }
    else
  	{
    	if (this.ovw)
				this.ovw.close()
    }
  }
};

/*启用地图拖拽（默认情况下启用）*/
GSMap.prototype.enableDragging = function()
{
	this.bmove = true
};
/*禁用地图拖拽*/
GSMap.prototype.disableDragging = function()
{
	this.bmove = false
};
/*启用双击缩放地图（默认情况下禁用）*/
GSMap.prototype.enableDoubleClickZoom = function()
{
	this.bdbclick = true
};
/*禁用双击缩放地图*/
GSMap.prototype.disableDoubleClickZoom = function()
{
	this.bdbclick = false
};
/*当且仅当启用了双击缩放地图时，返回 true*/
GSMap.prototype.doubleClickZoomEnabled = function()
{
  if (!this.bmove && this.bdbclick)
		return true
  else
		return false
};
/*启用选择浏览器的连续平滑缩放*/
GSMap.prototype.enableContinuousZoom = function()
{
	this.bcontZoom = true
};
/*禁用连续平滑缩放*/
GSMap.prototype.disableContinuousZoom = function()
{
	this.bcontZoom = false
};
/*如果启用了连续平滑缩放，则返回 true。*/
GSMap.prototype.continuousZoomEnabled = function()
{
  if (this.bcontZoom)
		return true
  else
		return false
};
/*启用使用鼠标滚轮缩放*/
GSMap.prototype.enableScrollWheelZoom = function()
{
	this.bwheel = true
};
/*禁用使用鼠标滚轮缩放*/
GSMap.prototype.disableScrollWheelZoom = function()
{
	this.bwheel = false
};
/*返回一个布尔值，表示是否启用了鼠标滚轮缩放*/
GSMap.prototype.scrollWheelZoomEnabled = function()
{
  if (this.bwheel)
		return true
  else
		return false
};

function unload()
{
  if (this.mapContainer)
  {
    this.mapContainer.moveTo(0, 0);
    this.mapContainer.clear();
  }
  if (this.layerMap)
  {
    this.layerMap.moveTo(0, 0);
    this.layerMap.clear();
  }
  if (this.layerScale)
		this.layerScale.clear();
  if (this.layerLogo)
		this.layerLogo.clear();
  document.onmouseout = null;
  document.onmouseup = null;
  document.onmousedown = null;
  document.onclick = null;
  document.onmousemove = null;
  document.ondrag = null;
  document.ondragend = null;
  document.ondragstart = null;
  document.onfocus = null;
  document.onblur = null;
};
var ControlBarSpace=9;
var uS = 15;
var pF = 2;
var uU = 8;
var oww = 210;
var nodeflag = null;
var owh = 140;
var tagheight = 0
var tagwidth = 0
var transparencyLevel = 60;
var ovz = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];

//作为注销事件的句柄
function GSEventListener()
{
  this.eventType; //事件的类型
  this.marker; //GSMarker对象
  this.handler; //函数的句柄
}

function GSParallel(pts, strokecolor, strokeweight, strokeopacity, fillColor, fillOpacity, roadwidth)
{
  this.id = new Date().getTime() + "" + parseInt(Math.random() * 10000) + "GSParallel";
  this.wz = function(id)
  {
		this.id = id;
	};
  this.pts = pts;
  this.strokeColor = (strokecolor == null) ? "#A3876A" : strokecolor;
  this.strokeWeight = (strokeweight == null || strokeweight == 0) ? 1 : strokeweight;
  this.strokeOpacity = (strokeopacity == null || strokeopacity == 0) ? 100 : strokeopacity;
  this.fillColor = (fillColor == null) ? "#FFF3C2" : fillColor;
  this.fillOpacity = (fillOpacity == null || fillOpacity == 0) ? 100 : fillOpacity;
  this.roadwidth = (roadwidth == null || roadwidth == 0) ? 5 : roadwidth;
  this.qo = false;
  this.ls = false;
  this.Polylineflag = null;
  this.maplet = null;
  this.bEditable = false;
  this.ao = new Array();
  this.setEditable = function(cs)
  {
    this.bEditable = (typeof cs == "undefined") ? false : cs;
    if (this.maplet != null)
    {
			this.S85()
    }
  };
  this.qc = function(maplet)
  {
    this.maplet = maplet;
    this.ao["mouseover"] = GSEvent.addListener(this.maplet.holder, "mouseover", this, this.mouseoverfun);
    this.ao["mousedown"] = GSEvent.addListener(this.maplet.holder, "mousedown", this, this.mousedownfun);
    this.ao["mousemove"] = GSEvent.addListener(this.maplet.holder, "mousemove", this, this.mousemovefun);
    this.ao["mouseup"] = GSEvent.addListener(this.maplet.holder, "mouseup", this, this.mouseupfun);

    if (typeof this.maplet.holder != "undefined")
    {
			this.paint()
    }
  }
  this.paint = function()
  {
    if (typeof this.elemDiv1 == "undefined")
    {
      this.elemDiv = document.createElement("div");
      this.elemDiv.unselectable = "on";
      this.elemDiv.style.zIndex = 10;
      this.elemDiv.style.position = "absolute";
      this.elemDiv1 = document.createElement("div");
      this.elemDiv1.unselectable = "on";
      this.elemDiv1.style.zIndex = 100;
      this.elemDiv1.style.position = "absolute";
      this.elemMidline = document.createElement("v:polyline");
      this.elemMidline.unselectable = "on";
      this.elemMidline.strokecolor = this.strokeColor;
      this.elemMidline.strokeweight = this.strokeWeight + 'pt';
      this.elemMidline.fill = "false";
      this.elemMidline.filled = "false";
      this.elemUpline = document.createElement("v:polyline");
      this.elemUpline.unselectable = "on";
      this.elemUpline.strokecolor = this.strokeColor;
      this.elemUpline.strokeweight = this.strokeWeight + 'pt';
      this.elemUpline.fill = "false";
      this.elemUpline.filled = "false";
      this.elemDownline = document.createElement("v:polyline");
      this.elemDownline.unselectable = "on";
      this.elemDownline.strokecolor = this.strokeColor;
      this.elemDownline.strokeweight = this.strokeWeight + 'pt';
      this.elemDownline.fill = "false";
      this.elemDownline.filled = "false";
      this.elemPolygon = document.createElement("v:shape");
      this.elemPolygon.unselectable = "on";
      this.elemPolygon.stroked = "false";
      this.elemPolygon.filled = "true";
      this.elemPolygon.style.width = 1;
      this.elemPolygon.style.height = 1;
      this.elemPolygon.style.top = "0px";
      this.elemPolygon.style.left = "0px";
      this.elemPolygon.style.position = "absolute";
      this.elemPolygon.coordsize = '1,1';
      this.elemStroke = document.createElement("v:stroke");
      this.elemStroke.opacity = (this.strokeOpacity / 100);
      this.elemStroke.joinstyle = "round";
      this.elemStroke.endcap = "round";
      this.elemStroke.fill = "false";
      this.elemPolygonfill = document.createElement("v:fill");
      this.elemPolygonfill.unselectable = "on";
      this.elemPolygonfill.color = this.fillColor;
      this.elemPolygonfill.opacity = (this.fillOpacity / 100);
      this.elemUpline.appendChild(this.elemStroke);
      this.elemDownline.appendChild(this.elemStroke);
      this.elemPolygon.appendChild(this.elemPolygonfill);
      this.elemDiv1.appendChild(this.elemMidline);
      this.elemDiv.appendChild(this.elemUpline);
      this.elemDiv.appendChild(this.elemDownline);
      this.elemDiv1.appendChild(this.elemPolygon)
    }
    this.S85();
    this.elemDiv.style.visibility = "visible";
    this.elemDiv1.style.visibility = "visible";
    if (this.maplet.layerDrawMap.objDiv != null)
    {
      this.maplet.layerDrawMap.objDiv.appendChild(this.elemDiv)
      this.maplet.layerDrawMap.objDiv.appendChild(this.elemDiv1)
    }
	};
	this.S85 = function()
	{
	  this.NodeLayer = document.getElementById(this.id + "vNodeLayer");
	  if ((this.bEditable||this.maplet.bParallel) && this.NodeLayer == null)
	  {
	    this.NodeLayer = document.createElement("div");
	    this.NodeLayer.vb = this;
	    this.NodeLayer.id = this.id + "vNodeLayer";
	    this.NodeLayer.style.position = "absolute";
	    this.NodeLayer.unselectable = "on";
	    this.NodeLayer.style.display = "none";
	    this.NodeLayer.style.zIndex = 1;
	    this.NodeLayer.style.cursor = (IE) ? "hand" : "pointer";
	    this.elemDiv1.appendChild(this.NodeLayer)
	  }
	  this.pu = new Array();
	  this.xPointValue = new Array();
	  this.yPointValue = new Array();
	  this.xUpPointValue = new Array();
	  this.yUpPointValue = new Array();
	  this.xDownPointValue = new Array();
	  this.yDownPointValue = new Array();
	  var measCount = 0;
	  if (this.pts == null || this.pts.length < 2)
			return;
	  for (var i = 0; i < this.pts.length; i += 1)
	  {
	    this.pu[measCount] = i;
	    if (this.pts[i].lng().toString() != Number.NaN.toString()&&this.pts[i].lat().toString() != Number.NaN.toString())
    	{
	      var xy=this.maplet.LatlngToScreen(parseFloat(this.pts[i].lng()),parseFloat(this.pts[i].lat()));
				this.xPointValue[measCount] =xy.x();
				this.yPointValue[measCount] =xy.y()
			}
			else
				return
	    if (measCount == 1)
	    {
	      var upStartlnglat = this.maplet.getStartUpPot(this.xPointValue[0], this.yPointValue[0], this.xPointValue[1] + 2, this.yPointValue[1] + 2, this.roadwidth);
	      if (upStartlnglat.lng().toString() != Number.NaN.toString()&&upStartlnglat.lat().toString() != Number.NaN.toString())
    		{
		      var xy=this.maplet.LatlngToScreen(parseFloat(upStartlnglat.lng()),parseFloat(upStartlnglat.lat()));
					this.xUpPointValue[0] =xy.x();
					this.yUpPointValue[0] =xy.y()
				}
	      var downStartlnglat = this.maplet.getStartDownPot(this.xPointValue[0], this.yPointValue[0], this.xPointValue[1] + 2, this.yPointValue[1] + 2, this.roadwidth);
	      if (downStartlnglat.lng().toString() != Number.NaN.toString()&&downStartlnglat.lat().toString() != Number.NaN.toString())
    		{
		      var xy=this.maplet.LatlngToScreen(parseFloat(downStartlnglat.lng()),parseFloat(downStartlnglat.lat()));
					this.xDownPointValue[0] =xy.x();
					this.yDownPointValue[0] =xy.y()
				}
	    }
	    if (measCount >= 1)
	    {
	      var upMovelnglat = this.maplet.getMoveUpPot(this.xPointValue[measCount - 1], this.yPointValue[measCount - 1], this.xPointValue[measCount] + 1, this.yPointValue[measCount] + 1, this.roadwidth);
	      if (upMovelnglat.lng().toString() != Number.NaN.toString()&&upMovelnglat.lat().toString() != Number.NaN.toString())
    		{
		      var xy=this.maplet.LatlngToScreen(parseFloat(upMovelnglat.lng()),parseFloat(upMovelnglat.lat()));
					this.xUpPointValue[measCount] =xy.x();
					this.yUpPointValue[measCount] =xy.y()
				}
	      var downMovelnglat = this.maplet.getMoveDownPot(this.xPointValue[measCount - 1], this.yPointValue[measCount - 1], this.xPointValue[measCount] + 1, this.yPointValue[measCount] + 1, this.roadwidth);
	      if (downMovelnglat.lng().toString() != Number.NaN.toString()&&downMovelnglat.lat().toString() != Number.NaN.toString())
    		{
		      var xy=this.maplet.LatlngToScreen(parseFloat(downMovelnglat.lng()),parseFloat(downMovelnglat.lat()));
					this.xDownPointValue[measCount] =xy.x();
					this.yDownPointValue[measCount] =xy.y()
				}
	    }
	    if (measCount > 1)
	    {
	      var miduplnglat = this.maplet.getMidPot(this.xPointValue[measCount - 2], this.yPointValue[measCount - 2], this.xPointValue[measCount - 1], this.yPointValue[measCount - 1], this.xPointValue[measCount], this.yPointValue[measCount], this.xUpPointValue[measCount - 2], this.yUpPointValue[measCount - 2], this.xUpPointValue[measCount], this.yUpPointValue[measCount]);
	      if (miduplnglat.lng().toString() != Number.NaN.toString()&&miduplnglat.lat().toString() != Number.NaN.toString())
    		{
		      var xy=this.maplet.LatlngToScreen(parseFloat(miduplnglat.lng()),parseFloat(miduplnglat.lat()));
					this.xUpPointValue[measCount-1] =xy.x();
					this.yUpPointValue[measCount-1] =xy.y()
				}
	      var middownlnglat = this.maplet.getMidPot(this.xPointValue[measCount - 2], this.yPointValue[measCount - 2], this.xPointValue[measCount - 1], this.yPointValue[measCount - 1], this.xPointValue[measCount], this.yPointValue[measCount], this.xDownPointValue[measCount - 2], this.yDownPointValue[measCount - 2], this.xDownPointValue[measCount], this.yDownPointValue[measCount]);
	      if (middownlnglat.lng().toString() != Number.NaN.toString()&&middownlnglat.lat().toString() != Number.NaN.toString())
    		{
		      var xy=this.maplet.LatlngToScreen(parseFloat(middownlnglat.lng()),parseFloat(middownlnglat.lat()));
					this.xDownPointValue[measCount-1] =xy.x();
					this.yDownPointValue[measCount-1] =xy.y()
				}
//				var atg1=Math.atan(-(this.yPointValue[measCount-2]-this.yPointValue[measCount-1])/(this.xPointValue[measCount-2]-this.xPointValue[measCount-1]))
//				var atg2=Math.atan(-(this.yPointValue[measCount]-this.yPointValue[measCount-1])/(this.xPointValue[measCount]-this.xPointValue[measCount-1]))
//				if((atg1*180/PI-atg2*180/PI)>-4&&(atg1*180/PI-atg2*180/PI)<5)
//					return
	    }
	    if (measCount > 0 && (Math.abs(this.xPointValue[measCount] - this.xPointValue[measCount - 1]) + Math.abs(this.yPointValue[measCount] - this.yPointValue[measCount - 1])) > 10)
	    {
				measCount++
	    }
	    if (measCount == 0)
				measCount++
	  }
	  var UppointValue = '';
	  var DownpointValue = '';
	  var GonpointValue = '';
	
	  for (var i = 0; i < this.xPointValue.length; i++)
	  {
	    if (this.NodeLayer && !this.maplet.bmeasure)
	    {
	      var sidenode = document.getElementById(this.id + "_node_" + this.pu[i]);
	      if (sidenode == null)
	      {
	        sidenode = new Image();
	        sidenode.id = this.id + "_node_" + this.pu[i];
	        sidenode.num = i;
	        sidenode.count = this.pu[i];
	        sidenode.src = "images/toogo/node.gif";
	        sidenode.unselectable = "on";
	        sidenode.alt = "拖动以移动此点";
	        sidenode.title = "拖动以移动此点";
	        sidenode.style.position = "absolute";
	        sidenode.style.filter = "alpha(opacity=100);";
	        sidenode.style.MozOpacity = 1.0;
	        sidenode.style.opacity = 1.0;
	        sidenode.onmousedown = function()
	        {
						return false
	        };
	      }
	      sidenode.style.left = (parseInt(this.xPointValue[i]) - 5) + "px";
	      sidenode.style.top = (parseInt(this.yPointValue[i]) - 5) + "px";
	      this.NodeLayer.appendChild(sidenode);
	      if (i > 0)
	      {
	        var midnode = document.getElementById(this.id + "_midnode_" + this.pu[i]);
	        if (midnode == null)
	        {
	          midnode = new Image();
	          midnode.id = this.id + "_midnode_" + this.pu[i];
	          midnode.num = i;
	          midnode.count = this.pu[i];
	          midnode.unselectable = "on";
	          midnode.src = "images/toogo/node.gif";
	          midnode.alt = "拖动以移动此点";
	          midnode.title = "拖动以移动此点";
	          midnode.style.position = "absolute";
	          midnode.style.filter = "alpha(opacity=60);";
	          midnode.style.MozOpacity = 0.6;
	          midnode.style.opacity = 0.6;
	          midnode.onmousedown = function() { return false };
	        }
	        midnode.style.left = ((parseInt(this.xPointValue[i]) + parseInt(this.xPointValue[i - 1])) / 2 - 5) + "px";
	        midnode.style.top = ((parseInt(this.yPointValue[i]) + parseInt(this.yPointValue[i - 1])) / 2 - 5) + "px";
	        this.NodeLayer.appendChild(midnode)
				}
	  	}
		}
		for (var i = 0; i < this.xUpPointValue.length; i++)
		{
	    if (i > 0)
	    {
				UppointValue += ',';
				DownpointValue += ',';
	    }
	    UppointValue += (parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]));
	    DownpointValue += (parseInt(this.xDownPointValue[i]) + ',' + parseInt(this.yDownPointValue[i]));
	    if (i > 1)
				GonpointValue += ','
	    if (i == 0)
	    {
				GonpointValue += ('m' + parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]) + 'l')
	    }
	    else
	  	{
	      GonpointValue += (parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]))
	    }
	  }
	  for (var i = this.xDownPointValue.length - 1; i >= 0; i--)
	  {
			GonpointValue += ','
			GonpointValue += (parseInt(this.xDownPointValue[i]) + ',' + parseInt(this.yDownPointValue[i]))
	  }
	  if (this.elemMidline.points)
	  {
	    if (UppointValue)
	    {
	      this.elemUpline.points.value = UppointValue;
	      this.elemDownline.points.value = DownpointValue;
	      this.elemPolygon.path.value = GonpointValue
	    }
	  }
	  else
		{
	    this.elemUpline.points = UppointValue;
	    this.elemDownline.points = DownpointValue;
	    this.elemPolygon.path = GonpointValue
	  }
 	};
  this.setStrokeColor = function(color)
  {
    if (typeof this.elemDiv != "undefined")
    {
      this.strokeColor = color;
      this.elemUpline.strokecolor = this.strokeColor
      this.elemDownline.strokecolor = this.strokeColor
    }
    else
			this.strokeColor = color
  };
  this.getStrokeColor = function()
  {
    if (this.strokeColor != "")
			return this.strokeColor
  };
  this.setStrokeWeight = function(weight)
  {
    if (typeof this.elemDiv != "undefined")
    {
      this.strokeWeight = weight;
      this.elemUpline.strokeweight = this.strokeWeight
      this.elemDownline.strokeweight = this.strokeWeight
    }
    else
			this.strokeWeight = weight
  };
  this.getStrokeWeight = function()
  {
    if (this.strokeWeight != "")
			return this.strokeWeight
  };
  this.setStrokeOpacity = function(opacity)
  {
    if (typeof this.elemDiv != "undefined")
    {
      this.strokeOpacity = opacity;
      this.elemStroke.opacity = this.strokeOpacity
    }
    else
			this.strokeOpacity = opacity
  };
  this.getStrokeOpacity = function()
  {
    if (this.strokeOpacity != "")
			return this.strokeOpacity
  };
  this.setFillColor = function(color)
  {
    if (typeof this.elemPolygonfill != "undefined")
  	{
      this.fillColor = color;
      this.elemPolygonfill.color = this.fillcolor
    }
    else
			this.fillcolor = color
  };
  this.getFillColor = function()
  {
    if (this.fillcolor != "")
			return this.fillcolor
  };
  this.setFillOpacity = function(opacity)
  {
    if (typeof this.elemPolygonfill != "undefined")
    {
      this.fillOpacity = opacity;
      this.elemPolygonfill.opacity = this.fillOpacity / 100
    }
    else
			this.fillOpacity = opacity
  };
  this.getFillOpacity = function()
  {
    if (this.fillOpacity != "")
			return this.fillOpacity
  };
  this.hide = function()
  {
    if (this.elemDiv)
			this.elemDiv.style.display = "none"
    if (this.elemDiv1)
			this.elemDiv1.style.display = "none"
  };
  this.show = function()
  {
    if (this.elemDiv)
			this.elemDiv.style.display = "block"
    if (this.elemDiv1)
			this.elemDiv1.style.display = "block"
  };
  this.remove = function()
  {
    if (typeof this.elemDiv != "undefined" && this.elemDiv.parentNode)
    {
      this.elemDiv.parentNode.removeChild(this.elemDiv);
      this.elemDiv = null
      this.elemDiv1.parentNode.removeChild(this.elemDiv1);
      this.elemDiv1 = null
    }

    for (var eventname in this.ao)
    {
      GSEvent.removeListener(this.maplet.holder, eventname, this.ao[eventname]);
      this.ao[eventname] = null
    }
  };

  this.openInfoWindow = function(content)
  {
    this.info = content
    markerinfo = this.info;
		this.maplet.moveTo(this.pts[this.pts.length - 1]);
		visible();
  };
  this.bdisplaynode = function(bflag)
  {
    if (this.NodeLayer != null)
    {
      if (bflag)
      {
        this.NodeLayer.style.display = "block";
        this.NodeLayer.style.zIndex = 10
      }
      else
    	{
        this.NodeLayer.style.display = "none";
        this.NodeLayer.style.zIndex = 0
      }
    }
  };
  this.mouseoverfun = function(EVT)
  {
    if (this.maplet)
    {
      if (this.bEditable || this.maplet.bEditParallel)
      {
        if (this.ls || this.elemDiv1 != null && this.maplet && fJ(EVT.target, this.elemDiv1) || fJ(EVT.target, this.NodeLayer))
        {
          if (IE)
          {
						this.elemStroke.opacity = ((this.strokeOpacity <= 20) ? this.strokeOpacity : this.strokeOpacity - 20) / 100
          }
          this.bdisplaynode(true)
        }
        else
      	{
          if (IE)
          {
						this.elemStroke.opacity = this.strokeOpacity / 100
          }
          this.bdisplaynode(false)
        }
      }
    }
  };
  this.mousedownfun = function(EVT)
	{
    if (this.elemDiv1 != null && (this.bEditable || this.maplet.bEditParallel) && this.maplet && fJ(EVT.target, this.elemDiv1) && EVT.button == 1 && EVT.target.id.indexOf("node") != -1)
    {
      this.qo = true;
      this.l0 = IE?EVT.offsetX:EVT.layerX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
      this.na = IE?EVT.offsetX:EVT.layerX+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
      nodeflag = EVT.target;
      if (this.Polylineflag == null)
      {
        this.Polylineflag = document.createElement("v:polyline");
        this.Polylineflag.unselectable = "on";
        this.Polylineflag.id = this.id;
        this.Polylineflag.strokecolor = this.strokeColor;
        this.Polylineflag.strokeweight = this.strokeWeight + 'px';
        this.Polylineflag.fill = "false";
        this.Polylineflag.filled = "false";
        this.Polylineflag.style.position = "absolute";
        this.Strokeflag = document.createElement("v:stroke");
        this.Strokeflag.opacity = this.strokeOpacity / 100;
        this.Strokeflag.joinstyle = "round";
        this.Strokeflag.endcap = "round";
        this.Strokeflag.fill = "false";
      }
      this.Polylineflag.appendChild(this.Strokeflag);
      this.elemDiv1.appendChild(this.Polylineflag)
    }
    else if (this.elemDiv != null && !(this.bEditable || this.maplet.bParallel) && this.maplet && fJ(EVT.target, this.elemDiv) && EVT.button == 1)
    { }
  };
  this.mousemovefun = function(EVT)
  {
    if (nodeflag != null && (this.bEditable || this.maplet.bEditParallel) && this.qo && nodeflag.id.indexOf("node") > 0)
    {
      if (nodeflag != null)
      {
        var x = EVT.clientX - this.l0 - this.maplet.left+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
        var y = EVT.clientY - this.na - this.maplet.top+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
        nodeflag.style.left = (parseInt(x)) + "px";
        nodeflag.style.top = (parseInt(y)) + "px";
        this.ls = true;
        var ps = parseInt(nodeflag.num);
        var Points = new String(IE ? "" : "M");
        if (nodeflag.id.indexOf("_midnode_") > 0)
        {
          Points += parseInt(this.xPointValue[ps - 1]) + ',' + parseInt(this.yPointValue[ps - 1]);
          Points += ',' + (x + 5) + ',' + (y + 5);
          Points += ',' + parseInt(this.xPointValue[ps]) + ',' + parseInt(this.yPointValue[ps])
        }
        else
      	{
          if (ps > 0)
          {
						Points += parseInt(this.xPointValue[ps - 1]) + ',' + parseInt(this.yPointValue[ps - 1]) + ','
          }
          Points += (x + 5) + ',' + (y + 5);
          if (ps < this.xPointValue.length - 1)
          {
						Points += ',' + parseInt(this.xPointValue[ps + 1]) + ',' + parseInt(this.yPointValue[ps + 1])
          }
        }
        if (this.Polylineflag != null)
        {
          if (this.Polylineflag.points)
          {
						this.Polylineflag.points.value = Points
          }
          else
        	{
            this.Polylineflag.value = Points
          }
        }
      }
    }
  };
  this.mouseupfun = function(EVT)
  {
    if (this.elemDiv1 != null && (this.bEditable || this.maplet.bEditParallel) && this.maplet && this.qo)
    {
      if (nodeflag != null)
      {
        var x = EVT.clientX - this.l0+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
        var y = EVT.clientY - this.na+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);

        var ps = parseInt(nodeflag.count);
        var ud=this.maplet.ScreenToLatlng(x + 5-this.maplet.left,y + 5-this.maplet.top);
        if (nodeflag.id.indexOf("_midnode_") > 0)
        {
					this.pts.splice(ps, 0, ud)
        }
        else
      	{
          this.pts.splice(ps, 1, ud)
        }
      }
      this.qo = false;
      if (this.ls)
      {
				this.ls = false
      }
      if (this.Polylineflag.parentNode != null)
      {
        this.Polylineflag.parentNode.removeChild(this.Polylineflag);
        this.Polylineflag = null
      }
			this.S85()
    }
  };
  this.removeNode = function(node)
  {
    if (typeof node != "undefined")
    {
      if (node.toString().indexOf(this.id) >= 0 && node.toString().lastIndexOf("_") >= 0)
      {
				node = node.toString().substring(node.toString().lastIndexOf("_") + 1)
      }
      node = parseInt(node);
      if (!isNaN(node) && node < this.pts.length)
      {
        this.pts.splice(node, 1);
        if (typeof this.NodeLayer != "undefined" && this.NodeLayer != null)
        {
          for (var uy in this.NodeLayer)
          {
            if (typeof uy == "object")
            {
							this.NodeLayer.removeChild(uy)
            }
          }
        }
        if (this.Polylineflag != null && this.Polylineflag.parentNode != null)
        {
          this.Polylineflag.parentNode.removeChild(this.Polylineflag);
          this.Polylineflag = null
        }
        this.maplet.refresh()
      }
    }
  };
  this.getLatLng = function()
  {
    x = this.pts.lng();
    y = this.pts.lat();
    return new GSLatLng(y, x);
  };
  this.enableDragging = function()
  {
		this.bEditable = true;
  };
  this.disableDragging = function()
  {
		this.bEditable = false;
  };
  this.draggable = function()
  {
    if (this.bEditable)
			return true;
    else
			return false;
  };
  this.toString = function()
  {
		return 'com.toogo.maplet.GSParallel'
  }
};

function GSSideway(pts, strokecolor, strokeweight, strokeopacity, fillColor, fillOpacity, roadwidth)
{
  this.id = new Date().getTime() + "" + parseInt(Math.random() * 10000) + "GSSideway";
  this.wz = function(id)
  {
		this.id = id;
	};
  this.pts = pts;
  this.strokeColor = (strokecolor == null) ? "#A3876A" : strokecolor;
  this.strokeWeight = (strokeweight == null || strokeweight == 0) ? 1 : strokeweight;
  this.strokeOpacity = (strokeopacity == null || strokeopacity == 0) ? 100 : strokeopacity;
  this.fillColor = (fillColor == null) ? "#FFFFFF" : fillColor;
  this.fillOpacity = (fillOpacity == null || fillOpacity == 0) ? 100 : fillOpacity;
  this.roadwidth = (roadwidth == null || roadwidth == 0) ? 3 : roadwidth;
  this.qo = false;
  this.ls = false;
  this.Polylineflag = null;
  this.maplet = null;
  this.bEditable = false;
  this.ao = new Array();;
  this.setEditable = function(cs)
  {
    this.bEditable = (typeof cs == "undefined") ? false : cs;
    if (this.maplet != null)
    {
			this.S85()
    }
  };
  this.qc = function(maplet)
  {
    this.maplet = maplet;
    this.ao["mouseover"] = GSEvent.addListener(this.maplet.holder, "mouseover", this, this.mouseoverfun);
    this.ao["mousedown"] = GSEvent.addListener(this.maplet.holder, "mousedown", this, this.mousedownfun);
    this.ao["mousemove"] = GSEvent.addListener(this.maplet.holder, "mousemove", this, this.mousemovefun);
    this.ao["mouseup"] = GSEvent.addListener(this.maplet.holder, "mouseup", this, this.mouseupfun);

    if (typeof this.maplet.holder != "undefined")
    {
			this.paint()
    }
  }
  this.paint = function()
  {
    if (typeof this.elemDiv1 == "undefined")
    {
      this.elemDiv = document.createElement("div");
      this.elemDiv.unselectable = "on";
      this.elemDiv.style.zIndex = 10;
      this.elemDiv.style.position = "absolute";
      this.elemDiv1 = document.createElement("div");
      this.elemDiv1.unselectable = "on";
      this.elemDiv1.style.zIndex = 100;
      this.elemDiv1.style.position = "absolute";
      this.elemMidline = document.createElement("v:polyline");
      this.elemMidline.unselectable = "on";
      this.elemMidline.strokecolor = this.strokeColor;
      this.elemMidline.strokeweight = this.strokeWeight + 'pt';
      this.elemMidline.fill = "false";
      this.elemMidline.filled = "false";
      this.elemUpline = document.createElement("v:polyline");
      this.elemUpline.unselectable = "on";
      this.elemUpline.strokecolor = this.strokeColor;
      this.elemUpline.strokeweight = this.strokeWeight + 'pt';
      this.elemUpline.fill = "false";
      this.elemUpline.filled = "false";
      this.elemDownline = document.createElement("v:polyline");
      this.elemDownline.unselectable = "on";
      this.elemDownline.strokecolor = this.strokeColor;
      this.elemDownline.strokeweight = this.strokeWeight + 'pt';
      this.elemDownline.fill = "false";
      this.elemDownline.filled = "false";
      this.elemPolygon = document.createElement("v:shape");
      this.elemPolygon.unselectable = "on";
      this.elemPolygon.stroked = "false";
      this.elemPolygon.filled = "true";
      this.elemPolygon.style.width = 1;
      this.elemPolygon.style.height = 1;
      this.elemPolygon.style.top = "0px";
      this.elemPolygon.style.left = "0px";
      this.elemPolygon.style.position = "absolute";
      this.elemPolygon.coordsize = '1,1';
      this.elemStroke = document.createElement("v:stroke");
      this.elemStroke.opacity = (this.strokeOpacity / 100);
      this.elemStroke.joinstyle = "round";
      this.elemStroke.endcap = "round";
      this.elemStroke.fill = "false";
      this.elemPolygonfill = document.createElement("v:fill");
      this.elemPolygonfill.unselectable = "on";
      this.elemPolygonfill.color = this.fillColor;
      this.elemPolygonfill.opacity = (this.fillOpacity / 100);
      this.elemUpline.appendChild(this.elemStroke);
      this.elemDownline.appendChild(this.elemStroke);
      this.elemPolygon.appendChild(this.elemPolygonfill);
      this.elemDiv1.appendChild(this.elemMidline);
      this.elemDiv.appendChild(this.elemUpline);
      this.elemDiv.appendChild(this.elemDownline);
      this.elemDiv1.appendChild(this.elemPolygon)
    }
    this.elemDiv.style.visibility = "visible";
    this.elemDiv1.style.visibility = "visible";
    if (this.maplet.layerDrawMap.objDiv != null)
    {
      this.maplet.layerDrawMap.objDiv.appendChild(this.elemDiv)
      this.maplet.layerDrawMap.objDiv.appendChild(this.elemDiv1)
    }
    this.S85();
      
  };
  this.S85 = function()
  {
    this.NodeLayer = document.getElementById(this.id + "vNodeLayer");
    if ((this.bEditable||this.maplet.bSideway) && this.NodeLayer == null)
    {
      this.NodeLayer = document.createElement("div");
      this.NodeLayer.vb = this;
      this.NodeLayer.id = this.id + "vNodeLayer";
      this.NodeLayer.style.position = "absolute";
      this.NodeLayer.unselectable = "on";
      this.NodeLayer.style.display = "none";
      this.NodeLayer.style.zIndex = 1;
      this.NodeLayer.style.cursor = (IE) ? "hand" : "pointer";
      this.elemDiv1.appendChild(this.NodeLayer)
    }
    this.pu = new Array();
    this.xPointValue = new Array();
    this.yPointValue = new Array();
    this.xUpPointValue = new Array();
    this.yUpPointValue = new Array();
    this.xDownPointValue = new Array();
    this.yDownPointValue = new Array();
    var measCount = 0;
    if (this.pts == null || this.pts.length < 2)
			return;
    for (var i = 0; i < this.pts.length; i += 1)
    {
      this.pu[measCount] = i;
      if (this.pts[i].lng().toString() != Number.NaN.toString()&&this.pts[i].lat().toString() != Number.NaN.toString())
    	{
	      var xy=this.maplet.LatlngToScreen(parseFloat(this.pts[i].lng()),parseFloat(this.pts[i].lat()));
				this.xPointValue[measCount] =xy.x();
				this.yPointValue[measCount] =xy.y()
			}
			else
				return
      if (measCount == 1)
      {
        var upStartlnglat = this.maplet.getStartUpPot(this.xPointValue[0], this.yPointValue[0], this.xPointValue[1] + 2, this.yPointValue[1] + 2, this.roadwidth);
        if (upStartlnglat.lng().toString() != Number.NaN.toString()&&upStartlnglat.lat().toString() != Number.NaN.toString())
    		{
		      var xy=this.maplet.LatlngToScreen(parseFloat(upStartlnglat.lng()),parseFloat(upStartlnglat.lat()));
					this.xUpPointValue[0] =xy.x();
					this.yUpPointValue[0] =xy.y()
				}
        var downStartlnglat = this.maplet.getStartDownPot(this.xPointValue[0], this.yPointValue[0], this.xPointValue[1] + 2, this.yPointValue[1] + 2, this.roadwidth);
        if (downStartlnglat.lng().toString() != Number.NaN.toString()&&downStartlnglat.lat().toString() != Number.NaN.toString())
    		{
		      var xy=this.maplet.LatlngToScreen(parseFloat(downStartlnglat.lng()),parseFloat(downStartlnglat.lat()));
					this.xDownPointValue[0] =xy.x();
					this.yDownPointValue[0] =xy.y()
				}
      }
      if (measCount >= 1)
      {
        var upMovelnglat = this.maplet.getMoveUpPot(this.xPointValue[measCount - 1], this.yPointValue[measCount - 1], this.xPointValue[measCount] + 1, this.yPointValue[measCount] + 1, this.roadwidth);
        if (upMovelnglat.lng().toString() != Number.NaN.toString()&&upMovelnglat.lat().toString() != Number.NaN.toString())
    		{
		     	var xy=this.maplet.LatlngToScreen(parseFloat(upMovelnglat.lng()),parseFloat(upMovelnglat.lat()));
					this.xUpPointValue[measCount] =xy.x();
					this.yUpPointValue[measCount] =xy.y()
				}
        var downMovelnglat = this.maplet.getMoveDownPot(this.xPointValue[measCount - 1], this.yPointValue[measCount - 1], this.xPointValue[measCount] + 1, this.yPointValue[measCount] + 1, this.roadwidth);
        if (downMovelnglat.lng().toString() != Number.NaN.toString()&&downMovelnglat.lat().toString() != Number.NaN.toString())
    		{
		      var xy=this.maplet.LatlngToScreen(parseFloat(downMovelnglat.lng()),parseFloat(downMovelnglat.lat()));
					this.xDownPointValue[measCount] =xy.x();
					this.yDownPointValue[measCount] =xy.y()
				}
      }
      if (measCount > 1)
      {
        var miduplnglat = this.maplet.getMidPot(this.xPointValue[measCount - 2], this.yPointValue[measCount - 2], this.xPointValue[measCount - 1], this.yPointValue[measCount - 1], this.xPointValue[measCount], this.yPointValue[measCount], this.xUpPointValue[measCount - 2], this.yUpPointValue[measCount - 2], this.xUpPointValue[measCount], this.yUpPointValue[measCount]);
        if (miduplnglat.lng().toString() != Number.NaN.toString()&&miduplnglat.lat().toString() != Number.NaN.toString())
    		{
		      var xy=this.maplet.LatlngToScreen(parseFloat(miduplnglat.lng()),parseFloat(miduplnglat.lat()));
					this.xUpPointValue[measCount-1] =xy.x();
					this.yUpPointValue[measCount-1] =xy.y()
				}
        var middownlnglat = this.maplet.getMidPot(this.xPointValue[measCount - 2], this.yPointValue[measCount - 2], this.xPointValue[measCount - 1], this.yPointValue[measCount - 1], this.xPointValue[measCount], this.yPointValue[measCount], this.xDownPointValue[measCount - 2], this.yDownPointValue[measCount - 2], this.xDownPointValue[measCount], this.yDownPointValue[measCount]);
        if (middownlnglat.lng().toString() != Number.NaN.toString()&&middownlnglat.lat().toString() != Number.NaN.toString())
    		{
		      var xy=this.maplet.LatlngToScreen(parseFloat(middownlnglat.lng()),parseFloat(middownlnglat.lat()));
					this.xDownPointValue[measCount-1] =xy.x();
					this.yDownPointValue[measCount-1] =xy.y()
				}
      }
      if (measCount > 0 && (Math.abs(this.xPointValue[measCount] - this.xPointValue[measCount - 1]) + Math.abs(this.yPointValue[measCount] - this.yPointValue[measCount - 1])) > 10)
      {
				measCount++
      }
      if (measCount == 0)
				measCount++
    }
    var UppointValue = '';
    var DownpointValue = '';
    var GonpointValue = '';

    for (var i = 0; i < this.xPointValue.length; i++)
		{
      if (this.NodeLayer && !this.maplet.bmeasure)
      {
        var sidenode = document.getElementById(this.id + "_node_" + this.pu[i]);
        if (sidenode == null)
        {
          sidenode = new Image();
          sidenode.id = this.id + "_node_" + this.pu[i];
          sidenode.num = i;
          sidenode.count = this.pu[i];
          sidenode.src = "images/toogo/node.gif";
          sidenode.unselectable = "on";
          sidenode.alt = "拖动以移动此点";
          sidenode.title = "拖动以移动此点";
          sidenode.style.position = "absolute";
          sidenode.style.filter = "alpha(opacity=100);";
          sidenode.style.MozOpacity = 1.0;
          sidenode.style.opacity = 1.0;
          sidenode.onmousedown = function()
          {
						return false
          };
        }
        sidenode.style.left = (parseInt(this.xPointValue[i]) - 5) + "px";
        sidenode.style.top = (parseInt(this.yPointValue[i]) - 5) + "px";
        this.NodeLayer.appendChild(sidenode);
        if (i > 0)
        {
          var midnode = document.getElementById(this.id + "_midnode_" + this.pu[i]);
          if (midnode == null)
          {
            midnode = new Image();
            midnode.id = this.id + "_midnode_" + this.pu[i];
            midnode.num = i;
            midnode.count = this.pu[i];
            midnode.unselectable = "on";
            midnode.src = "images/toogo/node.gif";
            midnode.alt = "拖动以移动此点";
            midnode.title = "拖动以移动此点";
            midnode.style.position = "absolute";
            midnode.style.filter = "alpha(opacity=60);";
            midnode.style.MozOpacity = 0.6;
            midnode.style.opacity = 0.6;
            midnode.onmousedown = function() { return false };
          }
          midnode.style.left = ((parseInt(this.xPointValue[i]) + parseInt(this.xPointValue[i - 1])) / 2 - 5) + "px";
          midnode.style.top = ((parseInt(this.yPointValue[i]) + parseInt(this.yPointValue[i - 1])) / 2 - 5) + "px";
          this.NodeLayer.appendChild(midnode)
        }
      }
    }
    for (var i = 0; i < this.xUpPointValue.length; i++)
    {
      if (i > 0)
      {
        UppointValue += ',';
        DownpointValue += ',';
      }
      UppointValue += (parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]));
      DownpointValue += (parseInt(this.xDownPointValue[i]) + ',' + parseInt(this.yDownPointValue[i]));
      if (i > 1)
				GonpointValue += ','
      if (i == 0)
      {
				GonpointValue += ('m' + parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]) + 'l')
      }
      else
    	{
        GonpointValue += (parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]))
      }
    }
    for (var i = this.xDownPointValue.length - 1; i >= 0; i--)
    {
      GonpointValue += ','
      GonpointValue += (parseInt(this.xDownPointValue[i]) + ',' + parseInt(this.yDownPointValue[i]))
    }
    if (this.elemMidline.points)
    {
      if (UppointValue)
      {
        this.elemUpline.points.value = UppointValue;
        this.elemDownline.points.value = DownpointValue;
        this.elemPolygon.path.value = GonpointValue
      }
    }
    else
  	{
      this.elemUpline.points = UppointValue;
      this.elemDownline.points = DownpointValue;
      this.elemPolygon.path = GonpointValue
    }
  };

  this.setStrokeColor = function(color)
  {
    if (typeof this.elemDiv != "undefined")
    {
      this.strokeColor = color;
      this.elemUpline.strokecolor = this.strokeColor
      this.elemDownline.strokecolor = this.strokeColor
    }
    else
			this.strokeColor = color
  };
  this.getStrokeColor = function()
  {
    if (this.strokeColor != "")
			return this.strokeColor
  };
  this.setStrokeWeight = function(weight)
  {
    if (typeof this.elemDiv != "undefined")
    {
      this.strokeWeight = weight;
      this.elemUpline.strokeweight = this.strokeWeight
      this.elemDownline.strokeweight = this.strokeWeight
    }
    else
			this.strokeWeight = weight
  };
  this.getStrokeWeight = function()
  {
    if (this.strokeWeight != "")
			return this.strokeWeight
  };
  this.setStrokeOpacity = function(opacity)
  {
    if (typeof this.elemDiv != "undefined")
    {
      this.strokeOpacity = opacity;
      this.elemStroke.opacity = this.strokeOpacity
    }
    else
			this.strokeOpacity = opacity
  };
  this.getStrokeOpacity = function()
  {
    if (this.strokeOpacity != "")
			return this.strokeOpacity
  };
  this.setFillColor = function(color)
  {
    if (typeof this.elemPolygonfill != "undefined")
    {
      this.fillColor = color;
      this.elemPolygonfill.color = this.fillcolor
    }
    else
			this.fillcolor = color
  };
  this.getFillColor = function()
  {
    if (this.fillcolor != "")
			return this.fillcolor
  };
  this.setFillOpacity = function(opacity)
  {
    if (typeof this.elemPolygonfill != "undefined")
    {
      this.fillOpacity = opacity;
      this.elemPolygonfill.opacity = this.fillOpacity / 100
    }
    else
			this.fillOpacity = opacity
  };
  this.getFillOpacity = function()
  {
    if (this.fillOpacity != "")
			return this.fillOpacity
  };
  this.hide = function()
  {
    if (this.elemDiv)
			this.elemDiv.style.display = "none"
    if (this.elemDiv1)
			this.elemDiv1.style.display = "none"
  };
  this.show = function()
  {
    if (this.elemDiv)
			this.elemDiv.style.display = "block"
    if (this.elemDiv1)
			this.elemDiv1.style.display = "block"
  };
  this.remove = function()
  {
    if (typeof this.elemDiv != "undefined" && this.elemDiv.parentNode)
    {
      this.elemDiv.parentNode.removeChild(this.elemDiv);
      this.elemDiv = null
      this.elemDiv1.parentNode.removeChild(this.elemDiv1);
      this.elemDiv1 = null
    }

    for (var eventname in this.ao)
    {
      GSEvent.removeListener(this.maplet.holder, eventname, this.ao[eventname]);
      this.ao[eventname] = null
    }
  };

  this.openInfoWindow = function(content)
  {
    this.info = content
    markerinfo = this.info;
		this.maplet.moveTo(this.pts[this.pts.length - 1]);
		visible();
  };
  this.bdisplaynode = function(bflag)
  {
    if (this.NodeLayer != null)
    {
      if (bflag)
      {
        this.NodeLayer.style.display = "block";
        this.NodeLayer.style.zIndex = 10

      }
      else
    	{
        this.NodeLayer.style.display = "none";
        this.NodeLayer.style.zIndex = 0

      }
    }
  };
  this.mouseoverfun = function(EVT)
  {
    if (this.maplet)
    {
      if (this.bEditable || this.maplet.bEditSideway)
      {
        if (this.ls || this.elemDiv1 != null && this.maplet && fJ(EVT.target, this.elemDiv1) || fJ(EVT.target, this.NodeLayer))
        {
          if (IE)
          {
						this.elemStroke.opacity = ((this.strokeOpacity <= 20) ? this.strokeOpacity : this.strokeOpacity - 20) / 100
          }
          this.bdisplaynode(true)
        }
        else 
      	{
          if (IE)
          {
						this.elemStroke.opacity = this.strokeOpacity / 100
          }
          this.bdisplaynode(false)
        }
      }
    }
  };
  this.mousedownfun = function(EVT)
  {
    if (this.elemDiv1 != null && (this.bEditable || this.maplet.bEditSideway) && this.maplet && fJ(EVT.target, this.elemDiv1) && EVT.button == 1 && EVT.target.id.indexOf("node") != -1)
    {
      this.qo = true;
      this.l0 = IE?EVT.offsetX:EVT.layerX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
      this.na = IE?EVT.offsetX:EVT.layerX+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
      nodeflag = EVT.target;
      if (this.Polylineflag == null)
      {
        this.Polylineflag = document.createElement("v:polyline");
        this.Polylineflag.unselectable = "on";
        this.Polylineflag.id = this.id;
        this.Polylineflag.strokecolor = this.strokeColor;
        this.Polylineflag.strokeweight = this.strokeWeight + 'px';
        this.Polylineflag.fill = "false";
        this.Polylineflag.filled = "false";
        this.Polylineflag.style.position = "absolute";
        this.Strokeflag = document.createElement("v:stroke");
        this.Strokeflag.opacity = this.strokeOpacity / 100;
        this.Strokeflag.joinstyle = "round";
        this.Strokeflag.endcap = "round";
        this.Strokeflag.fill = "false";
      }
      this.Polylineflag.appendChild(this.Strokeflag);
      this.elemDiv1.appendChild(this.Polylineflag)
    }
    else if (this.elemDiv != null && !(this.bEditable || this.maplet.bSideway) && this.maplet && fJ(EVT.target, this.elemDiv) && EVT.button == 1)
    { }
  };
  this.mousemovefun = function(EVT)
  {
    if (nodeflag != null && (this.bEditable || this.maplet.bEditSideway) && this.qo && nodeflag.id.indexOf("node") > 0)
    {
      if (nodeflag != null)
      {
        var x = EVT.clientX - this.l0 - this.maplet.left+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
        var y = EVT.clientY - this.na - this.maplet.top+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
        nodeflag.style.left = (parseInt(x)) + "px";
        nodeflag.style.top = (parseInt(y)) + "px";
        this.ls = true;
        var ps = parseInt(nodeflag.num);
        var Points = new String(IE ? "" : "M");
        if (nodeflag.id.indexOf("_midnode_") > 0)
        {
          Points += parseInt(this.xPointValue[ps - 1]) + ',' + parseInt(this.yPointValue[ps - 1]);
          Points += ',' + (x + 5) + ',' + (y + 5);
          Points += ',' + parseInt(this.xPointValue[ps]) + ',' + parseInt(this.yPointValue[ps])
        }
        else
      	{
          if (ps > 0)
          {
						Points += parseInt(this.xPointValue[ps - 1]) + ',' + parseInt(this.yPointValue[ps - 1]) + ','
          }
          Points += (x + 5) + ',' + (y + 5);
          if (ps < this.xPointValue.length - 1)
          {
						Points += ',' + parseInt(this.xPointValue[ps + 1]) + ',' + parseInt(this.yPointValue[ps + 1])
          }
        }
        if (this.Polylineflag != null)
        {
          if (this.Polylineflag.points)
          {
						this.Polylineflag.points.value = Points
          }
          else
        	{
            this.Polylineflag.value = Points
          }
        }
      }
    }
  };
  this.mouseupfun = function(EVT)
  {
    if (this.elemDiv1 != null && (this.bEditable || this.maplet.bEditSideway) && this.maplet && this.qo)
    {
      if (nodeflag != null)
      {
        var x = EVT.clientX - this.l0+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
        var y = EVT.clientY - this.na+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);

        var ps = parseInt(nodeflag.count);
       	var ud=this.maplet.ScreenToLatlng(x + 5-this.maplet.left,y + 5-this.maplet.top);
        if (nodeflag.id.indexOf("_midnode_") > 0)
        {
            this.pts.splice(ps, 0, ud)
        }
        else
      	{
          this.pts.splice(ps, 1, ud)
        }
			}
      this.qo = false;
      if (this.ls)
      {
				this.ls = false
      }
			if (this.Polylineflag.parentNode != null)
			{
        this.Polylineflag.parentNode.removeChild(this.Polylineflag);
        this.Polylineflag = null
      }
      this.S85()
    }
  };
  this.removeNode = function(node)
  {
    if (typeof node != "undefined")
    {
      if (node.toString().indexOf(this.id) >= 0 && node.toString().lastIndexOf("_") >= 0)
      {
				node = node.toString().substring(node.toString().lastIndexOf("_") + 1)
      }
      node = parseInt(node);
      if (!isNaN(node) && node < this.pts.length)
      {
        this.pts.splice(node, 1);
        if (typeof this.NodeLayer != "undefined" && this.NodeLayer != null)
        {
          for (var uy in this.NodeLayer)
          {
            if (typeof uy == "object")
            {
							this.NodeLayer.removeChild(uy)
            }
          }
        }
        if (this.Polylineflag != null && this.Polylineflag.parentNode != null)
        {
          this.Polylineflag.parentNode.removeChild(this.Polylineflag);
          this.Polylineflag = null
        }
        this.maplet.refresh()
      }
    }
  };
  this.getLatLng = function()
  {
    x = this.pts.lng();
    y = this.pts.lat();
    return new GSLatLng(y, x);
  };
  this.enableDragging = function()
  {
		this.bEditable = true;
  };
  this.disableDragging = function()
  {
		this.bEditable = false;
  };
  this.draggable = function()
  {
    if (this.bEditable)
			return true;
    else
			return false;
  };
  this.toString = function()
  {
		return 'com.toogo.maplet.GSSideway'
  }
};

function GSOverheadRoad(pts, strokecolor, strokeweight, strokeopacity, fillColor, fillOpacity, roadwidth)
{
  this.id = new Date().getTime() + "" + parseInt(Math.random() * 10000) + "GSOverheadRoad";
  this.wz = function(id)
  {
		this.id = id;
	};
  this.pts = pts;
  this.strokeColor = (strokecolor == null) ? "#CE5B04" : strokecolor;
  this.strokeWeight = (strokeweight == null || strokeweight == 0) ? 2 : strokeweight;
  this.strokeOpacity = (strokeopacity == null || strokeopacity == 0) ? 100 : strokeopacity;
  this.fillColor = (fillColor == null) ? "#E88B31" : fillColor;
  this.fillOpacity = (fillOpacity == null || fillOpacity == 0) ? 100 : fillOpacity;
  this.roadwidth = (roadwidth == null || roadwidth == 0) ? 3 : roadwidth;
  this.qo = false;
  this.ls = false;
  this.Polylineflag = null;
  this.maplet = null;
  this.bEditable = false;
  this.ao = new Array();
  this.setEditable = function(cs)
  {
    this.bEditable = (typeof cs == "undefined") ? false : cs;
    if (this.maplet != null)
    {
			this.S85()
    }
  };
  this.qc = function(maplet)
  {
    this.maplet = maplet;
    this.ao["mouseover"] = GSEvent.addListener(this.maplet.holder, "mouseover", this, this.mouseoverfun);
    this.ao["mousedown"] = GSEvent.addListener(this.maplet.holder, "mousedown", this, this.mousedownfun);
    this.ao["mousemove"] = GSEvent.addListener(this.maplet.holder, "mousemove", this, this.mousemovefun);
    this.ao["mouseup"] = GSEvent.addListener(this.maplet.holder, "mouseup", this, this.mouseupfun);

    if (typeof this.maplet.holder != "undefined")
    {
			this.paint()
    }
  };
  this.paint = function()
  {
    if (typeof this.elemDiv1 == "undefined")
    {
      this.elemDiv1 = document.createElement("div");
      this.elemDiv1.unselectable = "on";
      this.elemDiv1.style.zIndex = 110;
      this.elemDiv1.style.position = "absolute";
      this.elemMidline = document.createElement("v:polyline");
      this.elemMidline.unselectable = "on";
      this.elemMidline.strokecolor = this.strokeColor;
      this.elemMidline.strokeweight = this.strokeWeight + 'pt';
      this.elemMidline.fill = "false";
      this.elemMidline.filled = "false";
      this.elemUpline = document.createElement("v:polyline");
      this.elemUpline.unselectable = "on";
      this.elemUpline.strokecolor = this.strokeColor;
      this.elemUpline.strokeweight = this.strokeWeight + 'pt';
      this.elemUpline.fill = "false";
      this.elemUpline.filled = "false";
      this.elemDownline = document.createElement("v:polyline");
      this.elemDownline.unselectable = "on";
      this.elemDownline.strokecolor = this.strokeColor;
      this.elemDownline.strokeweight = this.strokeWeight + 'pt';
      this.elemDownline.fill = "false";
      this.elemDownline.filled = "false";
      this.elemPolygon = document.createElement("v:shape");
      this.elemPolygon.unselectable = "on";
      this.elemPolygon.stroked = "false";
      this.elemPolygon.filled = "true";
      this.elemPolygon.style.width = 1;
      this.elemPolygon.style.height = 1;
      this.elemPolygon.style.top = "0px";
      this.elemPolygon.style.left = "0px";
      this.elemPolygon.style.position = "absolute";
      this.elemPolygon.coordsize = '1,1';
      this.elemStroke = document.createElement("v:stroke");
      this.elemStroke.opacity = (this.strokeOpacity / 100);
      this.elemStroke.joinstyle = "round";
      this.elemStroke.endcap = "round";
      this.elemStroke.fill = "false";
      this.elemPolygonfill = document.createElement("v:fill");
      this.elemPolygonfill.unselectable = "on";
      this.elemPolygonfill.color = this.fillColor;
      this.elemPolygonfill.opacity = (this.fillOpacity / 100);
      this.elemUpline.appendChild(this.elemStroke);
      this.elemDownline.appendChild(this.elemStroke);
      this.elemPolygon.appendChild(this.elemPolygonfill);
      this.elemDiv1.appendChild(this.elemMidline);
      this.elemDiv1.appendChild(this.elemUpline);
      this.elemDiv1.appendChild(this.elemDownline);
      this.elemDiv1.appendChild(this.elemPolygon)
      this.elemDiv2 = document.createElement("div");
      this.elemDiv2.unselectable = "on";
      this.elemDiv2.style.zIndex = 109;
      this.elemDiv2.style.position = "absolute";
      this.elemMidline2 = document.createElement("v:polyline");
      this.elemMidline2.unselectable = "on";
      this.elemMidline2.strokecolor = this.strokeColor;
      this.elemMidline2.strokeweight = this.strokeWeight + 'pt';
      this.elemMidline2.fill = "false";
      this.elemMidline2.filled = "false";
      this.elemUpline2 = document.createElement("v:polyline");
      this.elemUpline2.unselectable = "on";
      this.elemUpline2.strokecolor = this.strokeColor;
      this.elemUpline2.strokeweight = this.strokeWeight + 'pt';
      this.elemUpline2.fill = "false";
      this.elemUpline2.filled = "false";
      this.elemDownline2 = document.createElement("v:polyline");
      this.elemDownline2.unselectable = "on";
      this.elemDownline2.strokecolor = this.strokeColor;
      this.elemDownline2.strokeweight = this.strokeWeight + 'pt';
      this.elemDownline2.fill = "false";
      this.elemDownline2.filled = "false";
      this.elemPolygon2 = document.createElement("v:shape");
      this.elemPolygon2.unselectable = "on";
      this.elemPolygon2.stroked = "false";
      this.elemPolygon2.filled = "true";
      this.elemPolygon2.style.width = 1;
      this.elemPolygon2.style.height = 1;
      this.elemPolygon2.style.top = "0px";
      this.elemPolygon2.style.left = "0px";
      this.elemPolygon2.style.position = "absolute";
      this.elemPolygon2.coordsize = '1,1';
      this.elemStroke2 = document.createElement("v:stroke");
      this.elemStroke2.opacity = (this.strokeOpacity / 100);
      this.elemStroke2.joinstyle = "round";
      this.elemStroke2.endcap = "round";
      this.elemStroke2.fill = "false";
      this.elemPolygonfill2 = document.createElement("v:fill");
      this.elemPolygonfill2.unselectable = "on";
      this.elemPolygonfill2.color = this.fillColor;
      this.elemPolygonfill2.opacity = (this.fillOpacity / 100);
      this.elemUpline2.appendChild(this.elemStroke2);
      this.elemDownline2.appendChild(this.elemStroke2);
      this.elemPolygon2.appendChild(this.elemPolygonfill2);
      this.elemDiv2.appendChild(this.elemMidline2);
      this.elemDiv2.appendChild(this.elemUpline2);
      this.elemDiv2.appendChild(this.elemDownline2);
      this.elemDiv2.appendChild(this.elemPolygon2)
      this.elemDiv3 = document.createElement("div");
      this.elemDiv3.unselectable = "on";
      this.elemDiv3.style.zIndex = 107;
      this.elemDiv3.style.position = "absolute";
      this.elemMidline3 = document.createElement("v:polyline");
      this.elemMidline3.unselectable = "on";
      this.elemMidline3.strokecolor = this.strokeColor;
      this.elemMidline3.strokeweight = this.strokeWeight + 'pt';
      this.elemMidline3.fill = "false";
      this.elemMidline3.filled = "false";
      this.elemUpline3= document.createElement("v:polyline");
      this.elemUpline3.unselectable = "on";
      this.elemUpline3.strokecolor = this.strokeColor;
      this.elemUpline3.strokeweight = this.strokeWeight + 'pt';
      this.elemUpline3.fill = "false";
      this.elemUpline3.filled = "false";
      this.elemDownline3 = document.createElement("v:polyline");
      this.elemDownline3.unselectable = "on";
      this.elemDownline3.strokecolor = this.strokeColor;
      this.elemDownline3.strokeweight = this.strokeWeight + 'pt';
      this.elemDownline3.fill = "false";
      this.elemDownline3.filled = "false";
      this.elemPolygon3 = document.createElement("v:shape");
      this.elemPolygon3.unselectable = "on";
      this.elemPolygon3.stroked = "false";
      this.elemPolygon3.filled = "true";
      this.elemPolygon3.style.width = 1;
      this.elemPolygon3.style.height = 1;
      this.elemPolygon3.style.top = "0px";
      this.elemPolygon3.style.left = "0px";
      this.elemPolygon3.style.position = "absolute";
      this.elemPolygon3.coordsize = '1,1';
      this.elemStroke3 = document.createElement("v:stroke");
      this.elemStroke3.opacity = (this.strokeOpacity / 100);
      this.elemStroke3.joinstyle = "round";
      this.elemStroke3.endcap = "round";
      this.elemStroke3.fill = "false";
      this.elemPolygonfill3 = document.createElement("v:fill");
      this.elemPolygonfill3.unselectable = "on";
      this.elemPolygonfill3.color = this.fillColor;
      this.elemPolygonfill3.opacity = (this.fillOpacity / 100);
      this.elemUpline3.appendChild(this.elemStroke3);
      this.elemDownline3.appendChild(this.elemStroke3);
      this.elemPolygon3.appendChild(this.elemPolygonfill3);
      this.elemDiv3.appendChild(this.elemMidline3);
      this.elemDiv3.appendChild(this.elemUpline3);
      this.elemDiv3.appendChild(this.elemDownline3);
      this.elemDiv3.appendChild(this.elemPolygon3)
    }
    this.elemDiv1.style.visibility = "visible";
    this.elemDiv2.style.visibility = "visible";
    this.elemDiv3.style.visibility = "visible";
    if (this.maplet.layerDrawMap.objDiv != null)
    {
			this.maplet.layerDrawMap.objDiv.appendChild(this.elemDiv1)
			this.maplet.layerDrawMap.objDiv.appendChild(this.elemDiv2)
			this.maplet.layerDrawMap.objDiv.appendChild(this.elemDiv3)
    }
    this.S85();   
  };
  this.S85 = function()
  {
    this.NodeLayer = document.getElementById(this.id + "vNodeLayer");
    if (this.maplet.bOverheadRoad && this.NodeLayer == null)
    {
      this.NodeLayer = document.createElement("div");
      this.NodeLayer.vb = this;
      this.NodeLayer.id = this.id + "vNodeLayer";
      this.NodeLayer.style.position = "absolute";
      this.NodeLayer.unselectable = "on";
      this.NodeLayer.style.display = "none";
      this.NodeLayer.style.zIndex = 1;
      this.NodeLayer.style.cursor = (IE) ? "hand" : "pointer";
    }
    if(this.NodeLayer != null)
    {
    	if((this.elemDiv1.style.zIndex > this.elemDiv2.style.zIndex)&&(this.elemDiv1.style.zIndex > this.elemDiv3.style.zIndex))
      	this.elemDiv1.appendChild(this.NodeLayer)
      else if(this.elemDiv2.style.zIndex > this.elemDiv3.style.zIndex)
      	this.elemDiv2.appendChild(this.NodeLayer)
      else
      	this.elemDiv3.appendChild(this.NodeLayer)
    }
    this.pu = new Array();
    this.xPointValue = new Array();
    this.yPointValue = new Array();
    this.xUpPointValue = new Array();
    this.yUpPointValue = new Array();
    this.xDownPointValue = new Array();
    this.yDownPointValue = new Array();
    var measCount = 0;
    if (this.pts == null || this.pts.length < 2)
			return;
    for (var i = 0; i < this.pts.length; i++)
    {
			this.pu[measCount] = i;
			if (this.pts[i].lng().toString() != Number.NaN.toString()&&this.pts[i].lat().toString() != Number.NaN.toString())
    	{
	  		var xy=this.maplet.LatlngToScreen(parseFloat(this.pts[i].lng()),parseFloat(this.pts[i].lat()));
				this.xPointValue[measCount] =xy.x();
				this.yPointValue[measCount] =xy.y()
			}
			else
				return
      if (measCount == 1)
      {
        var upStartlnglat = this.maplet.getStartUpPot(this.xPointValue[0], this.yPointValue[0], this.xPointValue[1] + 2, this.yPointValue[1] + 2, this.roadwidth);
        if (upStartlnglat.lng().toString() != Number.NaN.toString()&&upStartlnglat.lat().toString() != Number.NaN.toString())
      	{
		  		var xy=this.maplet.LatlngToScreen(parseFloat(upStartlnglat.lng()),parseFloat(upStartlnglat.lat()));
					this.xUpPointValue[0] =xy.x();
					this.yUpPointValue[0] =xy.y()
				}
				var downStartlnglat = this.maplet.getStartDownPot(this.xPointValue[0], this.yPointValue[0], this.xPointValue[1] + 2, this.yPointValue[1] + 2, this.roadwidth);
        if (downStartlnglat.lng().toString() != Number.NaN.toString()&&downStartlnglat.lat().toString() != Number.NaN.toString())
      	{
		  		var xy=this.maplet.LatlngToScreen(parseFloat(downStartlnglat.lng()),parseFloat(downStartlnglat.lat()));
					this.xDownPointValue[0] =xy.x();
					this.yDownPointValue[0] =xy.y()
				}
      }
      if (measCount >= 1)
      {
        var upMovelnglat = this.maplet.getMoveUpPot(this.xPointValue[measCount - 1], this.yPointValue[measCount - 1], this.xPointValue[measCount] + 1, this.yPointValue[measCount] + 1, this.roadwidth);
				if (upMovelnglat.lng().toString() != Number.NaN.toString()&&upMovelnglat.lat().toString() != Number.NaN.toString())
      	{
		  		var xy=this.maplet.LatlngToScreen(parseFloat(upMovelnglat.lng()),parseFloat(upMovelnglat.lat()));
					this.xUpPointValue[measCount] =xy.x();
					this.yUpPointValue[measCount] =xy.y()
				}
        var downMovelnglat = this.maplet.getMoveDownPot(this.xPointValue[measCount - 1], this.yPointValue[measCount - 1], this.xPointValue[measCount] + 1, this.yPointValue[measCount] + 1, this.roadwidth);
        if (downMovelnglat.lng().toString() != Number.NaN.toString()&&downMovelnglat.lat().toString() != Number.NaN.toString())
      	{
		  		var xy=this.maplet.LatlngToScreen(parseFloat(downMovelnglat.lng()),parseFloat(downMovelnglat.lat()));
					this.xDownPointValue[measCount] =xy.x();
					this.yDownPointValue[measCount] =xy.y()
				}
      }
      if (measCount > 1)
      {
        var miduplnglat = this.maplet.getMidPot(this.xPointValue[measCount - 2], this.yPointValue[measCount - 2], this.xPointValue[measCount - 1], this.yPointValue[measCount - 1], this.xPointValue[measCount], this.yPointValue[measCount], this.xUpPointValue[measCount - 2], this.yUpPointValue[measCount - 2], this.xUpPointValue[measCount], this.yUpPointValue[measCount]);
        if (miduplnglat.lng().toString() != Number.NaN.toString()&&miduplnglat.lat().toString() != Number.NaN.toString())
      	{
		  		var xy=this.maplet.LatlngToScreen(parseFloat(miduplnglat.lng()),parseFloat(miduplnglat.lat()));
					this.xUpPointValue[measCount-1] =xy.x();
					this.yUpPointValue[measCount-1] =xy.y()
				}
        var middownlnglat = this.maplet.getMidPot(this.xPointValue[measCount - 2], this.yPointValue[measCount - 2], this.xPointValue[measCount - 1], this.yPointValue[measCount - 1], this.xPointValue[measCount], this.yPointValue[measCount], this.xDownPointValue[measCount - 2], this.yDownPointValue[measCount - 2], this.xDownPointValue[measCount], this.yDownPointValue[measCount]);
        if (middownlnglat.lng().toString() != Number.NaN.toString()&&middownlnglat.lat().toString() != Number.NaN.toString())
      	{
		  		var xy=this.maplet.LatlngToScreen(parseFloat(middownlnglat.lng()),parseFloat(middownlnglat.lat()));
					this.xDownPointValue[measCount-1] =xy.x();
					this.yDownPointValue[measCount-1] =xy.y()
				}
      }
      if (measCount > 0 && (Math.abs(this.xPointValue[measCount] - this.xPointValue[measCount - 1]) + Math.abs(this.yPointValue[measCount] - this.yPointValue[measCount - 1])) > 10)
      {
				measCount++
      }
      if (measCount == 0)
				measCount++
    }

    var UppointValue = '';
    var DownpointValue = '';
    var GonpointValue = '';
    
    var UppointValue2 = '';
    var DownpointValue2 = '';
    var GonpointValue2 = '';
    
    var UppointValue3 = '';
    var DownpointValue3 = '';
    var GonpointValue3 = '';

    for (var i = 0; i < this.xPointValue.length; i++)
    {
        if (this.NodeLayer && !this.maplet.bmeasure)
        {
            var sidenode = document.getElementById(this.id + "_node_" + this.pu[i]);
            if (sidenode == null)
            {
                sidenode = new Image();
                sidenode.id = this.id + "_node_" + this.pu[i];
                sidenode.num = i;
                sidenode.count = this.pu[i];
                sidenode.src = "images/toogo/node.gif";
                sidenode.unselectable = "on";
                sidenode.alt = "拖动以移动此点";
                sidenode.title = "拖动以移动此点";
                sidenode.style.position = "absolute";
                sidenode.style.filter = "alpha(opacity=100);";
                sidenode.style.MozOpacity = 1.0;
                sidenode.style.opacity = 1.0;
                sidenode.onmousedown = function()
                {
                    return false
                };
            }
            sidenode.style.left = (parseInt(this.xPointValue[i]) - 5) + "px";
            sidenode.style.top = (parseInt(this.yPointValue[i]) - 5) + "px";
            this.NodeLayer.appendChild(sidenode);
            if (i > 0)
            {
                var midnode = document.getElementById(this.id + "_midnode_" + this.pu[i]);
                if (midnode == null)
                {
                    midnode = new Image();
                    midnode.id = this.id + "_midnode_" + this.pu[i];
                    midnode.num = i;
                    midnode.count = this.pu[i];
                    midnode.unselectable = "on";
                    midnode.src = "images/toogo/node.gif";
                    midnode.alt = "拖动以移动此点";
                    midnode.title = "拖动以移动此点";
                    midnode.style.position = "absolute";
                    midnode.style.filter = "alpha(opacity=60);";
                    midnode.style.MozOpacity = 0.6;
                    midnode.style.opacity = 0.6;
                    midnode.onmousedown = function() { return false };
                }
                midnode.style.left = ((parseInt(this.xPointValue[i]) + parseInt(this.xPointValue[i - 1])) / 2 - 5) + "px";
                midnode.style.top = ((parseInt(this.yPointValue[i]) + parseInt(this.yPointValue[i - 1])) / 2 - 5) + "px";
                this.NodeLayer.appendChild(midnode)
            }
        }

    }
		for (var i = 0; i < this.xUpPointValue.length; i++)
		{
			if (i == 0)
			{
				UppointValue = (parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]));
				DownpointValue = (parseInt(this.xDownPointValue[i]) + ',' + parseInt(this.yDownPointValue[i]));
				GonpointValue = ('m' + parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]) + 'l')
			}
			else if(i==1)
			{
				UppointValue += ',';
				DownpointValue += ',';
				GonpointValue += (parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]));
				UppointValue += (parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]));
				DownpointValue += (parseInt(this.xDownPointValue[i]) + ',' + parseInt(this.yDownPointValue[i]))
				if(this.xUpPointValue.length>2)
				{
					UppointValue2 = (parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]));
					DownpointValue2 = (parseInt(this.xDownPointValue[i]) + ',' + parseInt(this.yDownPointValue[i]));
					GonpointValue2 = ('m' + parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]) + 'l')
				}
			}
			if(i>=2&&i<=(this.xUpPointValue.length<=3?this.xUpPointValue.length-1:this.xUpPointValue.length-2))
			{
				UppointValue2 += ',';
				DownpointValue2 += ',';
				if(i>=3)
					GonpointValue2+=',';
				GonpointValue2 += (parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]));
				UppointValue2 += (parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]));
				DownpointValue2 += (parseInt(this.xDownPointValue[i]) + ',' + parseInt(this.yDownPointValue[i]))
			}
			if(i==this.xUpPointValue.length-2&&this.xUpPointValue.length>3)
			{
				UppointValue3 = (parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]));
				DownpointValue3 = (parseInt(this.xDownPointValue[i]) + ',' + parseInt(this.yDownPointValue[i]));
				GonpointValue3 = ('m' + parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]) + 'l')
			}
			
			if(i==this.xUpPointValue.length-1&&this.xUpPointValue.length>3)
			{
				UppointValue3 += ',';
				DownpointValue3 += ',';
				GonpointValue3 += (parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]));
				UppointValue3 += (parseInt(this.xUpPointValue[i]) + ',' + parseInt(this.yUpPointValue[i]));
				DownpointValue3 += (parseInt(this.xDownPointValue[i]) + ',' + parseInt(this.yDownPointValue[i]))
			}
		}
		for (var i = this.xDownPointValue.length-1; i >= 0; i--)
		{
    	if(i>=this.xDownPointValue.length-2&&this.xDownPointValue.length>3)
    	{
	      GonpointValue3 += ','
	      GonpointValue3 += (parseInt(this.xDownPointValue[i]) + ',' + parseInt(this.yDownPointValue[i]))
	      if(i==this.xDownPointValue.length-2)
	      {
	      	GonpointValue2 += ','
	      	GonpointValue2 += (parseInt(this.xDownPointValue[i]) + ',' + parseInt(this.yDownPointValue[i]))
	      }
	    }
	    else if(i>=1&&this.xDownPointValue.length>2)
	    {
	      GonpointValue2 += ','
	      GonpointValue2 += (parseInt(this.xDownPointValue[i]) + ',' + parseInt(this.yDownPointValue[i]))
	      if(i==1)
	      {
	      	GonpointValue += ','
	      	GonpointValue += (parseInt(this.xDownPointValue[i]) + ',' + parseInt(this.yDownPointValue[i]))
	      }
	    }
	    else if(i>=0)
	    {
	      GonpointValue += ','
	      GonpointValue += (parseInt(this.xDownPointValue[i]) + ',' + parseInt(this.yDownPointValue[i]))
	    }
    }

    if (this.elemMidline.points)
    {
      if (UppointValue)
      {
        this.elemUpline.points.value = UppointValue;
        this.elemDownline.points.value = DownpointValue;
        this.elemPolygon.path.value = GonpointValue
        if(UppointValue2)
        {
	        this.elemUpline2.points.value = UppointValue2;
	        this.elemDownline2.points.value = DownpointValue2;
	        this.elemPolygon2.path.value = GonpointValue2
	      }
	      if(UppointValue3)
	      {
	        this.elemUpline3.points.value = UppointValue3;
	        this.elemDownline3.points.value = DownpointValue3;
	        this.elemPolygon3.path.value = GonpointValue3
	      }
      }
    }
   
  };

  this.setStrokeColor = function(color)
  {
    if (typeof this.elemDiv1 != "undefined")
    {
      this.strokeColor = color;
      this.elemUpline.strokecolor = this.strokeColor
      this.elemDownline.strokecolor = this.strokeColor
      this.elemUpline2.strokecolor = this.strokeColor
      this.elemDownline2.strokecolor = this.strokeColor
      this.elemUpline3.strokecolor = this.strokeColor
      this.elemDownline3.strokecolor = this.strokeColor
    }
    else
			this.strokeColor = color
  };
  this.getStrokeColor = function()
  {
    if (this.strokeColor != "")
			return this.strokeColor
  };
  this.setStrokeWeight = function(weight)
  {
    if (typeof this.elemDiv1 != "undefined")
    {
      this.strokeWeight = weight;
      this.elemUpline.strokeweight = this.strokeWeight
      this.elemDownline.strokeweight = this.strokeWeight
      this.elemUpline2.strokeweight = this.strokeWeight
      this.elemDownline2.strokeweight = this.strokeWeight
      this.elemUpline3.strokeweight = this.strokeWeight
      this.elemDownline3.strokeweight = this.strokeWeight
    }
    else
			this.strokeWeight = weight
  };
  this.getStrokeWeight = function()
  {
    if (this.strokeWeight != "")
			return this.strokeWeight
  };
  this.setStrokeOpacity = function(opacity)
  {
    if (typeof this.elemDiv1 != "undefined")
    {
      this.strokeOpacity = opacity;
      this.elemStroke.opacity = this.strokeOpacity
      this.elemStroke2.opacity = this.strokeOpacity
      this.elemStroke3.opacity = this.strokeOpacity
    }
    else
			this.strokeOpacity = opacity
  };
  this.getStrokeOpacity = function()
  {
    if (this.strokeOpacity != "")
			return this.strokeOpacity
  };
  this.setFillColor = function(color)
  {
    if (typeof this.elemPolygonfill != "undefined")
    {
      this.fillColor = color;
      this.elemPolygonfill.color = this.fillcolor
      this.elemPolygonfill2.color = this.fillcolor
      this.elemPolygonfill3.color = this.fillcolor
  	}
    else
			this.fillcolor = color
  };
  this.getFillColor = function()
  {
    if (this.fillcolor != "")
			return this.fillcolor
	};
  this.setFillOpacity = function(opacity)
  {
    if (typeof this.elemPolygonfill != "undefined")
    {
      this.fillOpacity = opacity;
      this.elemPolygonfill.opacity = this.fillOpacity / 100
      this.elemPolygonfill2.opacity = this.fillOpacity / 100
      this.elemPolygonfill3.opacity = this.fillOpacity / 100
    }
    else
			this.fillOpacity = opacity
  };
  this.getFillOpacity = function()
  {
    if (this.fillOpacity != "")
			return this.fillOpacity
  };
  this.setzIndex=function()
  {
  	
  };
  this.hide = function()
  {
    if (this.elemDiv1)
    {
			this.elemDiv1.style.display = "none";
			this.elemDiv2.style.display = "none";
			this.elemDiv3.style.display = "none"
		}
  };
  this.show = function()
  {
    if (this.elemDiv1)
    {
			this.elemDiv1.style.display = "block"
			this.elemDiv2.style.display = "block"
			this.elemDiv3.style.display = "block"
		}
  };
  this.remove = function()
  {
    if (typeof this.elemDiv1 != "undefined" && this.elemDiv1.parentNode)
    {
      this.elemDiv1.parentNode.removeChild(this.elemDiv1);
      this.elemDiv1 = null
      this.elemDiv2.parentNode.removeChild(this.elemDiv2);
      this.elemDiv2 = null
      this.elemDiv3.parentNode.removeChild(this.elemDiv3);
      this.elemDiv3 = null
    }

    for (var eventname in this.ao)
    {
      GSEvent.removeListener(this.maplet.holder, eventname, this.ao[eventname]);
      this.ao[eventname] = null
    }
  };

  this.openInfoWindow = function(content)
  {
    this.info = content
    markerinfo = this.info;
		this.maplet.moveTo(this.pts[this.pts.length - 1]);
		visible();
  };
  this.bdisplaynode = function(bflag)
  {
    if (this.NodeLayer != null)
    {
      if (bflag)
      {
        this.NodeLayer.style.display = "block";
        this.NodeLayer.style.zIndex = 10
      }
      else
    	{
        this.NodeLayer.style.display = "none";
        this.NodeLayer.style.zIndex = 0
      }
    }
  };
  this.mouseoverfun = function(EVT)
  {
    if (this.maplet)
    {
      if (this.bEditable || this.maplet.bEditOverheadRoad)
      {
        if (this.ls || this.elemDiv1 != null && this.maplet && fJ(EVT.target, this.elemDiv1)||fJ(EVT.target, this.elemDiv2)||fJ(EVT.target, this.elemDiv3) || fJ(EVT.target, this.NodeLayer))
        {
          if (IE)
          {
						this.elemStroke.opacity = ((this.strokeOpacity <= 20) ? this.strokeOpacity : this.strokeOpacity - 20) / 100
          }
          this.bdisplaynode(true)
        }
        else
      	{
          if (IE)
          {
						this.elemStroke.opacity = this.strokeOpacity / 100
          }
          this.bdisplaynode(false)
        }
      }
    }
  };
  this.mousedownfun = function(EVT)
  {
    if (this.elemDiv1 != null && (this.bEditable || this.maplet.bEditOverheadRoad) && this.maplet && (fJ(EVT.target, this.elemDiv1)||fJ(EVT.target, this.elemDiv2)||fJ(EVT.target, this.elemDiv3)) && EVT.button == 1 && EVT.target.id.indexOf("node") != -1)
    {
      this.qo = true;
      this.l0 = IE?EVT.offsetX:EVT.layerX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
      this.na = IE?EVT.offsetX:EVT.layerX+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
      nodeflag = EVT.target;
      if (this.Polylineflag == null)
      {
        this.Polylineflag = document.createElement("v:polyline");
        this.Polylineflag.unselectable = "on";
        this.Polylineflag.id = this.id;
        this.Polylineflag.strokecolor = this.strokeColor;
        this.Polylineflag.strokeweight = this.strokeWeight + 'px';
        this.Polylineflag.fill = "false";
        this.Polylineflag.filled = "false";
        this.Polylineflag.style.position = "absolute";
        this.Strokeflag = document.createElement("v:stroke");
        this.Strokeflag.opacity = this.strokeOpacity / 100;
        this.Strokeflag.joinstyle = "round";
        this.Strokeflag.endcap = "round";
        this.Strokeflag.fill = "false";
      }
      this.Polylineflag.appendChild(this.Strokeflag);
      this.elemDiv1.appendChild(this.Polylineflag)
    }
    else if((this.bEditable || this.maplet.bEditOverheadRoad) &&fJ(EVT.target, this.elemDiv1))
    {
    	this.elemDiv1.style.zIndex+=1
    	this.S85()
    }
    else if((this.bEditable || this.maplet.bEditOverheadRoad) &&fJ(EVT.target, this.elemDiv2))
    {
    	this.elemDiv2.style.zIndex+=1
    	this.S85()
    }
    else if((this.bEditable || this.maplet.bEditOverheadRoad) &&fJ(EVT.target, this.elemDiv3))
    {
    	this.elemDiv3.style.zIndex+=1
    	this.S85()
    }
  };
  this.mousemovefun = function(EVT)
  {
    if (nodeflag != null && (this.bEditable || this.maplet.bEditOverheadRoad) && this.qo && nodeflag.id.indexOf("node") > 0)
    {
      if (nodeflag != null)
      {
        var x = EVT.clientX - this.l0 - this.maplet.left+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
        var y = EVT.clientY - this.na - this.maplet.top+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
        nodeflag.style.left = (parseInt(x)) + "px";
        nodeflag.style.top = (parseInt(y)) + "px";
        this.ls = true;
        var ps = parseInt(nodeflag.num);
        var Points = new String(IE ? "" : "M");
        if (nodeflag.id.indexOf("_midnode_") > 0)
        {
          Points += parseInt(this.xPointValue[ps - 1]) + ',' + parseInt(this.yPointValue[ps - 1]);
          Points += ',' + (x + 5) + ',' + (y + 5);
          Points += ',' + parseInt(this.xPointValue[ps]) + ',' + parseInt(this.yPointValue[ps])
      	}
      	else
      	{
          if (ps > 0)
          {
						Points += parseInt(this.xPointValue[ps - 1]) + ',' + parseInt(this.yPointValue[ps - 1]) + ','
          }
          Points += (x + 5) + ',' + (y + 5);
          if (ps < this.xPointValue.length - 1)
          {
						Points += ',' + parseInt(this.xPointValue[ps + 1]) + ',' + parseInt(this.yPointValue[ps + 1])
          }
        }
        if (this.Polylineflag != null)
        {
          if (this.Polylineflag.points)
          {
						this.Polylineflag.points.value = Points
          }
          else
        	{
            this.Polylineflag.value = Points
          }
        }
      }
    }
  };
  this.mouseupfun = function(EVT)
  {
    if (this.elemDiv1 != null && (this.bEditable || this.maplet.bEditOverheadRoad) && this.maplet && this.qo)
    {
      if (nodeflag != null)
      {
        var x = EVT.clientX - this.l0+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
        var y = EVT.clientY - this.na+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);

        var ps = parseInt(nodeflag.count);
        var ud=this.maplet.ScreenToLatlng(x + 5-this.maplet.left,y + 5-this.maplet.top);
        if (nodeflag.id.indexOf("_midnode_") > 0)
        {
					this.pts.splice(ps, 0, ud)
        }
        else
      	{
          this.pts.splice(ps, 1, ud)
        }
      }
      this.qo = false;
      if (this.ls)
      {
				this.ls = false
      }
      if (this.Polylineflag.parentNode != null)
      {
        this.Polylineflag.parentNode.removeChild(this.Polylineflag);
        this.Polylineflag = null
      }
      this.S85()
    }
  };
  this.removeNode = function(node)
  {
    if (typeof node != "undefined")
    {
      if (node.toString().indexOf(this.id) >= 0 && node.toString().lastIndexOf("_") >= 0)
      {
				node = node.toString().substring(node.toString().lastIndexOf("_") + 1)
      }
      node = parseInt(node);
      if (!isNaN(node) && node < this.pts.length)
      {
        this.pts.splice(node, 1);
        if (typeof this.NodeLayer != "undefined" && this.NodeLayer != null)
        {
          for (var uy in this.NodeLayer)
          {
            if (typeof uy == "object")
            {
							this.NodeLayer.removeChild(uy)
            }
          }
        }
        if (this.Polylineflag != null && this.Polylineflag.parentNode != null)
        {
          this.Polylineflag.parentNode.removeChild(this.Polylineflag);
          this.Polylineflag = null
        }
				this.maplet.refresh()
      }
    }
  };
  this.getLatLng = function()
  {
    x = this.pts.lng();
    y = this.pts.lat();
    return new GSLatLng(y, x);
  };
  this.enableDragging = function()
  {
		this.bEditable = true;
  };
  this.disableDragging = function()
  {
		this.bEditable = false;
  };
  this.draggable = function()
  {
    if (this.bEditable)
			return true;
    else
			return false;
  };
  this.toString = function()
  {
		return 'com.toogo.maplet.GSOverheadRoad'
  }
}
var zoomArr=new Array('W','0','1','2','3','4','5','6','7','8','9','10','11','12');
var longStepArr=new Array(90,40,20,10,5,2,1,0.5,0.2,0.1,0.05,0.02,0.01,0.005);
var latStepArr=new Array(90*0.8,40*0.8,20*0.8,10*0.8,5*0.8,2*0.8,1*0.8,0.5*0.8,0.2*0.8,0.1*0.8,0.05*0.8,0.02*0.8,0.01*0.8,0.005*0.8);
var gridStepArr=new Array(10,10,10,10,10,10,10,10,10,10,50,50,50,50);
var uGE$=new Array(0,0,0,0,0,0,0,0,75,0,0,-150,0,0);
var biggestZoom=13;
var hunThousand=100000;

document.writeln("<html xmlns:v=\"urn:schemas-microsoft-com:vml\">");
document.writeln("<style>");
document.writeln("v\\:* { behavior: url(#default#VML); }");
document.writeln("<\/style>");
