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

179
5
03-09-2020 10:06 AM
MarkJones7
New Contributor III

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

Reply
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.  

Reply
0 Kudos
MarkJones7
New Contributor III

I am using the Developer version of WAB.

Reply
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;
Reply
0 Kudos
MarkJones7
New Contributor III

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. =]

Reply
0 Kudos
MarkJones7
New Contributor III

figured it out. =]

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

thanks again.