加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

FeatureLayer的用法

发布时间:2020-12-15 04:38:33 所属栏目:百科 来源:网络整理
导读:当加载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 += "Magnit

当加载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 + "nn" + event.fault.faultDetail,"FeatureLayer Fault " + event.fault.faultCode);
            }

            protected function fLayer_loadErrorHandler(event:LayerEvent):void
            {
                Alert.show(event.fault.faultString + "nn" + 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());
				}


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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读