The layers in my map often have many overlapping features and when the popup is opened I'd like to be able to order them by a field in order to have the most relevant features at the top of the stack. Was able to find an older 3.x example of this, but I can't find the equivalent for 4.x. Any suggestions? No need to rewrite this for me, just point me to the right object/method/event if it exists, thanks!
connect.connect(map.infoWindow, "onSetFeatures", function () {
var orderedFeatures = [];
for(var i = 0; i< map.infoWindow.features.length; i++) {
if (map.infoWindow.features[i]._layer.id === 'ImportantLayer') {
orderedFeatures.unshift(map.infoWindow.features[i]);
}
else {
orderedFeatures.push(map.infoWindow.features[i]);
}
}
map.infoWindow.features = orderedFeatures;
});
Any luck on this ? I am facing the same issue and want resolution for this ?
Hi Michel -
I'm also trying to reorder features in the popup. I tried using a watch on the popup.viewModel.features object, but then when I try to reorder the features it triggers the watch again, causing an infinite loop. I also tried comparing the current and intended order of features prior to setting the value to avoid triggering the watch again, but the features value seems inconsistent. Any ideas? Thanks
Thanks - that does at least work to set the initially selected index, which works for now.