1

I am building a map that you can hover over and click on. I need to access a feature's project number (ProjectNum) when I click on it, but my click event on the layer doesn't seem to be firing. When I click the map, I get all of the feature layer's project numbers, not the one that I want. How do I retrieve the specific project number of the polygon that I click on?

function clickMap(){

    layer.on("update-end", function(evt){
        console.log(evt);
        map.on("click", function(e){
        console.log(e);
        console.log("project number: " + layer.graphics[0].attributes.ProjectNum);
        });
    })

}
0

You have to listen to the "click" event on the feature layer :

layer.on("click", function(evt){
  console.log(evt.graphic.attributes.ProjectNum);
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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