Occasionally when using popups in my application with popupTemplates defined on FeatureLayers pointed to ArcGIS Server MapService sub layers, when a click finds more than one applicable feature all popups after the first one serve ‘undefined’ when consuming attributes in the popup body. Is this a known issue? The popupTemplates are defined at the same time as each FeatureLayer.
Hi there,
Would you be able to provide a simple test case for this? At the very least can you please provide the code for how you are setting up the popup template?
Without a test case it is hard to say why this is happening.
Thanks,
-Undral
Hi Undral - sorry for the delay.
Since posting this question I've migrated the application to 4.19, so I should be using all the most recent APIs. I've also stopped using custom popupTemplates, but I'm still seeing intermittent problems where every popup after the first has no content. I'm initializing the mapView to use the default popupTemplate before adding any FeatureLayers or GroupLayers:
mapView.when(function () {
mapView.popup.defaultPopupTemplateEnabled = true;
// ...
const layers = createLayerObjects();
map.addMany(layers)
}
I create FeatureLayer and GroupLayer objects in the createLayerObjects() function. Each FeatureLayer is generated by a function that takes parameters for the FeatureLayer constructor something like this:
const featureLayer = new FeatureLayer({
url: url,
id: id,
title: title,
outFields: outFields,
popupEnabled: popup,
opacity: transparency
// popupTemplate: popupTemp
});
These ~80 FeatureLayer objects are mostly added to GroupLayer objects, which are then added to the layers array, which is then passed to the map.addMany() function.
Is this enough information for you to see if I should be doing something differently?
Thanks,
Anthony
Edit: Here's what the behavior looks like when it happens:
I've found a new wrinkle in this behavior. If I get the empty popups issue, if I then use the 'x of n' selector the popups will then fully populate:
After clicking the 'x of n' button then all popups appear to be correctly populated, even if I don't actually select a result but instead close the 'x of n' box to close it back to the original first popup. Does this suggest some sort of async issue? I also just noticed that the list of popups shown after clicking 'x of n' sometimes shows n popups, and sometimes shows n-1 popups. I'm having a hard time seeing a consistent pattern here.