import com.common.ConfigUtil; import com.common.ConstUtil; import com.server.QueryAction; import com.supermap.web.actions.MapAction; import com.supermap.web.core.Feature; import com.supermap.web.core.geometry.GeoLine; import com.supermap.web.core.geometry.GeoPoint; import com.supermap.web.core.geometry.GeoRegion; import com.supermap.web.core.styles.PictureMarkerStyle; import com.supermap.web.mapping.ElementsLayer; import com.supermap.web.mapping.FeaturesLayer; import com.supermap.web.mapping.GraphicsLayer; import com.utils.CommonUtility; import com.view.VideoTitleWindow; import flash.events.Event; import flash.events.MouseEvent; import mx.controls.Alert; import mx.controls.Tree; private var featureStyle:Object; private function checkBox_click(event:Event):void { if(!featureStyle) featureStyle = new Object(); var state:String = Tree(event.currentTarget).selectedItem.@STATE; var layerId:String = Tree(event.currentTarget).selectedItem.@CDID; if(layerId=="ALL") { checkAllLayer(state); return; } currSelectedLayerId = layerId; featureStyle[currSelectedLayerId] = Tree(event.currentTarget).selectedItem.@CDTB; if(state == "1") { var query:QueryAction = new QueryAction(); query.queryLayer(currSelectedLayerId,QueryLayerEvent.QUERY_SUCCESS,""); } else { map.infoWindow.closeButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK)); if(this.fLayer.features.length > 0) { var name:String; for(var i:int = this.fLayer.features.length - 1; i > -1; i-- in this.fLayer.features) { name = this.fLayer.features[i].name; if(name.indexOf(currSelectedLayerId) == 0) this.fLayer.removeFeature(this.fLayer.features[i]); } } } } /** * 图层权限按钮处理 */ private function checkAllLayer(state:String):void { if(state == "1") { // 遍历所有菜单配置 var list:XMLList = menuXML.children(); for each( var xmlChildren:XML in list) { if(xmlChildren.@CDID=="ALL") { continue; } xmlChildren.@STATE="1"; var query:QueryAction = new QueryAction(); query.queryLayer(xmlChildren.@CDID,QueryLayerEvent.QUERY_SUCCESS,""); } } else { map.infoWindow.closeButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK)); if(this.fLayer.features.length > 0) { var name:String; for(var i:int = this.fLayer.features.length - 1; i > -1; i-- in this.fLayer.features) { this.fLayer.removeFeature(this.fLayer.features[i]); } clearAllCheckedMenu(); } } return; } private function queryLayerSuccess(event:QueryLayerEvent):void { var obj:Object = event.data; if(obj == null) { Alert.show("查询失败!","错误"); return; } var features:Array = obj.features; var layerId:String = obj.layerId; for each(var fea:Feature in features) { try { if(fea.geometry is GeoPoint) { var markerStyle:PictureMarkerStyle = new PictureMarkerStyle(); markerStyle.source = featureStyle[layerId].toString(); fea.style = markerStyle; } else if (fea.geometry is GeoLine) { fea.style = ConfigUtil.getPolylineStyle(); } else if(fea.geometry is GeoRegion) { if(layerId == ConstUtil.L_ID_AQ_GQ) { fea.style = ConfigUtil.getPolygonStyle(0xffffff,0); }else if(layerId == ConstUtil.L_ID_BW_AQ){ fea.style = ConfigUtil.getPolygonStyle(uint(0x009933),0.0,0x000000,1,0.0); }else{ fea.style = ConfigUtil.getPolygonStyle(); } } fea.name = layerId; fea.useHandCursor = true; fea.mouseChildren = false; fea.buttonMode = true; fea.addEventListener(MouseEvent.CLICK,featureClick); this.fLayer.addFeature(fea); } catch(err:Error) { } } } private function featureClick(event:MouseEvent):void { var fea:Feature = event.currentTarget as Feature; if(fea.name == ConstUtil.L_ID_SP) { var video:VideoTitleWindow = new VideoTitleWindow(); CommonUtility.showTitleWindow(video,false); video.play(fea.attributes.WJLJ); return; } map.infoWindow.label = ConfigUtil.getMapLayerLabel(fea.name); map.infoWindow.setStyle("backgroundColor",0xFF1A96C8); map.infoWindow.infoWindowLabel.setStyle('color', 0xffffff); map.infoWindow.infoWindowLabel.setStyle('fontFamily', "华文新魏"); map.infoWindow.infoWindowLabel.setStyle('fontSize', "16"); this.showInfoGrid(fea); // map.infoWindow.content = this.getInfoWinGrid(fea.attributes.ID,fea.name,fea.attributes); // map.infoWindow.label = ConfigUtil.getMapLayerLabel(fea.name); // map.infoWindow.setStyle("backgroundColor",0xFF1A96C8); // map.infoWindow.infoWindowLabel.setStyle('color', 0xffffff); // map.infoWindow.infoWindowLabel.setStyle('fontFamily', "华文新魏"); // map.infoWindow.infoWindowLabel.setStyle('fontSize', "16"); // map.infoWindow.show(fea.geometry.center); } private function queryLayerFault(event:QueryLayerEvent):void { //Alert.show("查询失败!","错误"); } /** * clear FeatureLayer GraphicsLayer ElementLayer * */ public function clearAllTempLayer():void { var mapAction:MapAction = this.map.action; map.action = null; map.action = mapAction; map.infoWindow.closeButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK)); // detailCt.show=false; for each(var obj:Object in this.map.layers) { if(obj is GraphicsLayer) (obj as GraphicsLayer).graphics.clear(); else if(obj is FeaturesLayer) (obj as FeaturesLayer).clear(); else if(obj is ElementsLayer) (obj as ElementsLayer).clear(); } clearAllCheckedMenu(); } public function clearAllCheckedMenu():void { var list:XMLList = menuXML.children(); for each( var xmlChildren:XML in list) { xmlChildren.@STATE = "0"; } }