var MapTypeStatus=null;
function G_SATEMapTypeControl(gmap){
	this.map = gmap;
}
G_SATEMapTypeControl.prototype = new GHierarchicalMapTypeControl();
G_SATEMapTypeControl.prototype.initialize = function (){
		var container = document.createElement("div");
		container.id = "G_SATEMapTypeControl";
		container.style.width="75px";
		
		var imgBtn = document.createElement("img");
		imgBtn.src="images/index/satellite_D.gif";
		imgBtn.id = "G_SATELLITE_MAP";
		imgBtn.title = "卫星图";
		imgBtn.className="mouseOnStyle";
		
		//setSATEGType;
		GEvent.addDomListener(imgBtn, 'click',this.setSATEGType);
		container.appendChild(imgBtn);
		
		var mapLabelDIV=document.createElement("div");
		mapLabelDIV.id="mapLabel";
		mapLabelDIV.innerHTML="<input id='checkbox_label' type='checkbox' onclick='showLabel(this)'/>显示标签</div>";
		mapLabelDIV.style.backgroundColor="#fff";
		mapLabelDIV.style.display="none";
		container.appendChild(mapLabelDIV);
		
		this.map.getContainer().appendChild(container);
		return container;
} 

G_SATEMapTypeControl.prototype.getDefaultPosition = function() {
	return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(5,7));
}


var mlc;
G_SATEMapTypeControl.prototype.setSATEGType = function(){
	//判断是否已经处于选择状态，是则返回
	if(MapTypeStatus=="G_SATEMapType"){
		return;
	}
	MapTypeStatus="G_SATEMapType";
	gmap.setMapType(G_SATELLITE_MAP);
	if(ov){
		ov.setMapType(G_SATELLITE_MAP);
	}
	var imgBtn_SATELLITE=document.getElementById("G_SATELLITE_MAP");
	var imgBtn_MAP=document.getElementById("G_NORAMAL");
	imgBtn_SATELLITE.src="images/index/satellite_S.gif";
	imgBtn_MAP.src="images/index/gzmap_D.gif";
	
	var container=document.getElementById("G_SATEMapTypeControl");
	var mapLabelcontainer=document.getElementById("mapLabel");
	var checkbox_label=document.getElementById("checkbox_label");
	checkbox_label.checked=false;
	 mlc=mapLabelcontainer;
	GEvent.addDomListener(container, 'mousemove',function(){

		setTimeout("mlc.style.display='block'",1000);
		
	});
	GEvent.addDomListener(container, 'mouseout',function(){
		setTimeout("mlc.style.display='none'",2000);
		//mapLabelcontainer.style.display="none";
		
	});
}
function showLabel(checkbox){
	if(checkbox.checked){
		var mapOptions = {opacity: 0.75, minResolution:0, maxResolution: 19};
		var tiledmap = new esri.arcgis.gmaps.TiledMapServiceLayer(statellURL, mapOptions, addTiledMap);
    }else{
    	mapExtension.removeFromMap(gOverlays);
	}
	
}
function addTiledMap(gTileLayer) {
	mapExtension=new esri.arcgis.gmaps.MapExtension(gmap);
    //Add tile layer as a GTileLayerOverlay using mapExtension
    gOverlays = mapExtension.addToMap(gTileLayer);
  }
