The text property will search the display field of your layer, it is a short hand for a where clause of: where YourDisplayField like '%SearchText%'.
Hi Robert,I am using the sample which you have given in this thread..Its working fine for few layers but the same code fails when i try to do attribute query on a particular layer. can u please help me with the issue.I am using Bing maps as the basemap and the code shows wrong output for an attribute query.
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:esri="http://www.esri.com/2008/ags" pageTitle="Find features in Map Layers" styleName="plain"> <mx:Script> <![CDATA[ import com.esri.ags.events.QueryEvent; import com.esri.ags.Graphic; import com.esri.ags.events.FindEvent; import com.esri.ags.geometry.Geometry; import com.esri.ags.tasks.Query; import com.esri.ags.tasks.FeatureSet; private function doFind():void { findTask.execute(myFindParams); } private function findCompleteHandler(event:FindEvent):void { myGraphicsLayer.clear(); var graphic:Graphic; var query:Query = new Query(); resultSummary.text = event.findResults.length + " State Found using Find Task"; var resultCount:int = event.findResults.length; for (var i:Number = 0; i < resultCount; i++) { query.returnGeometry = true; query.outFields = ["CITY_NAME","POP1990"]; query.outSpatialReference = myMap.spatialReference; graphic = event.findResults.feature; query.geometry = graphic.geometry; graphic.symbol = sfsFind; myGraphicsLayer.add(graphic); queryTask.execute(query); } } private function queryCompleteHandler(event:QueryEvent):void { myGraphicsLayer.clear(); var fset:FeatureSet = event.featureSet; resultSummary.text += " and " + fset.features.length + " cities found using spatial query." for each (var graphic:Graphic in fset.features) { graphic.symbol = smsFind; graphic.toolTip = graphic.attributes["CITY_NAME"] + " - Population: " + graphic.attributes["POP1990"] myGraphicsLayer.add(graphic); } } ]]> </mx:Script> <!-- Symbol for Find Result as Point --> <esri:SimpleMarkerSymbol id="smsFind" style="square" color="0xFFFF00" size="11" alpha="0.9"> <esri:SimpleLineSymbol color="0x000000"/> </esri:SimpleMarkerSymbol> <!-- Symbol for Find Result as Polygon --> <esri:SimpleFillSymbol id="sfsFind" color="0xFFFF00" alpha="0.7"/> <!-- Find Task --> <esri:FindTask id="findTask" executeComplete="findCompleteHandler(event)" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer" /> <!-- Query Task --> <esri:QueryTask id="queryTask" executeComplete="queryCompleteHandler(event)" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/0" /> <esri:FindParameters id="myFindParams" returnGeometry="true" contains="true" searchText="{fText.text}" layerIds="[2]" searchFields="['STATE_NAME']" /> <mx:HBox width="100%" height="40" backgroundColor="0xDDDDFF" paddingTop="10" horizontalAlign="center"> <mx:Text text="Search for names of States:"/> <mx:TextInput maxWidth="400" id="fText" enter="doFind()" text="Alabama"/> <mx:Button label="Find" click="doFind()"/> </mx:HBox> <mx:Text id="resultSummary" height="15"/> <esri:Map id="myMap"> <esri:extent> <esri:Extent xmin="-126" ymin="24" xmax="-67" ymax="50"> <esri:SpatialReference wkid="4326"/> </esri:Extent> </esri:extent> <esri:ArcGISDynamicMapServiceLayer url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer"/> <esri:GraphicsLayer id="myGraphicsLayer"/> </esri:Map> </mx:Application>
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.