If we have a feature class where multiple features overlap each over, is there anyway to sort the features shown in the infowindow popup?
For example, if we have multiple point features representing different 3-1-1 calls that overlap each other on the map, is there anyway to enforce an ordering so that when the map is clicked, the newest feature, based on a timestamp column, is shown first ? So that the newest record is 1 of X, the second oldest is 2 of X etc.
It seems that the ordering of item in the popup window is random.
I tried adding code to the "set-features" event handler to sort the features, but this did not make any differenct
Solved! Go to Solution.
That seems to work, thank you Robert!
One more thing that seemed to be necessary - I had to override the "show" method and change the "closestFirst" parameter to false.
David
I tried adding code to the "set-features" event handler to sort the features, but this did not make any difference
What exactly did you try, because this is the only way to manage the order is to set the order of the setFeatures array?
Hi Robert,
in the "set-features" event-handler, I added some code like this:
var data = _map.infoWindow.features;
if (data && data.length > 0) {
data.sort(function (a, b) {
if (a.LayerSortKey && b.LayerSortKey) {
if (a.LayerSortKey > b.LayerSortKey) {
return 1;
}
if (a.LayerSortKey < b.LayerSortKey) {
return -1;
}
}
return 0;
});
data.reverse();
}
(LayerSortKey is an attribute I have on the feature class that I wish to use for sorting)
It seems to sort the array of _map.infoWindow.features, but the order that they appear in the popup seems to be random
David,
You are sorting the array after the fact. You need to override the setFeatures method and sort the array before the setFeatures method applies the array.
That seems to work, thank you Robert!
One more thing that seemed to be necessary - I had to override the "show" method and change the "closestFirst" parameter to false.
David,
The community would definitely benefit if you would post the code you end up using.