I am working with WAB 2.6 and want to close a widget panel when the selection in the map is changed. I can see the map.on("selection-change") code in some other question samples but don't see anything about it in the API 3.23 reference under map events. Can someone tell me the syntax for this function, where it goes and what needs to be defined in order to use the event handler? Thanks, cob
Solved! Go to Solution.
Cob,
Your code should be:
this.map.infoWindow.on("selection-change", lang.hitch(this, function() {
PanelManager.getInstance().closePanel(this.id + '_panel');
}));
Cob,
What widget panel are you wanting to close? There is no selection-change on the map class. A FeatureLayer does have a selection-complete event though. So you have to attach to a specific layers selection-complete or selection-clear event.
It's a custom in panel that displays the area and perimeter of the selected feature via a feature action. I want it to close whenever any other feature is selected in the map - and it also needs to work on layers added to the map from local sources - can I use lang.hitch(this or something to make it apply to any layer in the map? Thanks Robert - cob
Cob,
Is it the selection widget that is used to select the feature or are you just talking about selected it using a pop Up?
Just the popup by clicking the feature on the map - are you thinking about the selection change on the popup class? Could something like this work?
map.infoWindow.on("selection-change", function() {Close the Panel}
Cob,
Absolutely that is where I am going.
OK I tried it in a test setting but it doesn't seem to recognize the event. This code is in the widget.js file (which may not be the right place) for the test widget infographic :I defined 'esri/dijit/Popup' and function Popup, and here is the code in the PostCreate function:
this.inherited(arguments);
map.infoWindow.on("selection-change", function() { console.log('foo'); PanelManager.getInstance().closePanel(this.id + '_panel'); }); It fails with no error, and is not firing the selection event at all (i.e. no 'foo' printed). I know the close panel routine works because I had a click event in there before with the same code. I also tried this.map.infoWindow.on(...with the same results. Thoughts?
Cob,
Your code should be:
this.map.infoWindow.on("selection-change", lang.hitch(this, function() {
PanelManager.getInstance().closePanel(this.id + '_panel');
}));
Outstanding as usual Robert, thanks!