In ArcGIS JSAPI there are ways to select Features from FeatureLayer or using querytask like this or this or this. But how to select the Graphic from Graphics Layer?

I am trying to do this in AGS JSAPI which is accomplished by SelectInteraction in OpenLayers. This lets user select features from map by clicking on them. Base on other interactions of OpenLayers such as (Draw, Modify) AGS JSAPI also provides toolbar which let user Draw or Edit Graphics but lacks in selection.

Is there any similar functionality available to JSAPI as well?

closed as off-topic by PolyGeo May 4 '18 at 8:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.


Just take the graphiclayer as a normal JS object. All graphic is stored in graphicLayer.graphics as an array. You could use the maps onClick event to locate where exactly the user clicked and use that coord to check which graphic should be selected.

Here's a quick example to show what i meant.

map.on("click", function (evt) {
    var g = graphicLayer.graphics;
    for (var loopCnt = 0; loopCnt < g.length; loopCnt++) {
            //do whatever you want

Not the answer you're looking for? Browse other questions tagged or ask your own question.