//K_ReverterMap 0.1 For 51ditu API
function K_ReverterMap()
{
	function K_Function(){}
	//读取网址后缀的函数
	K_Function.GetQueryString=function(key)
	{
		var url=document.URL;
		var index=url.indexOf("?");
		if(index<=0){index=url.indexOf("#");}
		if(index>0)
		{
			var params=url.substr(index+1).split("&");
			for(var i=0;i<params.length;i++)
			{
				var index=params[i].indexOf("=");
				if(index>0)
				{
					var name=params[i].substr(0,index);
					var value=params[i].substr(index+1);
					if(name==key)
					{
						return decodeURIComponent(value);
					}
				}
			}
		}
		return "";
	}
	K_Function.GetCallBack=function(obj,func)
	{
		return function(){return func.apply(obj,arguments)};
	}
	//在地图上显示附加地图图片的类
	function K_ImageOverlay(imageUrl,bounds,rotation,opacity)
	{
		this.imageUrl=imageUrl;
		this.bounds=bounds;
		this.rotation=-rotation;
		this.opacity=(typeof(opacity)=="number")?opacity:0.45;
	}
	K_ImageOverlay.prototype.initialize=function(a)
	{
		this.map=a;
		if((this.rotation>5 || this.rotation<-5)&& document.all)
		{
			this.drawElement=document.createElement("v:Image");
			this.drawElement.style.rotation=this.rotation;
		}
		else
			this.drawElement=document.createElement("img");
		this.drawElement.style.position="absolute";
		this.drawElement.style.zIndex=400;
		this.drawElement.galleryImg="no";
		this.setOpacity(this.opacity);
		this.drawElement.src=this.imageUrl;
		LTFunction.setUnSelectable(this.drawElement);
		this.drawElement.style.border="0";
		this.drawElement.style.padding="0";
		this.drawElement.style.margin="0";
		this.drawElement.oncontextmenu=LTFunction.falseFunction;
	};
	K_ImageOverlay.prototype.getObject=function()
	{
		return this.drawElement;
	}
	K_ImageOverlay.prototype.reDraw=function(a)
	{
		if(!a)return;
		var leftBottom=this.map.getPixelCoord(new LTPoint(this.bounds.Xmin,this.bounds.Ymin));
		var rightTop=this.map.getPixelCoord(new LTPoint(this.bounds.Xmax,this.bounds.Ymax));
		
		this.drawElement.style.left=(leftBottom[0]-parseInt(this.map.mapsDiv.style.left))+"px";
		this.drawElement.style.top=(rightTop[1]-parseInt(this.map.mapsDiv.style.top))+"px";
		this.drawElement.style.width=(rightTop[0]-leftBottom[0])+"px";
		this.drawElement.style.height=(leftBottom[1]-rightTop[1])+"px";
	};
	K_ImageOverlay.prototype.setOpacity=function(opacity)
	{
		this.opacity=(typeof(opacity)=="number")?opacity:0.45;
		this.drawElement.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+(this.opacity*100)+");";
		this.drawElement.style.MozOpacity=this.opacity;
	}
	//进行简单的坐标转化的类
	function K_Projection()
	{
	}
	K_Projection.load=function(latlng)
	{
		K_Projection.loading=true;
		K_Projection._latlng=[latlng[0],latlng[1]];
		if(!K_Projection.loader)
		{
			K_Projection.loader=new LTObjectLoader();
			window.onLtnLoaded=K_Projection.onLoad;
		}
		K_Projection.loader.load("http://dituren-service.appspot.com/services/ntu_ltn?c=onLtnLoaded&ps="+latlng[0]+","+latlng[1]+"");
	}
	K_Projection.onLoad=function(points)
	{
		if(points.length==1)
		{
			K_Projection.spLatlng=K_Projection._latlng;
			K_Projection._latlng=null;
			K_Projection.spNtu=points[0];
			LTEvent.trigger(K_Projection,"change",[]);
			K_Projection.loading=false;
		}
	}
	K_Projection.LatlngToNtu=function(latlng)
	{
		if(K_Projection.spLatlng)
		{
			if(Math.pow(K_Projection.spLatlng[0]-latlng[0],2)+Math.pow(K_Projection.spLatlng[1]-latlng[1],2)>1000000 && !K_Projection.loading)
			{
				K_Projection.load(latlng);
			}
			return [latlng[0]-K_Projection.spLatlng[0]+K_Projection.spNtu[0],latlng[1]-K_Projection.spLatlng[1]+K_Projection.spNtu[1]];
		}
		else
		{
			if(!K_Projection.loading)
			{
				K_Projection.load(latlng);
			}
			return [latlng[0],latlng[1]];
		}
	}
	K_Projection.NtuToLatlng=function(ntu)
	{
		if(K_Projection.spLatlng)
		{
			if(Math.pow(K_Projection.spLatlng[0]-ntu[0],2)+Math.pow(K_Projection.spLatlng[1]-ntu[1],2)>100000000 && !K_Projection.loading)
			{
				K_Projection.load(ntu);
			}
			return [ntu[0]+K_Projection.spLatlng[0]-K_Projection.spNtu[0],ntu[1]+K_Projection.spLatlng[1]-K_Projection.spNtu[1]];
		}
		else
		{
			if(!K_Projection.loading)
			{
				K_Projection.load(ntu);
			}
			return [ntu[0],ntu[1]];
		}
	}
	//将Google地图和灵图51ditu网的地图进行同步合并的地图
	function K_GMap2LTMaps(opacity)
	{
	//	this.gmaptype=G_SATELLITE_MAP;
		this.opacity=typeof(opacity)=="number"?opacity:0.5;
		this.images=[];
		this.times=0;
		LTEvent.bind(K_Projection,"change",this,this.resetImages);
	}
	K_GMap2LTMaps.prototype.bind=function(ltmaps)
	{
		this.ltmaps=ltmaps;
		this.ltmml=LTEvent.bind(this.ltmaps,"move",this,this.onMapMove);
	}
	K_GMap2LTMaps.prototype.setOpacity=function(opacity)
	{
		if(this.opacity==opacity || opacity<0 || opacity>1){return;}
		if(opacity>=0.1 && this.opacity<0.1 && this.ltmaps)
		{
			this.opacity=opacity;
			this.onMapMove(this.ltmaps.getCenterPoint(),true);
		}
		this.opacity=opacity;
		for(var i=0;i<this.images.length;i++)
		{
			this.images[this.images[i]].setOpacity(opacity);
		}
	}
	K_GMap2LTMaps.prototype.resetImages=function()
	{
		this.onMapMove(this.ltmaps.getCenterPoint(),true);
	}
	K_GMap2LTMaps.prototype.getImageBounds=function(i,j,gzoom)
	{
		var gimgsize=256;
		var gimgsw=K_GMap2LTMaps.fromPixelToLatLng([i*gimgsize,(j+1)*gimgsize],gzoom)
		var gimgne=K_GMap2LTMaps.fromPixelToLatLng([(i+1)*gimgsize,(j)*gimgsize],gzoom)
		var ltimgsw=K_Projection.LatlngToNtu([gimgsw[0]*100000,gimgsw[1]*100000])
		var ltimgne=K_Projection.LatlngToNtu([gimgne[0]*100000,gimgne[1]*100000])
		return new LTBounds(ltimgsw[0],ltimgsw[1],ltimgne[0],ltimgne[1]);
	}
	K_GMap2LTMaps.prototype.onMapMove=function(ltpoint,flag)
	{
		if(!flag){return;}
		this.times++;
		if(this.opacity>=0.1)
		{
		var ltzoom=this.ltmaps.getCurrentZoom();
		var gzoom=16-ltzoom;
		var ltbounds=this.ltmaps.getBoundsLatLng();
		var gswu=K_Projection.NtuToLatlng([ltbounds.Xmin,ltbounds.Ymin])
		var gsw=[gswu[0]/100000,gswu[1]/100000];
		var gneu=K_Projection.NtuToLatlng([ltbounds.Xmax,ltbounds.Ymax])
		var gne=[gneu[0]/100000,gneu[1]/100000];
		var gmin=K_GMap2LTMaps.fromLatLngToPixel(gsw,gzoom);
		var gmax=K_GMap2LTMaps.fromLatLngToPixel(gne,gzoom);
		var gimgsize=256;
		for(var i=Math.floor(gmin[0]/gimgsize);i<Math.ceil(gmax[0]/gimgsize);i++)
		{
			for(var j=Math.floor(gmax[1]/gimgsize);j<Math.ceil(gmin[1]/gimgsize);j++)
			{
				var gimgname="_"+i+"_"+j+"_"+gzoom;
				if(this.images[gimgname])
				{
					this.images[gimgname].times=this.times;
					if(flag)
					{
						this.images[gimgname].bounds=this.getImageBounds(i,j,gzoom);
						this.images[gimgname].reDraw(true);
					}
					continue;
				}
				var gimgurl=K_GMap2LTMaps.getTileUrl([i,j],gzoom);
				this.images[gimgname]=new K_ImageOverlay(gimgurl,this.getImageBounds(i,j,gzoom),null,this.opacity);
				this.images[gimgname].times=this.times;
				this.ltmaps.addOverLay(this.images[gimgname]);
				this.images.push(gimgname);
			}
		}
		}
		for(var i=0;i<this.images.length;i++)
		{
			if(this.images[this.images[i]].times!=this.times)
			{
				this.ltmaps.removeOverLay(this.images[this.images[i]]);
				this.images[this.images[i]]=null;
				this.images.splice(i,1);
				i--;
			}
		}
	}
	K_GMap2LTMaps.fromLatLngToPixel=function(glatlng,gzoom)
	{
		var d=128*Math.pow(2,gzoom);
		var e=Math.round(d+glatlng[0]*256*Math.pow(2,gzoom)/360);
		var f=Math.min(Math.max(Math.sin(glatlng[1]*Math.PI/180),-0.9999),0.9999);
		var g=Math.round(d+0.5*Math.log((1+f)/(1-f))*-256*Math.pow(2,gzoom)/(2*Math.PI));
		return [e,g]
	}
	K_GMap2LTMaps.fromPixelToLatLng=function(gpoint,gzoom)
	{
		var e=128*Math.pow(2,gzoom);
		var f=(gpoint[0]-128*Math.pow(2,gzoom))/(256*Math.pow(2,gzoom)/360);
		var g=(gpoint[1]-128*Math.pow(2,gzoom))/(-256*Math.pow(2,gzoom)/(2*Math.PI));
		var h=(2*Math.atan(Math.exp(g))-Math.PI/2)*180/Math.PI;
		return [f,h];
	};
	K_GMap2LTMaps.getTileUrl=function(gpoint,gzoom)
	{
		var c=Math.pow(2,gzoom);
		var d=gpoint[0];
		var e=gpoint[1];
		var f="t";
		for(var g=0;g<gzoom;g++)
		{
			c=c/2;
			if(e<c)
			{
				if(d<c)
				{
					f+="q"
				}
				else
				{
					f+="r";
					d-=c
				}
			}
			else
			{
				if(d<c)
				{
					f+="t";
					e-=c
				}
				else
				{
					f+="s";
					d-=c;
					e-=c
				}
			}
		}
		var h=(gpoint[0]+gpoint[1])%K_GMap2LTMaps.serviceUrls.length;
		return K_GMap2LTMaps.serviceUrls[h]+"t="+f
	}
	K_GMap2LTMaps.serviceUrls=["http://kh0.google.com/kh?n=404&v=21&","http://kh1.google.com/kh?n=404&v=21&","http://kh2.google.com/kh?n=404&v=21&","http://kh3.google.com/kh?n=404&v=21&"];

	function K_GMap2LTMapsControl()
	{
		LTFunction.inherit(this,LTBaseControl);
		this.div=document.createElement("div");
		this.div.style.position = "absolute";
		this.setRight(10);
		this.setTop(10);
		var barimg=new Image(103,20);
		LTEvent.addListener(barimg,"mousedown",LTEvent.cancelBubble);
		LTEvent.addListener(barimg,"click",LTEvent.cancelBubble);
		LTEvent.addListener(barimg,"dblclick",LTEvent.cancelBubble);
		barimg.src="http://www.step1.cn/51ditu/images/bar.gif";
		this.div.appendChild(barimg);
		this.slider=new Image(7,20);
		LTEvent.addListener(this.slider,"click",LTEvent.cancelBubble);
		LTEvent.addListener(this.slider,"dblclick",LTEvent.cancelBubble);
		LTEvent.bind(this.slider,"mousedown",this,this.onMouseDown);
		LTFunction.setCursorStyle(this.slider,"pointer");
		this.slider.style.position = "absolute";
		this.slider.style.top="0px";
		this.slider.style.zIndex="20";
		this.setCursor(0);
		this.slider.src="http://www.step1.cn/51ditu/images/slider.gif";
		this.div.appendChild(this.slider);
		this.g2lt=new K_GMap2LTMaps(0);
		this.loaded=false;
	}
	K_GMap2LTMapsControl.prototype.onMouseDown=function(e)
	{
		LTEvent.cancelBubble(e);
		if(this.slider.setCapture)
		{
			this.slider.setCapture();
		}
		this.mml=LTEvent.bind(document,"mousemove",this,this.onMouseMove);
		this.mul=LTEvent.bind(document,"mouseup",this,this.onMouseUp);
		this.start=LTFunction.getEventPosition(e,this.div)[0]-parseInt(this.slider.style.left);
	}
	K_GMap2LTMapsControl.prototype.onMouseMove=function(e)
	{
		LTEvent.cancelBubble(e);
		var p=LTFunction.getEventPosition(e,this.div)[0]-this.start;
		if(p<20 || p>76){return;}
		this.setCursor((p-20)/56);
		this.g2lt.setOpacity((p-20)/56);
	}
	K_GMap2LTMapsControl.prototype.onMouseUp=function(e)
	{
		this.onMouseMove(e);
		if(this.mml){LTEvent.removeListener(this.mml);this.mml=null;}
		if(this.mul){LTEvent.removeListener(this.mul);this.mul=null;}
		if(document.releaseCapture)
		{
			document.releaseCapture();
		}
	}
	K_GMap2LTMapsControl.prototype.setCursor=function(opacity)
	{
		this.slider.style.left=(20+56*opacity)+"px";
	}
	K_GMap2LTMapsControl.prototype.initialize=function(map)
	{
		this.Map=map;
		this.g2lt.bind(map);
		this.loaded=true;
	}
	K_GMap2LTMapsControl.prototype.getObject=function()
	{
		return this.div;
	}
	K_GMap2LTMapsControl.prototype.depose=function()
	{
		this.loaded=false;
	}
//这是调用用户所在地点的对象
	function K_UserPosition()
	{
		this.loaded=false;
	}
	K_UserPosition.prototype.Load=function(handle)
	{
		this.handle=handle;
		this.LoadByWiFi();
	}
	K_UserPosition.prototype.LoadByWiFi=function()
	{
		var wifi=this.GetWiFiControl();
		if(wifi)
		{
			try
			{
				var results = wifi.GetLocation();
				if(results&&results.length>0)
					{eval(results);return;}
			}
			catch(ex){}
		}
		window.SetAutoLocateViewport=LTEvent.getCallback(this,this.SetAutoLocateViewport);
		window.ShowMessage=LTEvent.getCallback(this,this.ShowMessage);
		LTObjectLoader.getObject().load("http://virtualearth.msn.com/WiFiIPService/locate.ashx?pos=");
	}
	K_UserPosition.prototype.GetWiFiControl=function()
	{
		var wifi=null;
		try
		{
			wifi=new ActiveXObject("WiFiScanner");
		}
		catch(e)
		{
			try
			{
				wifi=new ActiveXObject("Microsoft.MapPoint.WiFiScanner.1");
			}
			catch(e)
			{
				try
				{
					wifi=new WiFiScanner("Microsoft.MapPoint.WiFiScanner.1");
				}
				catch(e)
				{}
			}
		}
		return wifi;
	}
	K_UserPosition.prototype.ShowMessage=function(message)
	{
	}
	K_UserPosition.prototype.SetAutoLocateViewport=function(lat,lon,zoom,pin,message)
	{
		if(this.loaded)
			return;
		this.point=new LTPoint(lon*100000,lat*100000);
		this.zoom=zoom;
		this.pin=pin;
		this.message=message;
		this.loaded=true;
		if(this.handle)
		{
			this.handle.apply(this);
			this.handle=null;
		}
	}
//显示地图中心十字的控件
	function K_CrossControl(image,size)
	{
		this.size=size?size:[20,20];
		var img=document.createElement("img");
		img.src=image?image:"http://www.step1.cn/map/cross.gif";
		img.style.position="absolute";
		img.style.width=this.size[0]+"px";
		img.style.height=this.size[1]+"px";
		this.img=img;
	}
	K_CrossControl.prototype.initialize=function(map)
	{
		this.map=map;
		this.resetSize();
		LTEvent.bind(map,"resize",this,this.resetSize());
		return this.div;
	}
	K_CrossControl.prototype.getObject=function()
	{
		return this.img;
	}
	K_CrossControl.prototype.resetSize=function()
	{
		var size=this.map.getViewSize();
		this.img.style.left=(size[0]/2-this.size[0]/2)+"px";
		this.img.style.top=(size[1]/2-this.size[1]/2)+"px";
	}
	//显示地图的中心点地理信息的控件
	function K_CenterPlaceControl()
	{
		this.loader=new LTObjectLoader();
		LTEvent.bind(this.loader,"loaded",this,this.onRegoLoader);
		LTEvent.bind(this.loader,"error",this,this.setRgeoText);
	}
	K_CenterPlaceControl.prototype.getObject=function(a)
	{
		return this.div;
	}
	K_CenterPlaceControl.prototype.initialize=function(a)
	{
		this.Map=a;
		this.div=document.createElement("div");
		this.div.style.position="absolute";
		this.div.style.left="50px";
		this.div.style.top="10px";
		this.div.style.fontSize="11px";
		
		a.getContainer().appendChild(this.div);
		this.setRgeoText();
		this.listener=LTEvent.bind(map,"moveend",this,this.onMapMove);
		this.onMapMove();
		return this.div;
	};
	K_CenterPlaceControl.prototype.onMapMove=function()
	{
		if(this.timeout){window.clearTimeout(this.timeout);}
		this.timeout=window.setTimeout(LTEvent.getCallback(this,this.loadRegoCode),2000);
	}
	K_CenterPlaceControl.prototype.loadRegoCode=function()
	{
		var point=map.getCenterPoint();
		this.setRgeoText();
		var lng=point.getLongitude(),lat=point.getLatitude();
		lng=Math.round(lng/100)*100;
		lat=Math.round(lat/100)*100;
		this.loader.load("http://dituren-service.appspot.com/services/place_rgeo.aspx?llt=lt&ll="+lat+","+lng,"gb2312");
	}
	K_CenterPlaceControl.prototype.onRegoLoader=function(result)
	{
		try
		{
			var node=result.c[1];
			var str=node.t.split("-");
			var link=node.a.link.split("-");
			var html=[];
			for(var i=0;i<str.length;i++)
			{
				html.push('<a href="/place/cn/'+link.slice(0,i+1).join("/")+'.aspx" target="_blank">'+str[i]+'</a>');
			}
			this.setRgeoText("地图中心点位于："+html.join("-")+" 附近");
		}
		catch(e)
		{
			this.setRgeoText("获取当前中心点信息失败");
		}
	}
	K_CenterPlaceControl.prototype.setRgeoText=function(html)
	{
		this.div.innerHTML=html?html:"地图中心地名信息加载中……";
	}
	//加载
	function K_PanoramioPhotoControl(config)
	{
		this.loader=new LTObjectLoader();
		window.onPanoramioLoaded=LTEvent.GetCallBack(this,this.this.onPanoramioLoader)
		this.markers=[];
		this.config=config?config:{};
	}
	K_PanoramioPhotoControl.prototype.initialize=function(a)
	{
		this.map=a;
		this.listener=LTEvent.bind(a,"moveend",this,this.onMapMove);
		this.onMapMove();
	};
	K_PanoramioPhotoControl.prototype.getObject=function(){}
	K_PanoramioPhotoControl.prototype.onMapMove=function()
	{
		if(this.timeout){window.clearTimeout(this.timeout);}
		this.timeout=window.setTimeout(LTEvent.getCallback(this,this.loadPhotos),1000);
	}
	K_PanoramioPhotoControl.prototype.loadPhotos=function()
	{
		var bounds=map.getBoundsLatLng();
		this.loader.load("http://www.panoramio.com/map/get_panoramas.php?minx=" + bounds.getXmin()/100000 + "&miny=" + bounds.getYmin()/100000 +"&maxx=" + bounds.getXmax()/100000 + "&maxy=" + bounds.getYmax()/100000 + "&from=0&to=50&user=&tag=&callback=onPanoramioLoaded","gb2312")
	}
	K_PanoramioPhotoControl.prototype.onPanoramioLoader=function(rs)
	{
		this.clear();
		var photos = rs.photos;
		var contentDiv=this.config.content;
		if(contentDiv){while(contentDiv.firstChild){contentDiv.removeChild(contentDiv.firstChild)}}
		for (var i = 0; i < photos.length; i++)
		{
			var p = photos[i];
			var iconSrc=p.photo_url.replace("photo/","photos/mini_square/")+'.jpg';
			var icon=new LTIcon(iconSrc,[32,32],[16,16]);
			var marker = new LTMarker(new LTPoint(p.longitude*100000,p.latitude*100000),icon);
			marker.panorama=p;
			this.markers.push(marker);
			LTEvent.bind(marker, "click",marker,this.onPhotoClick);
			this.map.addOverLay(marker);
			if(contentDiv)
			{
				var img=document.createElement("img");
				img.title=p.photo_title;
				img.style.cursor="pointer";
				img.src=iconSrc;
				img.style.width="32px";
				img.style.height="32px";
				contentDiv.appendChild(img);
				LTEvent.bind(img,"click",marker,this.onPhotoClick);
			}
		}
	}
	K_PanoramioPhotoControl.prototype.clear=function()
	{
		var marker;
		while(marker=this.markers.pop())
		{
			marker.img=null;
			this.map.removeOverLay(marker);
		}
	}
	K_PanoramioPhotoControl.prototype.onPhotoClick=function()
	{
		var p=this.panorama;
		var infowin=this.openInfoWinHtml('<a href="'+this.panorama.photo_url+'" target="_blank"><img border="0" width='+p.width+' height='+p.height+' src="'+p.photo_url.replace("photo/","photos/medium/")+'.jpg"/></a>');
		infowin.setTitle(this.panorama.photo_title);
		infowin.moveToShow();
	}

	function K_Step1InfoWindow()
	{
		LTInfoWindow.prototype.createInfoWin=K_Step1InfoWindow.createInfoWin;
		LTInfoWindow.prototype.getAnchorPoint=K_Step1InfoWindow.getAnchorPoint;
		LTInfoWindow.prototype.changeInfoWin=K_Step1InfoWindow.changeInfoWin;
	}
	K_Step1InfoWindow.createInfoWin=function()
	{
		var tabSize=[6,6];
		var cursorSize=[20,21];
		this.imgSrc="http://www.step1.cn/51ditu/images/";
		this.setSize([50,12]);
		this.markerOffset=[0.5,0];
		var corners={}
		var img=new Image(tabSize[0],tabSize[1]);
		img.src=this.imgSrc+"iw_ul.gif";
		img.style.position="absolute";
		img.style.left="0px";
		img.style.top="0px";
		this.div.appendChild(img);
		corners.ul=img;

		var img=new Image(tabSize[0],tabSize[1]);
		img.src=this.imgSrc+"iw_ur.gif";
		img.style.position="absolute";
		img.style.right="0px";
		img.style.top="0px";
		this.div.appendChild(img);
		corners.ur=img;

		var img=new Image(tabSize[0],tabSize[1]);
		img.src=this.imgSrc+"iw_bl.gif";
		img.style.position="absolute";
		img.style.left="0px";
		img.style.bottom=(cursorSize[1]-1)+"px";
		this.div.appendChild(img);
		corners.bl=img;

		var img=new Image(tabSize[0],tabSize[1]);
		img.src=this.imgSrc+"iw_br.gif";
		img.style.position="absolute";
		img.style.right="0px";
		img.style.bottom=(cursorSize[1]-1)+"px";
		this.div.appendChild(img);
		corners.br=img;
		this.corners=corners;

		var div=document.createElement("div");
		div.style.position="absolute";
		div.style.backgroundImage ="url("+this.imgSrc+"iw_u.gif)";
		div.style.fontSize="0px";
		div.style.left=tabSize[0]+"px";
		div.style.top="0px";
		div.style.height=tabSize[1]+"px";
		this.div.appendChild(div);
		this.topDiv=div;

		var div=document.createElement("div");
		div.style.position="absolute";
		div.style.backgroundImage ="url("+this.imgSrc+"iw_l.gif)";
		div.style.fontSize="0px";
		div.style.left="0px";
		div.style.top=tabSize[1]+"px";
		div.style.width=tabSize[0]+"px";
		this.div.appendChild(div);
		this.leftDiv=div;

		var div=document.createElement("div");
		div.style.position="absolute";
		div.style.backgroundImage ="url("+this.imgSrc+"iw_b.gif)";
		div.style.fontSize="0px";
		div.style.left=tabSize[0]+"px";
		div.style.bottom=(cursorSize[1]-1)+"px";
		div.style.height=tabSize[1]+"px";
		this.div.appendChild(div);
		this.bottomDiv=div;

		var div=document.createElement("div");
		div.style.position="absolute";
		div.style.backgroundImage ="url("+this.imgSrc+"iw_r.gif)";
		div.style.fontSize="0px";
		div.style.right="0px";
		div.style.top=tabSize[1]+"px";
		div.style.width=tabSize[0]+"px";
		this.div.appendChild(div);
		this.rightDiv=div;

		var img=new Image(cursorSize[0],cursorSize[1]);
		img.src=this.imgSrc+"iw_p.gif";
		img.style.position="absolute";
		this.div.appendChild(img);
		this.cursor=img;

		var div=document.createElement("div");
		div.style.position="absolute";
		div.style.backgroundColor="#FFFFFF";
		div.style.left=tabSize[0]+"px";
		div.style.top=tabSize[1]+"px";
		div.style.backgroundColor="#FFFFE1";
		this.div.appendChild(div);
		this.containerDiv=div;

		var img=new Image(16,16);
		img.src=this.imgSrc+"iw_i.gif";
		img.style.position="absolute";
		img.style.top="7px";
		img.style.left="12px";
		this.div.appendChild(img);

		this.containerDiv.appendChild(this.title);
		this.title.style.fontSize=13;
		this.title.style.fontWeight="bolder";
		this.title.style.color="#000000";
		this.title.style.position="absolute";
		this.title.align="left";
		this.title.style.left="30px";
		this.title.style.top="3px";
		this.title.style.height="13px";
		this.title.style.overflowX="hidden";

		this.containerDiv.appendChild(this.content);
		this.content.align="left";
		this.content.style.position="absolute";
		this.content.style.fontSize="12px";
		this.content.style.color="#333333";
		this.content.style.left="6px";
		this.content.style.top="23px";

		var img=new Image(16,16);
		img.src=this.imgSrc+"iw_c.gif";
		img.style.position="absolute";
		img.style.top=(tabSize[1]-1)+"px";
		img.style.right=tabSize[0]+"px";
		img.style.bottom=(cursorSize[1]-1)+"px";
		LTFunction.setCursorStyle(img,"pointer");
		this.div.appendChild(img);
		LTEvent.addListener(img,"mousedown",LTEvent.cancelBubble);
		LTEvent.bind(img,"click",this,this.closeInfoWindow);
		this.tabSize=tabSize;
		this.cursorSize=cursorSize;
	}
	//返回信息浮窗左上角和锚点的距离，这里是左上角直接作为锚点，因此为[0,0]
	K_Step1InfoWindow.getAnchorPoint=function()
	{
		return [-this.asize[0]*5/6,-this.asize[1]];
	}
	//在信息浮窗大小或者内容发生变化的时候重新设置一些层的位置，可以用来做自适应大小的功能
	K_Step1InfoWindow.changeInfoWin=function()
	{
		var tabSize=this.tabSize;
		var cursorSize=this.cursorSize;
		var asize=[Math.max(this.content.offsetWidth,this.size[0])+40,Math.max(this.content.offsetHeight,this.size[1])+35+cursorSize[1]-1];
		this.div.style.width=asize[0]+"px";
		this.div.style.height=asize[1]+"px";
		this.topDiv.style.width=asize[0]-tabSize[0]*2+"px";
		this.leftDiv.style.height=asize[1]-tabSize[1]*2-(cursorSize[1]-1)+"px";
		this.bottomDiv.style.width=asize[0]-tabSize[0]*2+"px";
		this.rightDiv.style.height=asize[1]-tabSize[1]*2-(cursorSize[1]-1)+"px";
		this.containerDiv.style.width=asize[0]-tabSize[0]*2+"px";
		this.containerDiv.style.height=asize[1]-tabSize[1]*2-(cursorSize[1]-1)+"px";
		this.title.style.width=asize[0]-tabSize[0]*2-50+"px";
		this.cursor.style.right=(asize[0]*1/6)+"px";
		this.cursor.style.top=asize[1]-35+tabSize[1]*2+"px";
		this.corners.br.style.top=asize[1]-33+tabSize[1]*1+"px";
		this.corners.bl.style.top=asize[1]-33+tabSize[1]*1+"px";
		this.asize=asize;
	}
	function LTMarkerCollection(map)
	{
		this.markers=[];
		this._markers=[];
		LTEvent.bind(map,"moveend",this,this.onMapMove);
		LTEvent.bind(map,"zoom",this,this.onMapMove);
		this.map=map;
		if(map.loaded){this.onMapMove();}
	}
	LTMarkerCollection.prototype.showMarker=function(m)
	{
		this.map.addOverLay(m[0]);
		if(m[0].mapText){this.map.addOverLay(m[0].mapText);}
	}
	LTMarkerCollection.prototype.hideMarker=function(m)
	{
		this.map.removeOverLay(m[0]);
		if(m[0].mapText){this.map.removeOverLay(m[0].mapText);}
	}
//添加一个标记，参数分别是标记,显示的最小缩放等级,显示的最大缩放等级
	LTMarkerCollection.prototype.addMarker=function(marker,startZoom,endZoom)
	{
		var m=[marker,startZoom,endZoom];
		if(this.inMapView(m))
		{
			this.markers.push(m);
			this.showMarker(m);
		}
		else
		{
			this._markers.push(m);
		}
	}
//在地图移动的时候执行本方法
	LTMarkerCollection.prototype.onMapMove=function()
	{
		var flag=true;
		var zoom=this.map.getCurrentZoom();
		var bounds=this.map.getBoundsLatLng();
		if(zoom!=this.zoom)
		{
			flag=false;
		}
		else
		{
			if(!this.bounds || !this.bounds.containsBounds(bounds)){flag=false;}
		}
		if(flag){return;}
		this.zoom=zoom;
		this.bounds=new LTBounds(2*bounds.Xmin-bounds.Xmax,2*bounds.Ymin-bounds.Ymax,2*bounds.Xmax-bounds.Xmin,2*bounds.Ymax-bounds.Ymin);
		for(var i=this.markers.length-1;i>=0;i--)
		{
			if(!this.inMapView(this.markers[i]))
			{
				var m=this.markers[i];
				this._markers.push(m);
				this.hideMarker(m);
				this.markers.splice(i,1);
			}
		}
		for(var i=this._markers.length-1;i>=0;i--)
		{
			if(this.inMapView(this._markers[i]))
			{
				var m=this._markers[i];
				this.markers.push(m);
				this.showMarker(m);
				this._markers.splice(i,1);
			}
		}
	}
//判断一个标记是否要添加到地图
	LTMarkerCollection.prototype.inMapView=function(m)
	{
		return this.bounds && this.bounds.containsPoint(m[0].getPoint()) && m[1]<=this.zoom && m[2]>=this.zoom;
	}
	function K_LmlSlideControl(list,config)
	{
		this.currentIndex=-1;
		this.list=list;
		this.config=config;
		var div=document.createElement("div");
		div.align="right";
		div.noWrap="true";
		var style=div.style;
		style.position="absolute";
		style.height="40px";
		style.right="0px";
		style.bottom="0px";
		this.div=div;
		var labelDiv=document.createElement("div");
		var style=labelDiv.style;
		style.position="absolute";
		style.fontSize="12px";
		style.top="0px";
		style.right="0px";
		style.height="20px";
		style.filter="glow(color=#FFFFFF,strength=2)";
		labelDiv.innerHTML="专题地图正在初始化…";
		this.labelDiv=labelDiv;
		div.appendChild(labelDiv);
		var listDiv=document.createElement("div");
		var style=listDiv.style;
		style.position="absolute";
		style.top="20px";
		style.right="0px";
		style.height="20px";
		style.width=list.length*20+"px";
		div.appendChild(listDiv);
		this.listDiv=listDiv;
		for(var i=0;i<list.length;i++)
		{
			var span=document.createElement("div");
			span.align="center";
			span.title=list[i].name;
			var style=span.style;
			style.position="absolute";
			style.top="0px";
			style.left=i*20+"px";
			style.width="20px";
			style.height="20px";
			style.backgroundColor="#FFFFFF";
			style.border="solid 1px #999999";
			span.appendChild(document.createTextNode(i+1));
			span.style.cursor="pointer";
			LTEvent.bind(span,"click",this,this.onListClick(i));
			listDiv.appendChild(span);
		}
	}
	K_LmlSlideControl.prototype.onListClick=function(i)
	{
		return function(e)
		{
			LTEvent.cancelBubble(e);
			this.switchShow(i);
		}
	}
	K_LmlSlideControl.prototype.switchShow=function(i)
	{
		i=i%this.list.length;
		if(this.currentIndex>=0)
		{
			this.listDiv.children[this.currentIndex].style.fontWeight="normal";
			this.listDiv.children[this.currentIndex].style.border="solid 1px #999999";
		}
		this.currentIndex=i;
		this.listDiv.children[this.currentIndex].style.fontWeight="bolder";
		this.listDiv.children[this.currentIndex].style.border="solid 1px #000000";
		if(!this.lmlControl)
		{
			var lmlControl=new LTLmlViewerControl();
			this.lmlControl=lmlControl;
			if(this.config.showPlacemark){lmlControl.showPlacemark=this.config.showPlacemark;};
			map.addControl(lmlControl);
		}
		this.lmlControl.clear();
		this.lmlControl.loadUrl(this.list[i].url);
		if(this.list.length>1)
		{
			setTimeout(LTEvent.getCallback(this,this.onListClick((i+1)%this.list.length)),this.config.delay);
		}
		this.labelDiv.innerHTML=this.list[i].name;
	}
	K_LmlSlideControl.prototype.initialize=function(map)
	{
		this.map=map;
		if(this.config.startDelay!=null && this.config.startDelay>=0 && this.list.length>0)
		{
			setTimeout(LTEvent.getCallback(this,this.onListClick(0)),this.config.startDelay);
		}
	}
	K_LmlSlideControl.prototype.getObject=function()
	{
		return this.div;
	}
	K_LmlSlideControl.prototype.remove=function()
	{
		this.map=null;
	}
	K_LmlSlideControl.prototype.depose=function()
	{
		LTEvent.deposeNode(this.div);
		this.div=null;
	}
	window.K_Function=K_Function;
	window.K_GMap2LTMaps=K_GMap2LTMaps;
	window.K_GMap2LTMapsControl=K_GMap2LTMapsControl;
	window.K_UserPosition=K_UserPosition;
	window.K_CrossControl=K_CrossControl;
	window.K_CenterPlaceControl=K_CenterPlaceControl;
	window.K_PanoramioPhotoControl=K_PanoramioPhotoControl;
	window.K_Step1InfoWindow=K_Step1InfoWindow;
	window.LTMarkerCollection=LTMarkerCollection;
	window.K_LmlSlideControl=K_LmlSlideControl;
}
K_ReverterMap();