本文共 5296 字,大约阅读时间需要 17 分钟。
当加载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增加监听
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("2000 Population: " + gr.attributes.POP2000.toString() + "" + "2000 Population per Sq. Mi.: " + gr.attributes.POP00_SQMI.toString() + "" + "2007 Population: " + gr.attributes.POP2007 + "" + "2007 Population per Sq. Mi.: " + 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()); }
-------------------------------------------------------------------------------------------------------------------
转载地址:http://wcgab.baihongyu.com/