


MapSystem.CanvasOption=function(){
	this.graph='poly';
	this.filled=false;
	this.fillColor='#FFFFFF';
	this.stroked=true;
	this.strokeColor='#FF0000';
	this.strokeWeight=1;
	this.startArrow='none';
	this.endArrow='none';
	this.closed=false;
	this.stroke={};
	this.fill={};
};


//键盘控制类
MapSystem.KeyboardHandler = new Class({
    initialize: function(map){
		var theKeyboardHandler=this;
        theKeyboardHandler.map=map;
		theKeyboardHandler.moveStep=1;
		//创建热区层
		theKeyboardHandler.createKeyboardHandler();
		
		
	},
	createKeyboardHandler: function(){
		var theKeyboardHandler=this;
        map=theKeyboardHandler.map;
		
		//重写地图拖拽时要执行的方法	
		map.getContainer().addEvent("keydown", theKeyboardHandler.viewLayer_onKeydownHandler.bindWithEvent(this));
		map.getContainer().addEvent("keyup", theKeyboardHandler.viewLayer_onKeyupHandler.bindWithEvent(this));
	},
	
	viewLayer_onKeydownHandler: function(event){
		
		if(event.target && (event.target.tagName.toLowerCase()=="input" || event.target.tagName.toLowerCase()=="textarea")){
			return;
		}
		
		
		var theKeyboardHandler=this;
        map=theKeyboardHandler.map;
		
		if(theKeyboardHandler.moveStep<30){
			theKeyboardHandler.moveStep+=1;
		}
		theKeyboardHandler.isKeydown=true;
		event.code=event.which ? event.which : event.code;
		switch(event.code){
			
			//上下左右箭头的方式移动地图	//W,S,A,D:CS的方式移动地图
			case 38: case 87: map.scrollMap(0,theKeyboardHandler.moveStep);
				map.trigger(map, "MapMoved", event);
				break;
			case 40: case 83: map.scrollMap(0,-theKeyboardHandler.moveStep);
				map.trigger(map, "MapMoved", event);
				break;
			case 37: case 65: map.scrollMap(theKeyboardHandler.moveStep,0);
				map.trigger(map, "MapMoved", event);
				break;
			case 39: case 68: map.scrollMap(-theKeyboardHandler.moveStep,0);
				map.trigger(map, "MapMoved", event);
				break;
			
			//PageUp,PageDown,Home,End:快速移动地图
			case 33: map.scrollMap(0, theKeyboardHandler.moveStep*5);
				map.trigger(map, "MapMoved", event);
				event.stop();
				break;
			case 34: map.scrollMap(0,-theKeyboardHandler.moveStep*5);
				map.trigger(map, "MapMoved", event);
				event.stop();
				break;
			case 35: map.scrollMap(-theKeyboardHandler.moveStep*5,0);
				map.trigger(map, "MapMoved", event);
				event.stop();
				break;
			case 36: map.scrollMap(theKeyboardHandler.moveStep*5,0);
				map.trigger(map, "MapMoved", event);
				event.stop();
				break;
				
			//=,+,z; -,-,x;的方式放缩地图
			case 187: case 107: case 88: map.zoomIn();
				break;
			case 189: case 109: case 90: map.zoomOut();
				break;
				
			//1,2,3,4的大键盘/小键盘方式直接放缩地图
			case 49: case 97: 
				map.zoomTo(2);
				if(map.controlers["EagleEyeMapControler"]){
					var eagleEyeMap=map.controlers["EagleEyeMapControler"].eagleEyeMap;
					eagleEyeMap.zoomTo(2);
				}
				break;
			case 50: case 98: 
				map.zoomTo(3);
				if(map.controlers["EagleEyeMapControler"]){
					var eagleEyeMap=map.controlers["EagleEyeMapControler"].eagleEyeMap;
					eagleEyeMap.zoomTo(3);
				}
				break;
			case 51: case 99:
				map.zoomTo(4);
				if(map.controlers["EagleEyeMapControler"]){
					var eagleEyeMap=map.controlers["EagleEyeMapControler"].eagleEyeMap;
					eagleEyeMap.zoomTo(4);
				}
				break;
			case 52: case 100: 
				map.zoomTo(5);
				if(map.controlers["EagleEyeMapControler"]){
					var eagleEyeMap=map.controlers["EagleEyeMapControler"].eagleEyeMap;
					eagleEyeMap.zoomTo(5);
				}
				break;
				
				
			//h,小键盘的非数字状态的5:返回homePoint
			case 72: case 12: map.goHome();
				map.trigger(map, "MapMoved", event);
				break;
				
			//r:显示/隐藏路名
			case 82: 
				if(map.getAtlas()[1]===MAP3D_Shenzhen_ROAD){
					map.setTo3DMapView()
					//map.setCenter(map.getCenter(), map.getMapLevel(), [MAP3D_Shenzhen_3D_MAP]);
				}else{
					map.setTo3DMapAndRoadView()
					//map.setCenter(map.getCenter(), map.getMapLevel(), [MAP3D_Shenzhen_3D_MAP, MAP3D_Shenzhen_ROAD]);
				}
				
				break;
				
			//m, Tab:切换地图
			case 77: case 9:
			
				if(map.getAtlas()[0]===MAP3D_Shenzhen_3D_MAP){
					map.setTo2DMapView()
					//map.setCenter(map.getCenter(), map.getMapLevel(), [MAP3D_Shenzhen_2D_MAP]);
				}else{
					map.setTo3DMapView()
					//map.setCenter(map.getCenter(), map.getMapLevel(), [MAP3D_Shenzhen_3D_MAP]);
				}
				event.stop();
				break;
				
			//E:显示/隐藏鹰眼图
			case 69: 
				map.trigger(map, "MapKeydown_E", event);
				break;
				
			//Q:显示/隐藏热区
			case 81: 
				map.trigger(map, "MapKeydown_Q", event);
				break;
				
			//enter:chat
			case 13: 
				if(iChater.bK.style.display=='none'){
					iChater.ca();
				}else{
					iChater.mini();
				}
				break;
				
			default: 
				
				break;
		}
		
		
		//this.fireEvent('onkeydown',evt);
		//map.trigger(map, "MapMoved", event);
	},
	
	viewLayer_onKeyupHandler: function(event){
		if(event.target && (event.target.tagName.toLowerCase()=="input" || event.target.tagName.toLowerCase()=="textarea")){
			return;
		}
		
		
		var theKeyboardHandler=this;
        map=theKeyboardHandler.map;
		
		theKeyboardHandler.isKeydown=false;
		setTimeout(function(){
			if(!theKeyboardHandler.isKeydown){
				theKeyboardHandler.moveStep=1;
				//重新定位热区
				if(map.hotSpot){
					map.hotSpot.recoverHotSpot();
					map.hotSpot.clearUpHotSpotMap();
				}
			}
			
		}, 1000);
		
		
	},
	
	about: function(){
		alert("Kinvix@gmail.com, ^_^");
	}
});

//热区类
MapSystem.HotSpot = new Class({
    initialize: function(map){
		var theHotSpot=this;

        theHotSpot.map = map;

		theHotSpot.enableHotSpotDrawBorder();
		theHotSpot.enableHotSpotDrawFill();
		
		//创建热区层
		theHotSpot.createHotSpot();
		theHotSpot.showHotSpot();
		theHotSpot.createAreaTip();
		theHotSpot.isLoadHotSpotTile=true;
		
		MapSystem.addMapEvent(map, "MapKeydown_Q", function(event){
			
			if(theHotSpot.isHotSpotShowing){
				theHotSpot.hideHotSpot();
			}else{
				theHotSpot.showHotSpot();
			}
		});
		
		var hotSpotImg_onDblClickHandler=function(event){
			var map=this;
			var mousePointInMobileLayerCoords;			
			var mousePointInMapCoords;
			var mousePointInPixelCoords;
			var mousePointInViewLayerCoords;
			var mousePointInViewLayerCoords2;
			var mousePointInFileCoords;
			var mousePointInBlockCoords;
			
			var atlasArray=map.atlas;
			
			//获取鼠标所在位置点的mobileLayer层的坐标
			mousePointInViewLayerCoords={VLx:(event.layer.x), VLy:(event.layer.y)};
			
			//以下是转换成MapCoords坐标
			mousePointInMapCoords=map.converterVL2M(mousePointInViewLayerCoords);
			
			//以下是转换成其他各种坐标
			mousePointInPixelCoords=map.getPixelCoords(mousePointInMapCoords);
			
			mousePointInFileCoords=map.getFileCoords(mousePointInMapCoords, atlasArray[0].sliceSize);
			
			mousePointInMobileLayerCoords=map.getMobileLayerCoords(mousePointInMapCoords);
			
			mousePointInBlockCoords=map.getBlockCoords(mousePointInMapCoords, atlasArray[0].sliceSize);
			
			mousePointInViewLayerCoords2=map.getViewLayerCoords(mousePointInMapCoords);
			
			
			var s="level:"+map.getMapLevel()+";<br />"+
				"MapCoords:"+mousePointInMapCoords.Mx+", "+mousePointInMapCoords.My+";<br />"+
				"PixelCoords:"+mousePointInPixelCoords.Px+", "+mousePointInPixelCoords.Py+";<br />"+
				"FileCoords:"+mousePointInFileCoords.Fx+", "+mousePointInFileCoords.Fy+";<br />"+
				"MobileLayerCoords:"+mousePointInMobileLayerCoords.MLx+", "+mousePointInMobileLayerCoords.MLy+";<br />"+
				"BlockCoords:"+mousePointInBlockCoords.Bx+", "+mousePointInBlockCoords.By+";<br />"+
				"ViewLayerCoords:"+mousePointInViewLayerCoords.VLx+", "+mousePointInViewLayerCoords.VLy+";<br />"+
				
				"ViewLayerCoords2:"+mousePointInViewLayerCoords2.VLx+", "+mousePointInViewLayerCoords2.VLy+";<br />";
			
			//输出位置信息
			//map.mapDebugLayer.innerHTML=s;
			map.setViewCenter(mousePointInMapCoords);
		};
		
		map.viewLayer_onDblClickHandler=hotSpotImg_onDblClickHandler;
    },
	
	//创建热区层
	createHotSpot: function(){
		var theHotSpot=this;
		var map=theHotSpot.map;
		var o;
		var o1;
		var o2;
		var o3;
		
		
		//生成热区总层
		map.mapHotSpotLayer=o=new Element("div");
			o.style.position="absolute";
			o.style.zIndex="5";
			o.style.left="0";
			o.style.top="0";
		map.mapMobileLayer.insertBefore(o, map.mapOverlayLayer);
		

		
			
		//生成热区的绘图描边层-------------------------------------------
		o1=new Element("div");
			o1.setAttribute("id", map.getContainer().id+"_hotSpotDraw");
			o1.style.position="absolute";
			o1.style.zIndex="1";
			o1.style.left="0px";
			o1.style.top="0px";
			o1.style.width="100%";
			o1.style.height="100%";
		map.mapHotSpotLayer.appendChild(o1);
		//map.mapViewLayer.style.cursor=map.cursor.onMapDragable;
		
		var borderColor="#eeee00";
		var fillColor="#ffffff";
		
		if(Browser.Engine.trident){
			map.hotSpotDraw = new Jos.Vml(o1);
			map.hotSpotDraw.mouseDrawElement=map.hotSpotDraw.drawPolygon(null, theHotSpot.isShowHotSpotDrawBorder, theHotSpot.isShowHotSpotDrawFill);
			
			//theHotSpot.hideHotSpotDraw();
			map.hotSpotDraw.mouseDrawElement.hide();
			map.hotSpotDraw.mouseDrawElement.setStrokeColor(borderColor); //设置描边的颜色
			map.hotSpotDraw.mouseDrawElement.setFillColor(fillColor);     //设置热区的填充颜色
			map.hotSpotDraw.mouseDrawElement.setFillOpacity(0.2);         //设置透明度
			
			
		}else{
			var id=map.getContainer().getAttribute("id");
			var temp=document.createElement("div");
			temp.setAttribute("id", id+"_HotSpotDraw_Fill");
			temp.style.opacity="0.2";			
			o1.appendChild(temp);
			
			temp=document.createElement("div");
			temp.setAttribute("id", id+"_HotSpotDraw_Border");
			temp.style.opacity="0.95";			
			o1.appendChild(temp);
			map.hotSpotDraw={};
			map.hotSpotDraw.mouseDrawElement=o1;
			theHotSpot.hotSpotDrawFill = new jsGraphics(id+"_HotSpotDraw_Fill");
			theHotSpot.hotSpotDrawBorder = new jsGraphics(id+"_HotSpotDraw_Border");
		}
		
		
		//生成热区的遮罩图片层--------------------------------------------
		map.mapHotSpotImg=o2=new Element("img");
			o2.src=map.images.hotspot.src;
			o2.style.position="absolute";
			o2.style.zIndex="2";
			
			
			o2.style.border="0";
			//o2.style.background="blue";
			o2.setAttribute("useMap", "#" + map.getContainer().id + "_HotSpot_Map");
		map.mapHotSpotLayer.appendChild(o2);
		
		
		
		
		

		//重写地图拖拽时要执行的方法
		MapSystem.addMapEvent(map, "MapMousemove", theHotSpot.map_onMapMousemove_loadHotSpotHandler.bindWithEvent(this));
		
		//重写地图拖拽时要执行的方法
		MapSystem.addMapEvent(map, "MapDragStart", theHotSpot.map_onMapDragStart_hideHotSpotMapLayerHandler.bindWithEvent(this));
		
		//重写地图拖拽时要执行的方法
		MapSystem.addMapEvent(map, "MapDragEnd", theHotSpot.map_onMapDragEnd_recoverHotSpotHandler.bindWithEvent(this));
		
		MapSystem.addMapEvent(map, "MapXSetCenterEnd", theHotSpot.map_onMapDragEnd_recoverHotSpotHandler.bindWithEvent(this));
		
		
		//重写地图拖拽时要执行的方法
		map.mapViewLayer.removeEvents("mousewheel");
		
		map.mapViewLayer.addEvent("mousewheel", theHotSpot.viewLayer_onMousewheelHandler.bindWithEvent(this));
		
		
		
		//生成热区的地图Map-----------------------------------------------
		map.mapHotSpotMap=o3=document.createElement("map");
			o3.setAttribute("id", map.getContainer().id+"_HotSpot_Map");
			o3.setAttribute("name", map.getContainer().id+"_HotSpot_Map");
			o3.style.zIndex="3";
		map.mapHotSpotLayer.appendChild(o3);
		
		//定义热区tile的对象
		theHotSpot.hotSpotTiles={};
		
		map.mapHotSpotMap.area={};
	

		
		//添加各种事件
		MapSystem.addMapEvent(map, "MapViewCenterChanged", function(event){
			var theHotSpot=this;
			var map=theHotSpot.map;
			
			theHotSpot.recoverHotSpot();
			theHotSpot.clearUpHotSpotMap();
			
		}.bindWithEvent(this));
		
		//添加各种事件
		MapSystem.addMapEvent(map, "MapViewLayerRateChanger", function(event){
			var theHotSpot=this;
			var map=theHotSpot.map;
			
			theHotSpot.recoverHotSpot();
			theHotSpot.clearUpHotSpotMap();
			
		}.bindWithEvent(this));
		
		
		//添加各种事件
		MapSystem.addMapEvent(map, "MapZoomEnd", function(event){
			var theHotSpot=this;
			var map=theHotSpot.map;
			
			Jos.emptyNode(map.mapHotSpotMap);
			
			//翻转标志
			theHotSpot.hotSpotTiles={};
			
			theHotSpot.recoverHotSpot();
			theHotSpot.clearUpHotSpotMap();
			
			
			if(theHotSpot.isShowingHotSpotDraw()){
				theHotSpot.hideHotSpotDraw();
				theHotSpot.showHotSpotDraw();
			}
		}.bindWithEvent(this));
		
		MapSystem.addMapEvent(map, "MapEagleEyeMapDragEnd", function(event){
			var theHotSpot=this;
			var map=theHotSpot.map;
			
			theHotSpot.recoverHotSpot();
			theHotSpot.clearUpHotSpotMap();
			
																	 
		}.bindWithEvent(this));
		
		
		//调整图片适应视图尺寸
		theHotSpot.recoverHotSpot();

	},
	
	isShowingHotSpotDraw: function(){
		var theHotSpot=this;
		var map=theHotSpot.map;
		
		return theHotSpot.currentAreaElement && (map.hotSpotDraw.mouseDrawElement.style.display!="none") ? true : false;
	},
	
	
	//创建热区提示
	createAreaTip:function(){
		var theHotSpot=this;
		var map=theHotSpot.map;
		
		var o=document.createElement("div");
		o.style.position="absolute";
		o.style.left="0px";
		o.style.top="0px";
		if(Browser.Engine.trident4){
			o.style.width="360px";
		}else{
			o.style.width="auto";
		}
		o.style.height="auto";
		theHotSpot.areaTip=map.getContainer().appendChild(o);
		theHotSpot.hideAreaTip();
		
			var o1=document.createElement("div");		
			o1.style.styleFloat="left";
			o1.className="hotSpotAreaTip_content";
			o1.style.borderRight="1px #fff solid";
			o1.style.color="#000033";
			o1.style.width="auto";
			o1.style.lineHeight="12px";
			o1.style.overflow="hidden";
			if(Browser.Engine.trident4){
				o1.style.padding="4px 10px 0 20px";
				o1.style.height="13px";
				o1.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod="crop", src="style/1.0/label/build_name_bg.png")';
			}else{
				o1.style.padding="3px 10px 0 20px";
				o1.style.height="16px";
				o1.style.background="url(style/1.0/label/build_name_bg.png) no-repeat";
			}
			theHotSpot.areaTipContent=theHotSpot.areaTip.appendChild(o1);
		
		
			
	},
	
	showAreaTip:function(placeName){
	    
		var theHotSpot=this;
		var map=theHotSpot.map;
		if(placeName){
            tipinfo=placeName;
			theHotSpot.areaTipContent.innerHTML=placeName;
			theHotSpot.areaTip.style.display="block";
		}
	},
	hideAreaTip:function(placeName){
		var theHotSpot=this;
		var map=theHotSpot.map;
		theHotSpot.areaTip.style.display="none";
	},
	moveAreaTip:function(event){
		var theHotSpot=this;
		var map=theHotSpot.map;
		var left=event.page.x+15;
		var top=event.page.y;
		theHotSpot.areaTip.style.left=left+"px";
		theHotSpot.areaTip.style.top=top+"px";
	},
	
	
	//更新一下热区层的位置
	recoverHotSpot: function(){
		var theHotSpot=this;
		var map=theHotSpot.map;
		var o;
		
		//计算一些必须数据
		var viewLeftTopPoint=map.getViewLeftTopPoint("mobileLayerCoords");
		//此值带有"px"
		var viewLayerWidth=map.mapViewLayer.getStyle("width");
		var viewLayerHeight=map.mapViewLayer.getStyle("height");
	
		
		//设定热区图片的新值
		o=map.mapHotSpotImg;
		o.style.left=viewLeftTopPoint.MLx + "px";
		o.style.top=viewLeftTopPoint.MLy + "px";
		//此值已经带有"px"
		o.style.width=viewLayerWidth;
		o.style.height=viewLayerHeight;
	},
	
	//更新热区map中的所有area
	updateHotSpotMap: function(){
		var theHotSpot=this;
		var map=theHotSpot.map;
		
		var level=map.getAtlas()[0].hotSpot.level;
		var sliceSize=map.getAtlas()[0].hotSpot.sliceSize;
		
		var viewLeftTopPointInFileCoords=map.getViewLeftTopPoint("fileCoords", sliceSize, level);
		var viewRightBottomPointInFileCoords=map.getViewRightBottomPoint("fileCoords", level);
		
		var i;
		var oldId;
		//length=map.mapHotSpotMap.childNodes.length;
		
		
		for(i=0; map.mapHotSpotMap.childNodes[i];){
			var node=map.mapHotSpotMap.childNodes[i];
			var Fx=node.getAttribute("Fx", 2).toInt();
			var Fy=node.getAttribute("Fy", 2).toInt();
			
			
			if(Fx<viewLeftTopPointInFileCoords.Fx 
				|| Fy<viewLeftTopPointInFileCoords.Fy 
				|| Fx>viewRightBottomPointInFileCoords.Fx 
				|| Fy>viewRightBottomPointInFileCoords.Fy){
				
				//如果出界则清除area
				theHotSpot.removeHotSpotArea(node);

			}else{
				//如果未出界则更新area值
				
				theHotSpot.updateHotSpotArea(node);
				
				i++;
			}
			
		}
	
	},
	
	//载入热区文件块
	loadHotSpotTile: function(hotSpot, mousePointerInMapCoords){
	    try{
		var theHotSpot=this;
		var map=theHotSpot.map;

		var mousePointerInFileCoordsOnThisLevel;


		
		//计算此点的hotSpot坐标
		mousePointerInFileCoordsOnThisLevel=map.getFileCoords(mousePointerInMapCoords, hotSpot.sliceSize, hotSpot.level);
		
		var id="hotSpot_"+hotSpot.level+','+mousePointerInFileCoordsOnThisLevel.Fx+','+mousePointerInFileCoordsOnThisLevel.Fy;
		
		if(theHotSpot.hotSpotTiles[id]){
			
		}else{
			
			//翻转标志
			theHotSpot.hotSpotTiles[id]=true;
			
			//生成hotSpot的url
			var url=hotSpot.filePath+hotSpot.level+"\/"+Math.floor(mousePointerInFileCoordsOnThisLevel.Fx/10)+"\/"+mousePointerInFileCoordsOnThisLevel.Fx+","+mousePointerInFileCoordsOnThisLevel.Fy + ".js?id=" + id;
			
			
			//载入数据
			ajax({url:url, type:"text", onSuccess:theHotSpot.parseHotSpotJson.bind(this), onError:theHotSpot.loadError.bind(this), onComplete:null, timeout:15000});
			
		}
		}catch(e){}
		
	},
	
	
	loadError: function(url){
		var theHotSpot=this;
		var map=theHotSpot.map;
		
		var id=url.toLowerCase().split("?id=")[1];

		//window.status=id+" is not loaded!";

		
		//翻转标志
		theHotSpot.hotSpotTiles[id]=null;

		//alert("error!");
	},
	
	//loadHotSpotSuccess
	parseHotSpotJson: function(data, url){
		var theHotSpot=this;
		var map=theHotSpot.map;
		var i;

		if(data){
			
			
			var areaJson=data.split("|");
			areaJson=eval(areaJson[1]);
		
			for(i=0;i<areaJson.length;i++){
				var area=areaJson[i];
				
				//将地图的字符串形式的横纵坐标转化为数组形式
				
				var length=area.xs.split(",").length;

				//注：xs[0]是建筑的中心点坐标，轮廓从1开始
				//如果此坐标串超过1个点，可以组成一个图形
				if(length>1){
					var fileId=url.toLowerCase().split("?id=")[1];
					var tileInfileCoords=fileId.split("_")[1].split(",");
					area.Mxs=area.xs;
					area.Mys=area.ys;
					area.fileId=fileId;
					area.Fx=tileInfileCoords[1];
					area.Fy=tileInfileCoords[2];
					theHotSpot.createHotSpotArea(area);
				}
			}
			
			//map.mapDebugLayer.innerHTML+="; "+map.isDragStart+","+fileId;
		}
		
	},
	
	
	
	
	
	
	//响应事件的处理器函数
	emptyFunction:function(){
	},
	returnTrue:function(){
		return true;
	},
	returnFalse:function(){
		return false;
	},

	
	//鼠标移动
	map_onMapMousemove_loadHotSpotHandler: function(event){
	    if(isSelectAreaStart)
		{
			startDragBox({x:(event.target.style.left.toInt()+event.layer.x), y:(event.target.style.top.toInt()+event.layer.y)});
			return;
		}
		if(isSacleStart)
		{
			previewScale({x:(event.target.style.left.toInt()+event.layer.x), y:(event.target.style.top.toInt()+event.layer.y)});
			return;
		}
		var theHotSpot=this;
		var map=theHotSpot.map;
		
		theHotSpot.moveAreaTip(event);
		
		//判断是否是拖拽状态
		if(!map.isDragStart && theHotSpot.isLoadHotSpotTile && theHotSpot.isHotSpotShowing){
			//alert(4)
			theHotSpot.isLoadHotSpotTile=false;
			
			var mousePointerInMobileLayerCoords;
			var mousePointerInMapCoords;
			
			var viewLeftTopPointInMobileLayer=map.getViewLeftTopPoint("mobileLayerCoords");
			
			
			//计算当前点的MapCoords
			mousePointerInMobileLayerCoords={MLx: (viewLeftTopPointInMobileLayer.MLx+event.layer.x), MLy: (viewLeftTopPointInMobileLayer.MLy+event.layer.y)};
			mousePointerInMapCoords=map.converterML2M(mousePointerInMobileLayerCoords);
			if(event.control){
				map.output("K"+"inv"+"ix says(MapCoords): "+mousePointerInMobileLayerCoords.MLx+","+mousePointerInMobileLayerCoords.MLy+";<br/>", "add");
			}else{
				map.output("");
			}
			//载入当前点的hotSpot数据
			if(map.getMapLevel()<=4){
				theHotSpot.loadHotSpotTile(map.getAtlas()[0].hotSpot, mousePointerInMapCoords);
			}else{
				theHotSpot.hideHotSpotDraw()
			}
			
			setTimeout(function(){
				theHotSpot.isLoadHotSpotTile=true;
			}, 100);
			
			
		}
		
	},
	
	
	map_onMapDragStart_hideHotSpotMapLayerHandler: function(event){
		var theHotSpot=this;
		var map=theHotSpot.map;

		if(theHotSpot.dragEndTimer){
			clearTimeout(theHotSpot.dragEndTimer);
			theHotSpot.dragEndTimer=null;
		}else{
			theHotSpot.hideHotSpot();
		}

		//隐藏placeName的Tip
		theHotSpot.hideAreaTip();

		//map.mapHotSpotImg.style.cursor=map.cursor.onMapDragging;
		//
		//theHotSpot.clearHotSpotMap();

	},
	
	map_onMapDragEnd_recoverHotSpotHandler: function(event){
		var theHotSpot=this;
		var map=theHotSpot.map;

		theHotSpot.dragEndTimer=setTimeout(function(){

			theHotSpot.showHotSpot();
			clearTimeout(theHotSpot.dragEndTimer);
			theHotSpot.dragEndTimer=null;
		
			
		}, 300);
		
		theHotSpot.recoverHotSpot();
		theHotSpot.clearUpHotSpotMap();

		//map.mapHotSpotImg.style.cursor=map.cursor.onMapDragable;
		try{
			$("bottonNav").setCapture();
			$("bottonNav").releaseCapture();
		}catch(e){}
	},
	
	showHotSpot: function(){
		var theHotSpot=this;
		var map=theHotSpot.map;
		map.mapHotSpotLayer.style.display="block";
		theHotSpot.isHotSpotShowing=true;
	},
	hideHotSpot: function(){
		var theHotSpot=this;
		var map=theHotSpot.map;
		map.mapHotSpotLayer.style.display="none";
		theHotSpot.isHotSpotShowing=false;
	},

	clearHotSpotMap: function(){
		var theHotSpot=this;
		var map=theHotSpot.map;
		
		//隐藏placeName的Tip
		theHotSpot.hideAreaTip();

		Jos.emptyNode(map.mapHotSpotMap);
		//翻转标志
		theHotSpot.hotSpotTiles={};
		
	},
	
	
	clearUpHotSpotMap: function(){
		var theHotSpot=this;
		var map=theHotSpot.map;
		
		theHotSpot.hideAreaTip();
		
		//if(Browser.Engine.webkit){
			//清空areas
			Jos.emptyNode(map.mapHotSpotMap);
			//翻转标志
			theHotSpot.hotSpotTiles={};
		//}else{
			//更新areas
			//theHotSpot.updateHotSpotMap();
		//}
		
	},

	//事件处理集合
	viewLayer_onMousewheelHandler: function(event){
		var theHotSpot=this;
		var map=theHotSpot.map;
		
		//阻止默认动作的执行
		event.preventDefault();
		
		//保持同步，防止异步执行
		if(map.isFireMousewheel){
			//翻转标志
			map.isFireMousewheel=false;
			
			
			var mousePointInMobileLayerCoords;
			var mousePointInMapCoords;
			var mousePointInViewLayerCoords;
			//alert(event.target.tagName)
			//获取鼠标所在位置点的mobileLayer层的坐标
			//mousePointInMobileLayerCoords={MLx:(event.target.getStyle("left").toInt()+event.layer.x), MLy:(event.target.getStyle("top").toInt()+event.layer.y)};
			mousePointInViewLayerCoords={VLx:(event.layer.x), VLy:(event.layer.y)};
			
			//以下是转换成MapCoords坐标
			//mousePointInMapCoords=map.converterML2M(mousePointInMobileLayerCoords);
			mousePointInMapCoords=map.converterVL2M(mousePointInViewLayerCoords);
			
			//以下是转换成ViewLayerCoords坐标
			mousePointInViewLayerCoords=map.getViewLayerCoords(mousePointInMapCoords);
			
			//如果是推滚轮
			if(event.wheel==1||event.wheel==2){
				//event.target.setStyle("cursor", map.cursor.onMapZoomIn);
				map.zoomIn(mousePointInViewLayerCoords, mousePointInMapCoords);
				if(map.controlers["EagleEyeMapControler"]){
					var eagleEyeMap=map.controlers["EagleEyeMapControler"].eagleEyeMap;
					eagleEyeMap.zoomIn();
				}

			//如果是拉滚轮
			}else if(event.wheel==-1||event.wheel==-2){
				//event.target.setStyle("cursor", map.cursor.onMapZoomOut);
				map.zoomOut(mousePointInViewLayerCoords, mousePointInMapCoords);	
				if(map.controlers["EagleEyeMapControler"]){
					var eagleEyeMap=map.controlers["EagleEyeMapControler"].eagleEyeMap;
					eagleEyeMap.zoomOut();
				}
			}
			map.isFireMousewheel=true;
		}
		
	},
	
	area_onMouseoverHandler: function(event){
	    if(isSacleStart)
	    {
		 return;
	    }
		var theHotSpot=this;
		var map=theHotSpot.map;
		event=Jos.getEvent(event);		
		var o=Jos.Event.getTarget(event);
		
		map.mapViewLayer.style.cursor="pointer";
		theHotSpot.showAreaTip(o.getAttribute("placeName"));
		theHotSpot.showHotSpotDraw(o);
		
		window.status=o.getAttribute("placeName");
	},
	area_onMouseoutHandler: function(event){
		var theHotSpot=this;
		var map=theHotSpot.map;
		//设定图标
		map.mapViewLayer.style.cursor=map.cursor.onMapDragable;
		//隐藏建筑tip提示
		theHotSpot.hideAreaTip();
		//隐藏建筑描边
		theHotSpot.hideHotSpotDraw();
	},
	


	

	
	area_onFocusHandler: function(event){
		this.blur();
	},
	

	//创建热区Area的方法
	createHotSpotArea: function(area){
		var theHotSpot=this;
		var map=theHotSpot.map;
		var o;

		o=new Element("area");
		o.setAttribute("shape", "poly");
		o.setAttribute("coords", "0,0");
		

		theHotSpot.modifyHotSpotArea(o, area);
		map.mapHotSpotMap.appendChild(o);
		
		o.onmouseover=theHotSpot.area_onMouseoverHandler.bindWithEvent(this);
		o.onmouseout=theHotSpot.area_onMouseoutHandler.bindWithEvent(this);
		o.onfocus=map.onFocus_blurHandler;
		

	},
	
	modifyHotSpotArea: function(areaElement, area){
		var theHotSpot=this;
		var map=theHotSpot.map;

		
		areaElement.setAttribute("placeName", area.name);
		areaElement.setAttribute("pid", area.id);
		areaElement.setAttribute("href", "javascript:;");
		//area的文件fileId
		areaElement.setAttribute("fileId", area.fileId);
		areaElement.setAttribute("Fx", area.Fx);
		areaElement.setAttribute("Fy", area.Fy);
		
		//建筑中心点
		areaElement.setAttribute("Mxs", area.Mxs);
		areaElement.setAttribute("Mys", area.Mys);
		
		
		theHotSpot.updateHotSpotArea(areaElement);


	},
	
	//更新热区area的坐标值
	updateHotSpotArea: function(areaElement){
		var theHotSpot=this;
		var map=theHotSpot.map;
		var i;
		var Mxs=areaElement.getAttribute("Mxs").split(",");
		var Mys=areaElement.getAttribute("Mys").split(",");
		
		
			
		var left=map.mapHotSpotImg.style.left.toInt();
		var top=map.mapHotSpotImg.style.top.toInt();
		
		//根据当前视图位置，重新计算热区的坐标位置
		var thePointerInMobileLayerCoords=map.getMobileLayerCoords({Mx:Mxs[1].toInt(), My:Mys[1].toInt()});
		var coords=(thePointerInMobileLayerCoords.MLx-left) + "," + (thePointerInMobileLayerCoords.MLy-top);

		for(i=2; i<Mxs.length; i++){
			thePointerInMobileLayerCoords=map.getMobileLayerCoords({Mx:Mxs[i].toInt(), My:Mys[i].toInt()});
			coords+="," + (thePointerInMobileLayerCoords.MLx-left) + "," + (thePointerInMobileLayerCoords.MLy-top);
		}

		areaElement.setAttribute("coords", coords);

	},

	
	removeHotSpotArea: function(areaElement){
		var theHotSpot=this;
		var map=theHotSpot.map;
		areaElement.onmouseover=null;
		areaElement.onmouseout=null;
		areaElement.onfocus=null;
		
		Jos.removeNode(areaElement);
		
		theHotSpot.hotSpotTiles[areaElement.fileId]=null;
		
	},
	
	showHotSpotDraw: function(areaElement){
		var theHotSpot=this;
		var map=theHotSpot.map;
		
		

		var strength=0;
		
		var coords;
		
		var borderColor="#eeee00";
		var fillColor="#ffffff";
		
		areaElement=areaElement || theHotSpot.currentAreaElement;
		theHotSpot.currentAreaElement=areaElement;
		if(areaElement.getAttribute("Mxs")){
			var Mxs=areaElement.getAttribute("Mxs").split(",");
			var Mys=areaElement.getAttribute("Mys").split(",");
			
			//根据当前视图位置，重新计算热区的坐标位置
			var thePointerInMobileLayerCoords=map.getMobileLayerCoords({Mx:Mxs[1].toInt(), My:Mys[1].toInt()});
			coords=(thePointerInMobileLayerCoords.MLx).toInt() + "," + (thePointerInMobileLayerCoords.MLy).toInt();
			
			for(i=2; i<Mxs.length; i++){
				thePointerInMobileLayerCoords=map.getMobileLayerCoords({Mx:Mxs[i].toInt(), My:Mys[i].toInt()});
				coords+="," + (thePointerInMobileLayerCoords.MLx).toInt() + "," + (thePointerInMobileLayerCoords.MLy).toInt();
			}

		}else{
			coords="";//areaElement;
		}
		
		if(Browser.Engine.trident){
			
			var strokeOnLevel=[0, 2.4, 1.8, 1.4, 1.2];
			var stroke=strokeOnLevel[map.getMapLevel()];
			//ie闪动效果
			
			//map.mapDebugLayer.innerHTML+="<br/>"+coords;
			map.hotSpotDraw.mouseDrawElement.setPoints(coords);
			map.hotSpotDraw.mouseDrawElement.setStroke(stroke);
			map.hotSpotDraw.mouseDrawElement.show();
		}else{
			
			var strokeOnLevel=[0, 2.3, 2, 1.5, 1];
			var stroke=strokeOnLevel[map.getMapLevel()];
			
			
			coords=coords.split(",");
			
			var x = new Array(coords.length/2); 
			var y = new Array(coords.length/2);
			var i=0;
			for (var j=0;j<coords.length;j++) {
				x[i] = parseInt(coords[j]);
				y[i] = parseInt(coords[j+1]);
				j++;
				i++;
			}
			
			if(theHotSpot.isShowHotSpotDrawFill){
				
				theHotSpot.hotSpotDrawFill.setColor(fillColor);
				theHotSpot.hotSpotDrawFill.fillPolygon(x, y);
				theHotSpot.hotSpotDrawFill.paint();
			}
			if(theHotSpot.isShowHotSpotDrawBorder){
				
				theHotSpot.hotSpotDrawBorder.setColor(borderColor);
				theHotSpot.hotSpotDrawBorder.setStroke(stroke);
				theHotSpot.hotSpotDrawBorder.drawPolygon(x, y);
				theHotSpot.hotSpotDrawBorder.paint();
			}
			map.hotSpotDraw.mouseDrawElement.display="block";
		}
	},
	
	hideHotSpotDraw: function(){
		var theHotSpot=this;
		var map=theHotSpot.map;

		if(Browser.Engine.trident){
			map.hotSpotDraw.mouseDrawElement.hide();

		}else{
			theHotSpot.hotSpotDrawFill.clear();
			theHotSpot.hotSpotDrawBorder.clear();
		}
	},
	
	enableHotSpotDrawBorder: function(){
		this.isShowHotSpotDrawBorder=true;
	},
	disableHotSpotDrawBorder: function(){
		this.isShowHotSpotDrawBorder=false;
	},
	enableHotSpotDrawFill: function(){
		this.isShowHotSpotDrawFill=true;
	},
	disableHotSpotDrawFill: function(){
		this.isShowHotSpotDrawFill=false;
	},
    
	//移除热区层
	removeHotSpot: function(){
		var theHotSpot=this;
		var map=theHotSpot.map;
		MapSystem.removeMapEvent(map, "MapMousemove", theHotSpot.map_onMapMousemove_loadHotSpotHandler);
		Jos.removeNode(map.mapHotSpotLayer);
	},
   
    about: function(){
		alert("Kinvix@gmail.com, ^_^");
	}
});
















































MapSystem.Overlay=new Class({
	//初始化地图引擎
	initialize: function(){	
	
	},
	create: function(){
		
	},
	about: function(){
		alert("Kinvix@gmail.com, ^_^");
	}
});




MapSystem.Marker=new Class({
	//初始化地图引擎
	initialize: function(text){	
		var thisMaker=this;
		thisMaker.parentMapInstance=null;
		thisMaker.parentContainer=null;
		
		thisMaker.text=text;
		
		
	},
	create: function(map){
		var thisMaker=this;
		thisMaker.parentMapInstance=map;
		thisMaker.parentContainer=map.mapMarkerLayer;
		
		thisMaker.container=document.createElement("div");
		
		thisMaker.container.style.position="absolute";
		thisMaker.container.style.left="10px";
		thisMaker.container.style.top="10px";
		thisMaker.container.style.border="1px solid blue";
		thisMaker.container.style.background="white";
		thisMaker.container.style.width="100px";
		thisMaker.container.style.height="100px";
		thisMaker.container.innerHTML=thisMaker.text;
		//thisMaker.container.appendChild(document.createTextNode(thisMaker.text));
		
		
		thisMaker.parentContainer.appendChild(thisMaker.container);

	},
	remove: function(){
		thisMaker.parentContainer.removeChild(thisMaker.container);
		
	},
	about: function(){
		alert("Kinvix@gmail.com, ^_^");
	}
		
});



































MapSystem.Polyline=new Class({
	//初始化地图引擎
	initialize: function(){	
	
	},
	create: function(){
		
	},
	about: function(){
		alert("Kinvix@gmail.com, ^_^");
	}
		
});





//拖拽类
MapSystem.DragPanel=new Class({
	//初始化拖拽对象
	initialize: function(captureTarget, moveTarget, option){
		var thisDragObject=this;
		
		//记录鼠标感应对象
		thisDragObject.captureTarget=captureTarget;
		//记录被移动的对象
		thisDragObject.moveTarget=moveTarget;
		
		thisDragObject.mouseStartPos={};
		thisDragObject.elementStartPos={};
		thisDragObject.elementNowPos={};
		thisDragObject.MouseupStartTime=0;
		
		//记录被移动对象的父层容器
		thisDragObject.container=option&&option.container || null;

		//是否移动对象的判断标志
		thisDragObject.isMoveable=false;
		
		//是否开始拖动的标志
		thisDragObject.isDragStart=false;
		
		//存储鼠标在可拖拽目标内的样式
		thisDragObject.draggableCursor=option&&option.draggableCursor || "";
		//存储鼠标拖拽时的样式
		thisDragObject.draggingCursor=option&&option.draggingCursor || "move";
		
		
		
		//拖拽开始时的接口
		MapSystem.addDomEvent(captureTarget, "Mousedown", function(event){
			var thisDragObject=this;
			
			//如果是左键按下，则开始拖拽，否则，不开始拖拽
			if(event.leftClick){
				//绑定事件到document对象，防止鼠标移动过快造成丢失响应事件的事件源对象
				document.addEvents({
					"mousemove": thisDragObject.handleMousemove.bind(this)
				});
			}
			
			//绑定事件到document对象，防止鼠标移动过快造成丢失响应事件的事件源对象
			document.addEvents({
				"mouseup": thisDragObject.handleMouseup.bind(this)
			});
			
		}.bind(this));
		
		//拖拽开始时的接口
		MapSystem.addDomEvent(captureTarget, "Mouseup", function(event){
			
			
		}.bind(this));
		
		//添加单击事件
		MapSystem.addDomEvent(captureTarget, "Click", function(event){
			//alert("click");
			
		}.bind(this));
		
		//添加双击事件
		MapSystem.addDomEvent(captureTarget, "DblClick", function(event){
			alert("DblClick");
			
		}.bind(this));
		

		//拖拽开始时的接口
		MapSystem.addDomEvent(captureTarget, "DragStart", function(event){
			var thisDragObject=this;
			captureTarget.setStyle("cursor", thisDragObject.draggingCursor);
		}.bind(this));

		
		//正在拖拽中要执行的接口
		MapSystem.addDomEvent(captureTarget, "DragMoving", function(event){
			var thisDragObject=this;
			
		}.bind(this));

		//拖拽结束时的接口
		MapSystem.addDomEvent(captureTarget, "DragEnd", function(event){
			var thisDragObject=this;
			captureTarget.setStyle("cursor", thisDragObject.draggableCursor);
		}.bind(this));
	
		
		//给容器绑定鼠标按下事件
		captureTarget.addEvent("mousedown", thisDragObject.handleMousedown.bind(this));
		
	},
	
	//设定鼠标进入可拖拽层时的鼠标样式的方法
	setDraggableCursor: function(cursor){
		this.draggableCursor=cursor;
	},
	
	//设定拖拽时鼠标样式的方法
	setDraggingCursor: function(cursor){
		this.draggingCursor=cursor;	
	},
	//获取鼠标进入可拖拽层时的鼠标样式的方法
	getDraggableCursor: function(){
		return this.draggableCursor;
	},
	
	//获取拖拽时鼠标样式的方法
	getDraggingCursor: function(){
		return this.draggingCursor;
	},
	
	//当鼠标按下时执行的方法
	handleMousedown: function(event){
		var thisDragObject=this;
		
		//阻止默认动作的执行
		event.preventDefault();
		
		//拖拽暂时关闭开关
		thisDragObject.isMoveable=true;
		
		//拖拽状态开关
		thisDragObject.isDragStart=true;
		
		//记录当前时间，用来做是否双击的判断
		thisDragObject.mousedownStartTime=(new Date()).getTime();
		
		//记录被移动对象的起始状态：鼠标在拖拽开始时的位置
		thisDragObject.mouseStartPos.x=event.page.x;
		thisDragObject.mouseStartPos.y=event.page.y;
		
		//记录被移动对象的起始状态，元素在拖拽开始时的位置
		thisDragObject.elementStartPos.left=thisDragObject.moveTarget.getStyle("left").toInt();
		thisDragObject.elementStartPos.top=thisDragObject.moveTarget.getStyle("top").toInt();

		//是否开始拖动的标志
		//thisDragObject.isDragStart=false;
		thisDragObject.isDragStart=true;
		
		
		
		//执行地图拖拽层鼠标按下事件的处理方法
		map.trigger(thisDragObject.captureTarget, "Mousedown", event);
		
		//执行地图拖拽开始的函数
		map.trigger(thisDragObject.captureTarget, "DragStart", event);
		

	},
	
	//设置成可以移动的方法
	setToOnDragMoving:function(){
		var thisDragObject=this;
		//设置可拖拽状态
		thisDragObject.isMoveable=true;
	},
	
	//当鼠标移动时执行的方法
	handleMousemove: function(event){
		var thisDragObject=this;
		event.preventDefault();
	
		//如果没有被暂时关闭地图拖拽
		if(thisDragObject.isMoveable){
		
			//设置移动对象为不可移动状态
			thisDragObject.isMoveable=false;
			
			

			//地图可移动图层根据鼠标动作进行移动，+：正向拖动，-：反向移动
			var left=thisDragObject.elementStartPos.left+(event.page.x-thisDragObject.mouseStartPos.x);
			var top=thisDragObject.elementStartPos.top+(event.page.y-thisDragObject.mouseStartPos.y);
			
			//移动对象到坐标位置
			thisDragObject.moveTo({left: left, top: top}, event);
			
			//执行拖拽函数
			map.trigger(thisDragObject.captureTarget, "DragMoving", event);
			
			/*
			if((!thisDragObject.isDragStart) && (Math.abs(thisDragObject.mouseStartPos.x-event.page.x)>=1 || Math.abs(thisDragObject.mouseStartPos.y-event.page.y)>=1)){
				thisDragObject.isDragStart=true;
				//执行地图拖拽开始的函数
				map.trigger(thisDragObject.captureTarget, "DragStart", event);
			}
			*/
			
			//clearTimeout(thisDragObject.timer);
			//30毫秒后执行setToOnDragMoving方法
			thisDragObject.timer=thisDragObject.setToOnDragMoving.delay(30, this);
		}
	},
	
	
	//当鼠标松开时执行的方法
	handleMouseup: function(event){
		var thisDragObject=this;
		//event.stopPropagation();
		
		//删除事件绑定，以免ie内存泄露
		document.removeEvents("mousemove");
		document.removeEvents("mouseup");
		
		//执行地图拖拽层鼠标释放事件的处理方法
		map.trigger(thisDragObject.captureTarget, "Mouseup", event);
		
		//拖拽状态开关
		thisDragObject.isDragStart=false;
		//执行拖拽完毕的函数
		map.trigger(thisDragObject.captureTarget, "DragEnd", event);

		var nowTime=(new Date()).getTime();
		
		if(nowTime-thisDragObject.mousedownStartTime<=500 && Math.abs(thisDragObject.mouseStartPos.x-event.page.x)<=2 && Math.abs(thisDragObject.mouseStartPos.y-event.page.y)<=2){
			map.trigger(thisDragObject.captureTarget, "Click", event);
		}
		
		/*
		if(nowTime-thisDragObject.MouseupStartTime<=800&&Math.abs(thisDragObject.mouseStartPos.x-event.page.x)<=2&&Math.abs(thisDragObject.mouseStartPos.y-event.page.y)<=2){
			map.trigger(thisDragObject.captureTarget, "DblClick", event);
		}else{
			if(nowTime-thisDragObject.mousedownStartTime<=500&&Math.abs(thisDragObject.mouseStartPos.x-event.page.x)<=2&&Math.abs(thisDragObject.mouseStartPos.y-event.page.y)<=2){
				
				setTimeout(function(){
					thisDragObject.MouseupStartTime;
					var nowTime=(new Date()).getTime();
					alert(nowTime-thisDragObject.MouseupStartTime);
					if(nowTime-thisDragObject.MouseupStartTime>800){
						map.trigger(thisDragObject.captureTarget, "Click", event);
					}
				},800);
			}
		}
		thisDragObject.MouseupStartTime=(new Date()).getTime();
		*/
		//return true;

	},
	
	//按照坐标值来移动对象的方法
	moveTo: function(nextPos, event){
		var thisDragObject=this;
		if(thisDragObject.elementNowPos.left!=nextPos.left||thisDragObject.elementNowPos.top!=nextPos.top){
			
			//地图可移动图层根据鼠标动作进行移动
			thisDragObject.elementNowPos.left=nextPos.left;
			thisDragObject.elementNowPos.top=nextPos.top;
			
			thisDragObject.moveTarget.style.left=nextPos.left+"px";
			thisDragObject.moveTarget.style.top=nextPos.top+"px";

			/*
			thisDragObject.moveTarget.setStyles({
				'left': nextPos.left+"px",
				'top': nextPos.top+"px"
			});
			*/
			
		}
	},
	
	//按照位移来移动对象的方法
	moveBy: function(nextDistance){
		var thisDragObject=this;
		thisDragObject.moveTarget.style.left=(thisDragObject.elementStartPos.left+nextDistance.x).toInt()+"px";
		thisDragObject.moveTarget.style.top=(thisDragObject.elementStartPos.top+nextDistance.y).toInt()+"px";
		
		/*
		thisDragObject.moveTarget.setStyles({
			'left': (thisDragObject.elementStartPos.left+nextDistance.x).toInt()+"px",
			'top': (thisDragObject.elementStartPos.top+nextDistance.y).toInt()+"px"
		});
		*/
	},
	

	
	about: function(){
		var thisDragObject=this;
		alert(thisDragObject.text.about);
	}
});
var gaTimer;
var gas=function(){
	if(typeof _gat!="undefined"){
		var pageTracker = _gat._getTracker("UA-393149-5");
		pageTracker._initData();
		pageTracker._trackPageview();
		gaTimer=null;
		//alert(3)
	}else{
		gaTimer=setTimeout(gas, 1000);
	}	
};
gaTimer=setTimeout(gas, 1000);


MapSystem.PlaceLabel=new Class({
	//初始化地图引擎
	initialize: function(Mx, My, title, url, type){	
		var thisPlaceLabel=this;
		thisPlaceLabel.parentMapInstance=null;
		thisPlaceLabel.parentContainer=null;
		
		thisPlaceLabel.Mx=Mx;
		thisPlaceLabel.My=My;
		thisPlaceLabel.title=title;
		thisPlaceLabel.url=url;
		thisPlaceLabel.type=type || "company";
		
		
	},
	create: function(map){
		var thisPlaceLabel=this;
		thisPlaceLabel.parentMapInstance=map;
		thisPlaceLabel.parentContainer=map.mapMarkerLayer;
		
		
		thisPlaceLabel.container=document.createElement("div");
		
		thisPlaceLabel.container.style.position="absolute";

		thisPlaceLabel.parentContainer.appendChild(thisPlaceLabel.container);
		
		
		map.createPlaceLabel(thisPlaceLabel.Mx, thisPlaceLabel.My, "GPSLocate", thisPlaceLabel.title, thisPlaceLabel.url, thisPlaceLabel.type, "iconText", thisPlaceLabel.container);

	},
	remove: function(){
		var thisPlaceLabel=this;
		thisPlaceLabel.parentContainer.removeChild(thisPlaceLabel.container);
		
	},
	about: function(){
		alert("Kinvix@gmail.com, ^_^");
	}
		
});

//暂未使用
MapSystem.Tile = new Class({
    initialize: function(Fx, Fy, level, map){
		var theTile=this;
        theTile.Fx = Fx;
        theTile.Fy = Fy;
        theTile.level = level;
        theTile.map = map;
    },
    
    getFx: function(){
        return this.Fx;
    },
    
    getFy: function(){
        return this.Fy;
    },
    
    getLevel: function(){
        return this.level;
    },
    
    getMapModel: function(){
        return this.map;
    },
    
    getUrl: function(){
        return this.map.getCurrentMapType().getUrl(this.level, this.Fx, this.Fy);
    }
});