<?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"> <mx:Script> <![CDATA[ import com.esri.ags.Graphic; import com.esri.ags.events.MapMouseEvent; import com.esri.ags.symbol.InfoSymbol; import com.esri.ags.tasks.IdentifyParameters; import com.esri.ags.tasks.IdentifyResult; import mx.controls.Alert; import mx.rpc.AsyncResponder; private function mapClickHandler(event:MapMouseEvent):void { clickGraphicsLayer.clear(); var identifyParams:IdentifyParameters = new IdentifyParameters(); identifyParams.returnGeometry = true; identifyParams.tolerance = 3; identifyParams.width = myMap.width; identifyParams.height = myMap.height; identifyParams.geometry = event.mapPoint; identifyParams.mapExtent = myMap.extent; identifyParams.spatialReference = myMap.spatialReference; var clickGraphic:Graphic = new Graphic(event.mapPoint, clickPtSym); identifyTask.execute(identifyParams, new AsyncResponder(myResultFunction, myFaultFunction, clickGraphic)); clickGraphicsLayer.add(clickGraphic); } private function myResultFunction(results:Array, clickGraphic:Graphic = null):void { if (results && results.length > 0) { var result:IdentifyResult = results[0]; var resultGraphic:Graphic = result.feature; // update clickGraphic (from mouse click to returned feature) clickGraphic.symbol = new InfoSymbol(); // use default renderer clickGraphic.attributes = resultGraphic.attributes; } } private function myFaultFunction(error:Object, clickGraphic:Graphic = null):void { Alert.show(String(error), "Identify Error"); } ]]> </mx:Script> <!-- start declarations --> <!-- Symbol for where the user clicked --> <esri:SimpleMarkerSymbol id="clickPtSym" style="x" color="0xFF0000" size="12"/> <!-- Identify Task --> <esri:IdentifyTask id="identifyTask" concurrency="last" url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/MapServer?layerDefs=0:magnitude > 5"/> <!-- end declarations --> <esri:Map id="myMap" mapClick="mapClickHandler(event)" openHandCursorVisible="false"> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer"/> <esri:ArcGISDynamicMapServiceLayer url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/MapServer"> <esri:layerDefinitions> <mx:String>magnitude > 5</mx:String> </esri:layerDefinitions> </esri:ArcGISDynamicMapServiceLayer> <esri:GraphicsLayer id="clickGraphicsLayer"/> </esri:Map> </mx:Application>
The ArcGIS Server Identify operation added support for layerDefs at version 10.http://sampleserver3.arcgisonline.com/ArcGIS/SDK/REST/identify.htmlIf you're using ArcGIS Server 10 with ArcGIS API for Flex 1.3, you can append the layerDefs url parameter to the url you set on the IdentifyTask and it will be included in the request.
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.