123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- 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";
- }
- }
|