TransWikia.com

How do you retrieve a single attribute from a feature layer by clicking on it using ArcGIS Javascript API v3.2?

Geographic Information Systems Asked on July 22, 2021

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);
        });
    })

}

One Answer

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

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

Answered by LMokrane on July 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP