Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

How can you figure out what polygon is clicked within a feature layer? I have a feature layer made of county polygons. When the layer is clicked I want to trigger a geoprocessing task on my server. One of the inputs to the task is a polygon. I can't figure out how to get the clicked polygon data from the onclick event.

This is my attempt at starting but can't figure out how to get the polygon from evt.

 gp = new Geoprocessor("http://myserver/arcgis/services/IntersectSumJoin/GPServer/Model");
        gp.setOutputSpatialReference({ wkid: 4326 });

        paCounties.on("click", getData);

        function getData(evt) {
            console.log("In GetData The Event graphic is "+evt.Graphic+"Point is ", evt.mapPoint.x)

        }

The output in console is this.

I can't find a good sample that captures the Polygon in which the user clicks.

In GetData The Event graphic is undefinedPoint is -8619169.218412401

share|improve this question
    
I've both answered and voted down this question. Have you even tried to google or look at the ESRI samples? You need to put in a little more effort before asking a question like this. developers.arcgis.com/en/javascript/jssamples –  CLJ Sep 13 '13 at 2:48
    
@CLJ I actually did research this for a couple hours. I did come across a few examples that showed identify and query but I kept thinking there had to be a function I was missing for a feature layer. When you click a polygon in a feature layer it outlines and gives you the data for that polygon without doing a query or identify. I was thinking there was something like paCounties.getSelectedPolygon that I was missing but apparently not. –  Xaxum Sep 17 '13 at 19:54
add comment

1 Answer

up vote 1 down vote accepted

See this example of what you are looking for: https://developers.arcgis.com/en/javascript/jssamples/query_deferred_list.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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