FeatureLayer的用法

当加载FeatureLayer时为每个Feature增加监听

            protected function fLayer_graphicAddHandler(event:GraphicEvent):void
            {
                // just so we can add tool tips
                event.graphic.toolTip = event.graphic.attributes.Name + "\n";
                event.graphic.toolTip += "Magnitude " + myOneDecimalFormatter.format(event.graphic.attributes.Magnitude) + " earthquake";
                if (event.graphic.attributes.Num_Deaths)
                {
                    event.graphic.toolTip += "\n(" + event.graphic.attributes.Num_Deaths + " people died)";
                }
            }


            protected function fLayer_graphicAddHandler(event:GraphicEvent):void
            {
                // just so we can add tool tips
                event.graphic.toolTip = event.graphic.attributes.Name + "\n";
                event.graphic.toolTip += "Magnitude " + myOneDecimalFormatter.format(event.graphic.attributes.Magnitude) + " earthquake";
                if (event.graphic.attributes.Num_Deaths)
                {
                    event.graphic.toolTip += "\n(" + event.graphic.attributes.Num_Deaths + " people died)";
                }
            }

查询时,增加筛选的事件

            private function doSearch():void
            {
                // fLayer.layerDetails.displayField
                fLayer.definitionExpression = "STATE_NAME like '" + qText.text + "'";
            }

            // the following four functions are 'just' error handling and showing/hiding the busy cursor
            protected function fLayer_updateStartHandler(event:LayerEvent):void
            {
                this.cursorManager.setBusyCursor();
            }

            protected function fLayer_updateEndHandler(event:LayerEvent):void
            {
                if (event.fault)
                {
                    trace("updateEnd: " + event.fault); // maybe a badly formatted query?
                }
                else if (event.updateSuccess == false)
                {
                    trace(event.type + ": " + event.updateSuccess + " ... unexpected failure");
                }
                else // things seem OK
                {
                    if (FeatureLayer(event.layer).numGraphics < 1)
                    {
                        Alert.show("Sorry, found no such features, please try something else");
                    }
                }
                this.cursorManager.removeBusyCursor();
            }

            protected function fLayer_faultHandler(event:FaultEvent):void
            {
                Alert.show(event.fault.faultString + "\n\n" + event.fault.faultDetail, "FeatureLayer Fault " + event.fault.faultCode);
            }

            protected function fLayer_loadErrorHandler(event:LayerEvent):void
            {
                Alert.show(event.fault.faultString + "\n\n" + event.fault.faultDetail, "FeatureLayer Load Error " + event.fault.faultCode);
            }


为Feature增加监听

        <esri:FeatureLayer id="fLayer"
                           definitionExpression="STATE_NAME='South Carolina'"
                           graphicAdd="fLayer_graphicAddHandler(event)"
                           mode="snapshot"
                           outFields="*"
                           symbol="{defaultsym}"
                           url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3"/>


         protected function fLayer_graphicAddHandler(event:GraphicEvent):void
            {
                event.graphic.addEventListener(MouseEvent.MOUSE_OVER, onMouseOverHandler);
                event.graphic.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutHandler);
            }

            private function onMouseOverHandler(event:MouseEvent):void
            {
                var gr:Graphic = Graphic(event.target);
                gr.symbol = mouseOverSymbol;
                myTextArea.textFlow = TextFlowUtil.importFromString("<span fontWeight='bold'>2000 Population: </span>" + gr.attributes.POP2000.toString() + "<br/>"
                                                                    + "<span fontWeight='bold'>2000 Population per Sq. Mi.: </span>" + gr.attributes.POP00_SQMI.toString() + "<br/>"
                                                                    + "<span fontWeight='bold'>2007 Population: </span>" + gr.attributes.POP2007 + "<br/>"
                                                                    + "<span fontWeight='bold'>2007 Population per Sq. Mi.: </span>" + gr.attributes.POP07_SQMI);
                myMap.infoWindow.label = gr.attributes.NAME;
                myMap.infoWindow.closeButtonVisible = false;
                myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));
            }

            private function onMouseOutHandler(event:MouseEvent):void
            {
                var gr:Graphic = Graphic(event.target);
                gr.symbol = defaultsym;
                myMap.infoWindow.hide();
            }


FeatureLayer选择要素使之高亮显示

			protected function button2_clickHandler(event:MouseEvent):void
			{
				var query:Query=new Query();
				query.where="RainYN like '0'";
				fLayer.selectFeatures(query,"new");
			}
			


获取所有feature


			protected function button2_clickHandler(event:MouseEvent):void
			{
				var arr:ArrayCollection=fLayer.graphicProvider as ArrayCollection;
				Alert.show(arr.length.toString());
				
			}

feature 具有event.graphic.visible=false;属性。

在权限控制的时候,帅选显示要素

            protected function button3_clickHandler(event:MouseEvent):void
            {
                fLayer.definitionExpression = "NOT (Name IN('徐图港西闸站','田大港闸站'))" ;               
            }

FeatureLayer的update_end事件,当更新时,包括地图放大、缩小、漫游、重新过滤筛选feature。

				featureLayer.addEventListener(LayerEvent.UPDATE_END,updateEndHandler);

				function updateEndHandler(event:LayerEvent):void{
					var arr:ArrayCollection=featureLayer.graphicProvider as ArrayCollection;
					Alert.show(arr.length.toString());
				}


-------------------------------------------------------------------------------------------------------------------


  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值