Select to view content in your preferred language

get reference to clicked feature custom widget

667
2
Jump to solution
06-01-2020 10:10 AM
jinjoe
by
New Contributor

Hi ,

I am trying to build a custom widget using ArcGIS WebAppBuilder for Developers Edition. My goal is quite simple however I am quite new to the ArcGIS world and am in need of some assistance. The goal is the following:

I have a feature set and map that is already built on arcgis online. my organization has wrapped a web app around the map and featuresets to build an application that can be displayed on the website. I need to find a way to add a custom widget to this application to do the following:

When the user selects a feature (on the map), I need to get a reference to the selected feature's attributes. For example if the feature has an attribute volume and height, i need to get a handle onto those variables so i can work with them in our custom logic. 

I.e User clicks on a feature, and opens my widget, the widget gets volume and height values of the selected feature. Then i can run my custom logic to check the volume and height are within our specified parameters. I am having a hard time with getting the reference. Can someone point me in the right direction? I have looked through the tutorials however I dont see this. 

Thanks, 

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Jin,

   The easy way to handle this is through the maps popup. So if the layer has a popup configured then you can get access to the current feature selected in the popup by using 

var feat = this.map.infoWindow.getSelectedFeature();
var aVolume = feat.attributes.volume;
var aHeight = feat.attributes.height;

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Jin,

   The easy way to handle this is through the maps popup. So if the layer has a popup configured then you can get access to the current feature selected in the popup by using 

var feat = this.map.infoWindow.getSelectedFeature();
var aVolume = feat.attributes.volume;
var aHeight = feat.attributes.height;
jinjoe
by
New Contributor

This is excellent, this did the trick! i knew it was something easy i was just a noob haha.