Hi All,
I have a web map and the issue I'm having is, when I select features using either Polygon, Circle or Freehand Polygon buttons for the first time as shown in Figure A, it displays the correct figures for (Total features selected, FeatureLayer1, FeatureLayer2 and FeatureLayer3). However, when I clear selection (using the Clear Selection button) and make another selection (Figure B) the figures displayed are incorrect. The Total features selected from the previous selection is added to the current Total features selected figures. The figures of FeatureLayer1, FeatureLayer2 and FeatureLayer3 are also not correct. This is the link to the web map, similar to the one I'm using. Can anyone please show me how to correct this issue?
Thanks
Figure A
Figure B
Solved! Go to Solution.
Hi Hab,
You are not resetting your promises array on draw end event, because of which your promises just keeps adding on top of each other.
I have updated the fiddle have a look Edit fiddle - JSFiddle
Hi Hab,
You are not resetting your promises array on draw end event, because of which your promises just keeps adding on top of each other.
I have updated the fiddle have a look Edit fiddle - JSFiddle
Riyas,
you are just too fast with your answers!!!
Tim
Tim,
Just happened to cast my eyes couple of minutes earlier
And that's why I refreshed the page so I didn't post the same answer. You posted just a minute before I was going to
Hab,
your issue lies here:
function showselResults(results) {
var featureLayer1Message = results[0].length;
var featureLayer2Message = results[1].length;
var featureLayer3Message = results[2].length;
var count = 0;
for (var i = 0; i < results.length; i++) {
count = count + results.length;
}
dom.byId("messages").innerHTML = "Total features selected: <b>" + count + "</b><br> FeatureLayer1: <b>" + featureLayer1Message + "</b><br> FeatureLayer2: <b>" + featureLayer2Message + "</b><br> FeatureLayer3: " + featureLayer3Message;
}
Your results keep the previous selections. That is also why the count for each feature layer in future selections is wrong, because it will keep showing the count of your first selection.
Looking at my screenshot, there should only be 3 arrays, but there are 9 because I did 3 selections.
Thanks Riyas.