I have a mapservice that has 3 layers and each layer has sublayers. I am using mapImageLayer to call popups with the properties sublayers and popupTemplate as displayed below:
var displayLayer = new MapImageLayer({ url: "RESTURL/endpoints", sublayers: [{ id: 10, title: "Gas Main", popupTemplate: { title: "Gas Main", content: [{ type: "fields", fieldInfos: [ {fieldName: "INSTALLDATE", visible: true, label: "Install Date", format: {dateFormat: "short-date"}}, {fieldName: "SUBTYPECD", visible: true, label: "Type"} ] }] } }] });
The layers structure is:
Layer1 has index 0. Layer1 has two subLayers - sublayer1 with index 1 and sublayer2 with index 2.
Layer 2 has index 3.
I am using layerlist widget. When I have sublayers in the MapImageLayer, the layerlist displays all the layers at once without honoring the sublayers.
But when I do not have "sublayers" property in my MapImageLayer, the layerlist displays layers fine honoring the sublayers. I do not want to use feature layers just to make popups.
Any ideas on how to reconcile popup and layerlist widget.
Thanks
Solved! Go to Solution.
Saroj,
If reverting to 4.3 did not help you issue then it must be a different issue then I was thinking about.
Can you try setting the sublayer properties like this then:
var citiesLayer = layer.sublayers.getItemAt(3);
citiesLayer.title = "Gas Main";
citiesLayer.popupTemplate = {
title: "Gas Main",
content: [{
type: "fields",
fieldInfos: [
{fieldName: "INSTALLDATE", visible: true, label: "Install Date", format: {dateFormat: "short-date"}},
{fieldName: "SUBTYPECD", visible: true, label: "Type"}
]
}]
};
Saroj,
Sublayer visibility is a known issue in 4.4 for now you will have to regress to 4.3.
Thanks Robert, Regressing to 4.3 still does not solve the issue. I will probably have to use feature layer to enable popups.
Saroj,
If reverting to 4.3 did not help you issue then it must be a different issue then I was thinking about.
Can you try setting the sublayer properties like this then:
var citiesLayer = layer.sublayers.getItemAt(3);
citiesLayer.title = "Gas Main";
citiesLayer.popupTemplate = {
title: "Gas Main",
content: [{
type: "fields",
fieldInfos: [
{fieldName: "INSTALLDATE", visible: true, label: "Install Date", format: {dateFormat: "short-date"}},
{fieldName: "SUBTYPECD", visible: true, label: "Type"}
]
}]
};
Hi Saroj,
Did Robert's suggestion help you, or are you still having an issue with popups?
-Noah
Hi Noah, Yes Robert's suggestion helped. Forgot to mark as a Correct Answer.