Select to view content in your preferred language

How can I change the order of popups on an ArcGIS Online Map

35554
55
Jump to solution
10-03-2014 01:15 PM
bshepard
Regular Contributor

I have 3 layers (2 point and 1 line) that coincide, let's call them A, B, and C.  I have tried several things to get the popup order to be A (1 of 3), B,(2 of 3), C (3 of 3): ordering the layers in Content with A on top, then B, then C; renaming them so that they are in alphabetical order; creating copies of the layers in a specific order.  No matter what I try, the popups appear in the order B, A, C.  They don't seem to order in the order they appear in Content or the Legend, alphabetically, or in order of creation/modification.  Is there any way to force one layer's popup to display 1st, or specify the order in which the popups display?

Tags (2)
55 Replies
JamesMadden1
Frequent Contributor

This is possible using the developer edition.  Follow the steps below.

 

FYI - I got the below snippets off a similar thread a few years back but I can't seem to find the link.  The code below will work for WAB but you probably should consider moving to Experience Builder/4.X.  I'm not sure how much additional support the 3.X builder will be getting before it is retired.

 

(1) Open the popupmanager.js file

(2) Add "this.reorderPopupFeatures();" at the end of the init method

(3) Add the two methods listed below to the popupmanager.js file. 

reorderPopupFeatures: function() {
var that = this;
this.layerStructrue = LayerStructure.getInstance();

aspect.around(this.popupUnion.bigScreen, "setFeatures", function(originalSetFeatures) {
return function(featuresArg, options) {
var convertedFeatureDefs = [];


array.forEach(featuresArg, function(featureOrDef) {
if(featureOrDef.declaredClass === "esri.Graphic") {

var def = new Deferred();
def.resolve([featureOrDef]);
convertedFeatureDefs.push(def);
} else {

convertedFeatureDefs.push(featureOrDef);
}
});

this.clearFeatures();
all(convertedFeatureDefs).then(lang.hitch(this, function(results) {
var features = [];
array.forEach(results, function(result) {
array.forEach(result, function(feature) {
if(feature) {

var featureAlreadyExist = array.some(features, function(f) {
if(feature === f) {
return true;
} else {
return false;
}
});

if(!featureAlreadyExist) {
features.push(feature);
}
}
});
}, this);


var orderedFeatures = that.sortFeatures(features);


originalSetFeatures.apply(this, [orderedFeatures, options]);
}));

};
});


aspect.around(this.popupUnion.bigScreen, 'show', function(originalShow) {
return function(location/*, options*/) {
originalShow.apply(this, [location, false]);
};
});

aspect.around(this.popupUnion.mobile, 'show', function(originalShow) {
return function(location/*, options*/) {
originalShow.apply(this, [location, false]);
};
});
},


sortFeatures: function(features) {
if(!this.layerOrderPriority) {

this.layerOrderPriority = {};
var priority = 1;
this.layerStructrue.traversal(lang.hitch(this, function(layerNode) {
this.layerOrderPriority[layerNode.id] = priority++;
}));
}


if(!this.layerStructureChangeHandler) {
this.layerStructureChangeHandler = this.layerStructrue.on('structure-change', lang.hitch(this, function() {
this.layerOrderPriority = null;
}));
}

array.forEach(features, function(feature) {
if(feature && feature.getLayer) {
feature._priority = this.layerOrderPriority[feature.getLayer().id];
} else {
feature._priority = 100000;
}
}, this);


features.sort(function(featureA, featureB) {
if(featureA._priority > featureB._priority)
{ return 1;}
else
{ return -1;}
return 0;
});

return features;
},

Jesse_WI_DNR
Occasional Contributor

I just stumbled across this post, has this been added as an ArcGIS Idea yet?  Someone should add it there, perhaps that would get more traction on a solution.  If it has been posted, please share the link so we can upvote if, if not, any volunteers 😉 ?

BenCunningham
Occasional Contributor
0 Kudos
LeahSattler
Emerging Contributor

I have created a Dashboard for our Public Safety Teams for Emergency Operations, such as the current Winter Storm Severe Weather Event we are experiencing. Our Field Ops crews perform various tasks at specific locations, such as Plow Snow, Sand Road, Close and Reopen Road. It would be a very helpful for those teams to review the activities performed based on the entry date in chronological order. With a more severe event, there can be 20-30 activities at the same point. Without the functionality to order the pop-ups, it is very difficult to follow the order of work performed at each location and kinda makes the whole thing much less useful. 

ESRI, please consider adding this functionality. There is clearly a big need across multiple different types of organizations for many important functions!

Super Thanks.

RhettZufelt
MVP Notable Contributor

No, I have not.  And, this has been an issue since the flexviewer days.

It appears as if this one will never get addressed, so the solution is to just accept it.

R_

GregReinecke
Frequent Contributor

Well it has been a while. I’ll pile on to the list. I get dinged literally every demo I do as to the seemingly random (I understand it’s not) selection order of features. I’ve been in the biz 30 years and still can’t get used to customers eyes glazing over when I discuss that “performance” drives the constraint. And then of course this from customers, “but aren’t computers super fast these days? A lot faster than 10 years ago?”  From a practical sense perhaps feature type could determine order of selection. A user being able to select points, then lines and then areas (or other combo) would be a reasonable compromise. I’ll add a pretty please to all this. Thank you though for an amazing product regardless. 

GrantWilcox
Occasional Contributor

I asked about this yesterday during a Map Viewer discussion at the ESRI IUC. There is apparently no intention to fix this despite the numerous users clamoring for it. They said it was too technologically challenging and one layer might bog down the map. I did not have a chance to respond to that unfortunately but with all the posts here, they already know we want it and don't care.

Edit: I relistened to what they said and, to be fair, they didn't say no intention but my question was will it be soon and the response was basically "not close." So they probably do care but are finding it too hard right now which doesn't make me much happier.

TiffanyTuro
Regular Contributor
I think at some point it will be figured out, but for now what a time waster! Team frustration for now. Thanks for asking though!
0 Kudos
GrantWilcox
Occasional Contributor

I sure hope so because it seems so basic a need for most any map with more than one layer.

0 Kudos
CameronKenworthy
New Contributor

Hello this question says solved but obviously it is not. In the year of our lord 2023 I have come up with a stop-gap solution.

var timer = 0
if(timer < 100) {
  timer += 1
}
 
Add this as an expression to the fields list description or whatever you want. Adjust the timer accordingly to get each of your popups to load in the order you want.