Adding a link to a popup and getting a value from the selected feature

1152
3
Jump to solution
10-27-2017 03:39 PM
MarkEastwood
Occasional Contributor II

My ultimate goal is to run a geoprocessing service from a link in a popup but at the moment am trying to retrieve an attribute value to use as a input parameter from the selected attribute. I have added the following code to the PopupManager.js 

line 99 onwards: 

 

   var link = html.create("a",{
   "class": "action",
   "id": "statsLink",
   "innerHTML": "Bridge Report", //text that appears in the popup for the link
   "href": "javascript: void(0);"
   }, query(".actionList", this.popupUnion.bigScreen.domNode)[0]);

   //when the link is clicked register a function that will run
   on(link, "click", this.calculateBridgeReport);
   },

   calculateBridgeReport: function(){
   var feature = this.popupUnion.getSelectedFeatures();
   console.log(feature);
   },

I am receiving the following error:

Uncaught TypeError: Cannot read property 'getSelectedFeatures' of undefined 

I have looked here and here but have not been able to get values returned. I am guessing the this.popupUnion is not what I should be using with getSelectedFeatures but am not sure what to do. Thanks in advance for any help.

0 Kudos
1 Solution

Accepted Solutions
MarkEastwood
Occasional Contributor II

I was able to expose the value that I was looking for by adding the following:

var feature = this.mapManager.map.infoWindow.getSelectedFeature();
var fs = feature.attributes.bridge_name_num;

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

ME,

   I think that you are having a simple scope issue with your function:

on(link, "click", lang.hitch(this, this.calculateBridgeReport));

You will notice this in the code in your second link when I replied to the Lesi.

MarkEastwood
Occasional Contributor II

Thanks for the reply Robert. I am now getting this.popupUnion.getSelectedFeature is not a function. I noticed in your reply to Lesi that you use this.popup.getSelectedFeature and this.popup is set to this.map.infoWindow. Is this something I need to do within the PopupManager.js?

0 Kudos
MarkEastwood
Occasional Contributor II

I was able to expose the value that I was looking for by adding the following:

var feature = this.mapManager.map.infoWindow.getSelectedFeature();
var fs = feature.attributes.bridge_name_num;

0 Kudos