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.
Solved! Go to Solution.
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;
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.
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?
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;