﻿var PageMap={}
/********************************************************
* 创建详细页面的地图
* 参数： cx，cy：中心点坐标；
*        bigMapId是大地图的容器的Id，bigH，bigW分别是大地图的宽和高
*        smallMapId是小地图容器的Id，smallH,smallW分别是小地图的宽和高
* 执行后：PageMap.mapB 是大地图对象， PageMap.mapS是小地图对象
*.......................................................*/
PageMap.loadDetailMap=function(cx,cy,bigMapId,smallMapId,showPaneId,is3D){
    PageMap.mapB = new FtMap($P(bigMapId),$P(bigMapId).clientWidth,$P(bigMapId).clientHeight);
    var o = PageMap.mapB.eMapToGis(cx,cy);
    PageMap.mapB.cL = o.l;
    PageMap.mapB.cB = o.b;
    PageMap.mapB.showBubble = false;
    PageMap.mapB.showPane = true;//不显示面板
    PageMap.mapB.showPaneLink=true;
    PageMap.mapB.canDoubleClick = true;
    PageMap.mapB.canScrollWheelZoom = false;
    PageMap.mapB.mapLevel = 16;
    PageMap.mapB.showControl = true;
    if(showPaneId){
        PageMap.mapB.showPaneId=showPaneId;
    }
    PageMap.mapB.showFlagPrice=true;    //房价
    PageMap.mapB.showFlag=true;
    PageMap.mapB.showHots=true;
    if(is3D){
    PageMap.mapB.changeType(FtMap.Map_Edushi);   
    }else{ PageMap.mapB.changeType(FtMap.Map_Satellite);}    
    PageMap.mapS = new FtMap($P(smallMapId),$P(smallMapId).clientWidth,$P(smallMapId).clientHeight);
    PageMap.mapS.cL = o.l;
    PageMap.mapS.cB = o.b;
    PageMap.mapS.showBubble = false;  
    PageMap.mapS.canDoubleClick = false;
    PageMap.mapS.canScrollWheelZoom = false;
    PageMap.mapS.mapLevel = 14;
    PageMap.mapS.showControl = false;
    PageMap.mapS.showCopyright = false;
    PageMap.mapS.changeType(FtMap.Map_GMap2D);    
   
    Methods.setObjEvent($P(bigMapId),"resize",_atuoSize);
    function _atuoSize(){       
        PageMap.mapB.setWidth($P(bigMapId).clientWidth);
        PageMap.mapB.setHeight($P(bigMapId).clientHeight);
        PageMap.mapS.setWidth($P(smallMapId).clientWidth);
        PageMap.mapS.setHeight($P(smallMapId).clientHeight);
    }
}

PageMap.showMapChang=function()
{//鹰眼隐藏、显示
	if($P("eye").style.display != "none")
	{
		$P("eye").style.display = "none";
		$P("eye_btn").className = "eye_btn_s";
	}else{
		$P("eye").style.display = "block";
		$P("eye_btn").className = "eye_btn_h";
	}
}

PageMap.showLeftItem=function()
{//左右伸缩 
  if($P("list_left").style.display == "none"){
      if(PageMap.mapB)PageMap.mapB.setWidth($P("map_right").clientWidth-316);
      $P("list_left").style.display = "block";    
      $P("map_right").className = "map_right";
      $P("ch_size").className = "ch_size_btn1";
      $P("sh_left").style.display = "block";
  }else{
      $P("list_left").style.display = "none"; 
      $P("map_right").className = "";
      $P("ch_size").className = "ch_size_btn2";
      $P("sh_left").style.display = "none";
      if(!browseris.ie){
          PageMap.mapB.setWidth($P("map_right").clientWidth-5);        
      }
  }
}

PageMap.showFullItem=function()
{//显示、退出全屏      
       if($P("divHead").style.display == "none"){            
                if(PageMap.mapB){
                    if($P("list_left").style.display == "none"){
                        PageMap.mapB.setWidth($P("map_right").clientWidth-230);
                    }
                }
            $P("divHead").style.display = "block";
            $P("list_left").style.display = "block";    
            $P("map_right").className = "map_right";
          //  $P("ch_size").className = "ch_size_btn1";
            $P("showfull").className = "show_full";
            $P("showfull").innerHTML = "显示全屏";
           // $P("sh_left").style.display = "block";
            if(browseris.ie){}else{
                PageMap.mapB.setHeight($P("map_right").clientHeight);
            }
        }else{
            $P("divHead").style.display = "none"; 
            $P("list_left").style.display = "none";
            $P("map_right").className = "";
            $P("showfull").className = "return_full";
            $P("showfull").innerHTML = "退出全屏";
           // $P("ch_size").className = "ch_size_btn2";
           // $P("sh_left").style.display = "none";
            if(!browseris.ie){
                PageMap.mapB.setWidth($P("map_right").clientWidth);                
            }
            PageMap.mapB.setHeight(document.documentElement.clientHeight-30);
        }
}

/********************************************************
* 创建大地图
* 参数： cx，cy：中心点坐标；
*        mapId是地图的容器的Id，h，w分别是地图的宽和高
* 执行后：PageMap.mapB 是地图对象
*.......................................................*/
PageMap.loadBigMap=function(cx,cy,mapId,showPaneId,is3D){
    PageMap.mapB = new FtMap($P(mapId),$P(mapId).clientWidth,$P(mapId).clientHeight);
    var o = PageMap.mapB.eMapToGis(cx,cy);
    PageMap.mapB.cL = o.l;
    PageMap.mapB.cB = o.b;
    PageMap.mapB.canDoubleClick = true;
    PageMap.mapB.canScrollWheelZoom = true;
    PageMap.mapB.mapLevel = 14;
    PageMap.mapB.showControl = true;
    if(showPaneId){
        PageMap.mapB.showPaneId=showPaneId;
    }
    PageMap.mapB.showFlag=true;
    PageMap.mapB.showHots=true;
    PageMap.mapB.showPaneLink=true;
    PageMap.mapB.showPane=true;
    PageMap.mapB.showFlagPrice=true;    //房价
    if(is3D){
       PageMap.mapB.changeType(FtMap.Map_Edushi);
    }else{
        PageMap.mapB.changeType(FtMap.Map_Satellite);    
    }     
    Methods.setObjEvent($P(mapId),"resize",_atuoSize);
    $P(mapId).sizeChanged=_atuoSize;       
    function _atuoSize(){       
        PageMap.mapB.setWidth($P(mapId).clientWidth-2);
        PageMap.mapB.setHeight($P(mapId).clientHeight);
    }
}

/********************************************************
* 创建小地图
* 参数： cx，cy：中心点坐标；
*        mapId是地图的容器的Id，h，w分别是地图的宽和高
* 执行后：PageMap.mapS 是地图对象
*.......................................................*/
PageMap.loadSmallMap=function(cx,cy,mapId,w,h,is3D){    
    PageMap.mapS = new FtMap($P(mapId),w,h);
    var o = PageMap.mapS.eMapToGis(cx,cy);
    PageMap.mapS.cL = o.l;
    PageMap.mapS.cB = o.b;
    PageMap.mapS.showBubble = false;
    PageMap.mapS.showPane = false;//不显示面板
    PageMap.mapS.canDoubleClick = false;
    PageMap.mapS.canScrollWheelZoom = false;
    PageMap.mapS.mapLevel = 12;
    PageMap.mapS.showControl = false;
    PageMap.mapS.showCopyright = false;
    if(is3D){
        PageMap.mapS.changeType(FtMap.Map_Edushi);
        _atuoSize();
    }else{
        PageMap.mapS.changeType(FtMap.Map_GMap2D);
        Methods.setObjEvent(window,"resize",_atuoSize)
    }
    function _atuoSize(){
        PageMap.mapS.setWidth($P(mapId).clientWidth-2);
        PageMap.mapS.setHeight($P(mapId).clientHeight);
    }  
}
PageMap.showFlagPane=function(cx,cy,hid,bName){
   var currMap = null;
    if(PageMap.mapB){
        currMap=PageMap.mapB;
    }else if(PageMap.mapS){
        currMap=PageMap.mapS;
    }
    if(!currMap) return;
    if(cx==0 && cy==0){ return;}
    else if ((cx>112184||cx<-25676||cy>70189||cy<-22920)&&currMap._mapType==FtMap.Map_Edushi){ }
    var o = currMap.eMapToGis(cx,cy); 
    currMap.showFlagPane(o.l,o.b,hid,bName);
}

PageMap.setCenter=function(cx,cy,l){
   var currMap = null;
    if(PageMap.mapB){
        currMap=PageMap.mapB;
    }else if(PageMap.mapS){
        currMap=PageMap.mapS;
    }
    if(!currMap) return;
    if(cx==0 && cy==0){ return;}
    else if ((cx>112184||cx<-25676||cy>70189||cy<-22920)&&currMap._mapType==FtMap.Map_Edushi){ }
    var o = currMap.eMapToGis(cx,cy);
    if(l&&l>0){currMap._eMapLevel = l; }
    else{currMap._eMapLevel = 2;}
    currMap.setMapCenter(o.l,o.b);
}

PageMap.changeType=function(t){
    if(PageMap.mapB){
        PageMap.mapB.changeType(t);
    }
}

/*地图定位*/
PageMap.movePos=function(buildingId,x,y,ht){  
    if(ht==null) ht = 1;      
    var params = "x="+x+"&y="+y;
    window.open("/map/default.aspx?"+params);
}

 PageMap.highLighHots=function(bIds,onlyHot){
   var currMap = null;
    if(PageMap.mapB){
        currMap=PageMap.mapB;
    }else if(PageMap.mapS){
        currMap=PageMap.mapS;
    }else{
        return;
    }   
    currMap.highLightHots(bIds,onlyHot);
 }
 
 
  PageMap.cancelHighLightHots=function(){
   var currMap = null;
    if(PageMap.mapB){
        currMap=PageMap.mapB;
    }else if(PageMap.mapS){
        currMap=PageMap.mapS;
    }else{
        return;
    }
    currMap.cancelHighLightHots();
  }
  
 /*获取当前屏幕的所有小区编号*/
 PageMap.getScreenBuildingIds=function(){
    var currMap = null;
    if(PageMap.mapB){
        currMap=PageMap.mapB;
    }else if(PageMap.mapS){
        currMap=PageMap.mapS;
    }else{
        return "";
    }
	//取得flash的Id
	var ids = currMap.getScreenBuildingIds();
	return ids;
 }
 
 /*显示屏幕泡泡*/
  PageMap.showBubble=function(sender,text){
    var currMap = null;
    if(PageMap.mapB){
        currMap=PageMap.mapB;
    }else if(PageMap.mapS){
        currMap=PageMap.mapS;
    }else{
        return "";
    }
	if(!text) text="";
	//让js显示泡泡
	currMap.showScreenBubbles(text);
 }
 
  /*擦除公交路线*/
  PageMap.eraseLine=function(){
    var currMap = null;
    if(PageMap.mapB){
        currMap=PageMap.mapB;
    }else if(PageMap.mapS){
        currMap=PageMap.mapS;
    }else{
        return "";
    }
    currMap.drawTrafficLine("","");	
	currMap.cancelHighLightHots();
 }
 
 PageMap.isShowBubble=function()
 {//是否显示泡泡 地图级别条件
    var currMap = null;
    if(PageMap.mapB){
        currMap=PageMap.mapB;
    }else if(PageMap.mapS){
        currMap=PageMap.mapS;
    }else{
        return false;//当前没有地图
    }
  
    if(currMap._mapType.toLowerCase()=="map_edushi"){
        return currMap._eMapLevel<4?true:false;
    }else{
        return currMap.mapLevel>=16? true:false;
    } 
 }
 
PageMap.zoom=function()
{//放大地图
    if(PageMap.mapB){
        currMap=PageMap.mapB;
    }else{ return;}         
    if(currMap._mapType.toLowerCase()=="map_edushi"){currMap.zoomTo(3); }
    else{currMap.zoomTo(16);}     
}

/********************************************************
* 创建学区图
* 参数： x，y：中心点坐标；
* mapId是地图的容器的Id，h，w分别是地图的宽和高
*.......................................................*/
function SchoolMapFactory(con,x,y,scId,bIds)
{       
    var Schl = new FtMap($P(con),$P(con).clientWidth,$P(con).clientHeight);
    var o = Schl.eMapToGis(x,y);
    Schl.cL = o.l;
    Schl.cB = o.b;     
    Schl.changeType(FtMap.Map_Edushi);
    
    Schl.onMapLoaded = function(){window.setTimeout(function(){},500);Schl.highLightHots(bIds,true);Schl.setMapCenter(o.l+0.000001,o.b,false,4);};   
    Schl.onBuildingClicked=function(bid){GotoPage('/house/trade/housemap.aspx?ln=1&sc='+scId+'&bid='+bid,'_blank')};    
       /*显示屏幕泡泡*/
    Schl.showBubble=function(sender,text){ window.setTimeout(function(){},100);  Schl.showScreenBubbles(text);};    
    Schl.onPositionChanged = function(){ window.setTimeout(function(){},100);
      Methods.getAjaxStrAsync('/building/DataOffer.aspx?way=BubbleByBuildingIds&encode=UTF-8&ht=1&ajax=yes&sc='+scId+'&bid='+bIds,Schl.showBubble); 
    };
    return Schl;
}
