to use your example, if you are loading the US states as a feature layer there is no need to wire up a QueryTask when the map is clicked because the FeatureLayer has already ensured that the graphics have already been downloaded to the client.instead, writing code which listens for the "onClick" event of the FeatureLayer will give you immediate access to the graphic which has been clicked.dojo.connect(myFeatureLayer, "onClick", myFunction); function myFunction(evt) { console.log(evt.graphic); }
dojo.connect(myFeatureLayer, "onClick", myFunction); function myFunction(evt) { console.log(evt.graphic); }
is the feature you are trying to use as clipping geometry being drawn in the app as part of a ArcGISDynamicMapServiceLayer, as a FeatureLayer, or in some other way?
thanks for clarifying. in this case you shouldn't need to fire a QueryTask to ask the server about a feature under a mouse click because the geometry and attributes of the features have already been downloaded to the client.Because FeatureLayers inherit from GraphicsLayers, the GraphicsLayer "onClick" event will give you access to the feature itself (along with screenPoint and mapPoint).
the ArcGISDynamicMapServiceLayer.visibleLayers property will return an array of the layerIds which are currently visible. you could loop through those results and pass to a series of QueryTasks, but if the client needs to interact with the geometry from all these individual layers (and perhaps even send a featureSet back to ArcGIS Server), maybe it would be more convenient to work with FeatureLayers and skip the Querying altogether instead?
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.