FeatureLayer 的Feature 的symbol使用renderer
发布时间:2020-12-15 04:38:18 所属栏目:百科 来源:网络整理
导读:定义个DataRenderer ?xml version="1.0" encoding="utf-8"?s:DataRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:s="library://ns.adobe.com/flex/spark" implements="mx.core.IFactory"xmlns:code="http://code.google.com/p/flex-iframe/"creati
定义个DataRenderer <?xml version="1.0" encoding="utf-8"?> <s:DataRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" implements="mx.core.IFactory" xmlns:code="http://code.google.com/p/flex-iframe/" creationComplete="datarenderer1_creationCompleteHandler(event)" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:supportClasses="com.esri.ags.skins.supportClasses.*" xmlns:view="widgets.monitor.view.*" xmlns:template="com.depth.viewer.widget.template.*" xmlns:widget="com.depth.viewer.widget.*"> <fx:Script> <![CDATA[ import com.depth.viewer.facade.IocAppFacade; import com.esri.ags.Graphic; import com.esri.ags.layers.FeatureLayer; import com.xcsw.flex.facade.ConstFacade; import mx.controls.Alert; import mx.events.DragEvent; import mx.events.FlexEvent; import mx.events.MoveEvent; import widgets.map.util.MapUtil; /* 只显示监控数据,雨量、水位、闸门开合度,没有视频 */ protected function linkbutton3_clickHandler(event:MouseEvent):void { if(!data)//由渲染器使用者提供 return; var feature:Graphic = data.feature as Graphic; var fl:FeatureLayer = feature.graphicsLayer as FeatureLayer; //获取水位站对应的ID var fId:String = feature.attributes[fl.layerDetails.objectIdField]; var site:String=data.station; //水位信息警戒水位参数设置 IocAppFacade.getInstance().sendNotification(IocAppFacade.LOAD_WIDGET,{id:"TriggerlevelWidget",runingParams:{ID:fId,tablename:"M_Waterlevel",site:site}}); } public function newInstance():*{ return new MonitorDataInfoSymbolRenderer(); } protected function btnCloseButton_clickHandler(event:MouseEvent):void { if (currentState != "minState") { currentState = "minState"; } } protected function datarenderer1_creationCompleteHandler(event:FlexEvent):void { //addEventListener(MouseEvent.ROLL_OUT,rollOutHandler); //addEventListener(MouseEvent.ROLL_OVER,rollOverHandler); } private function rollOverHandler(event:MouseEvent):void { if (currentState == "minState") { currentState = "normal"; } } private function rollOutHandler(event:MouseEvent):void { //var obj:Object=event.target; } protected function chkMonitorData_clickHandler(event:MouseEvent):void { var checkBox:CheckBox=event.target as CheckBox; switch(checkBox.label){ case "雨量": if(checkBox.selected) break; case "水位": if(checkBox.selected) break; case "闸门": if(checkBox.selected) break; } } protected function btnExpandButton_clickHandler(event:MouseEvent):void { if (currentState == "minState") { currentState = "normal"; } } ]]> </fx:Script> <s:states> <s:State name="normal"/> <s:State name="minState"/> </s:states> <fx:Style> @namespace s "library://ns.adobe.com/flex/spark"; @namespace mx "library://ns.adobe.com/flex/mx"; .InfoExpandButton { disabledSkin: Embed(source="/assets/swf/skins2.swf",symbol="Callout_expandButtonDisabledSkin"); downSkin: Embed(source="/assets/swf/skins2.swf",symbol="Callout_expandButtonDownSkin"); overSkin: Embed(source="/assets/swf/skins2.swf",symbol="Callout_expandButtonOverSkin"); upSkin: Embed(source="/assets/swf/skins2.swf",symbol="Callout_expandButtonUpSkin"); } .InfoCloseButton { disabledSkin: Embed(source="/assets/swf/skins2.swf",symbol="Callout_closeButtonDisabledSkin"); downSkin: Embed(source="/assets/swf/skins2.swf",symbol="Callout_closeButtonDownSkin"); overSkin: Embed(source="/assets/swf/skins2.swf",symbol="Callout_closeButtonOverSkin"); upSkin: Embed(source="/assets/swf/skins2.swf",symbol="Callout_closeButtonUpSkin"); } </fx:Style> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <s:VGroup width="100%"> <s:HGroup verticalAlign="middle"> <s:Label text="监控点:"/> <mx:Button id="btnExpandButton" width="18" height="18" click="btnExpandButton_clickHandler(event)" includeIn="minState" styleName="InfoExpandButton"/> <mx:Button id="btnCloseButton" width="18" height="18" includeIn="normal" click="btnCloseButton_clickHandler(event)" styleName="InfoCloseButton" toolTip="关闭"/> </s:HGroup> <s:BorderContainer height="80" borderColor="#128EEE" includeIn="normal" > <s:layout> <s:VerticalLayout /> </s:layout> <s:HGroup id="ghRain" verticalAlign="middle" fontSize="25"> <s:CheckBox id="chkMonitorDataRain" label="雨量" click="chkMonitorData_clickHandler(event)" /> <s:Label text=":" /> </s:HGroup> <s:HGroup id="hgWater" verticalAlign="middle"> <s:CheckBox id="chkMonitorDataWater" label="水位" click="chkMonitorData_clickHandler(event)" /> <s:Label text=":" /> </s:HGroup> <s:HGroup id="hgFloodgate" verticalAlign="middle"> <s:CheckBox id="chkMonitorDataFloodgate" label="闸门" click="chkMonitorData_clickHandler(event)" /> <s:Label text=":" /> </s:HGroup> </s:BorderContainer> <s:Label text="当前时间:" includeIn="normal" /> </s:VGroup> </s:DataRenderer> 使用该renderer protected function btnShowVideoInfo_clickHandler(event:MouseEvent):void { var videoLayerName:String="sde.SDE.MonitorPoint"; //var videoLayerName:String="sde.SDE.RainMonitory"; featureLayer=MapUtil.getFeatureLayerByName(videoLayerName); //featureLayer增加feature featureLayer.addEventListener(GraphicEvent.GRAPHIC_ADD,graphicAddedHandler); featureLayer.visible=true; /** * feature添加处理函数 */ function graphicAddedHandler(event:GraphicEvent):void{ /* var features:ArrayCollection=featureLayer.graphicProvider as ArrayCollection; for each(var feature:Graphic in features){ displayFeatureInfoSymbol(feature); } */ displayFeatureInfoSymbol(event.graphic); } } private function displayFeatureInfoSymbol(feature:Graphic,data:Object=null):void{ var infoSymbol:InfoSymbol=new InfoSymbol(); infoSymbol.infoRenderer=new ClassFactory(MoniotorPointInfoSymbolRenderer); feature.symbol=infoSymbol; feature.alpha=0.8; //feature.visible=false; }??? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |