WAB: How to get popup info from feature layer via js function?

277
5
03-09-2020 10:06 AM
MarkJones7
Occasional Contributor

Good Afternoon,

I was just wondering if it is possible via JS to get a layers popup information? I was hoping to just grab the info and send it to another widget.

Any help is greatly appreciated.

Mark

0 Kudos
5 Replies
WilliamCraft
MVP Regular Contributor

I don't believe this is possible when working from within the WAB framework of Portal.  You would likely need to use the developer edition of WAB if you're not using it already.  

0 Kudos
MarkJones7
Occasional Contributor

I am using the Developer version of WAB.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Mark,

   In JS the way you get the current popup info is:

var atts = this.map.infoWindow.getSelectedFeature().attributes;
0 Kudos
MarkJones7
Occasional Contributor

Thanks Rob.

I gather I will need some type of handler to listen to the map for when a feature is selected? Using on click doesn't seem right since it would fire where ever the user clicks on the map. =]

0 Kudos
MarkJones7
Occasional Contributor

figured it out. =]

evtHandler = this.map.infoWindow.on('set-features', function(){       
        var atts = this.map.infoWindow.getSelectedFeature().attributes;
        console.log(atts);
      });

thanks again.