Popups using MapImageLayer and LayerList Widget

1490
5
Jump to solution
08-11-2017 12:04 PM
SarojThapa1
Occasional Contributor III

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 

1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

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"}
        ]
      }]
    };

View solution in original post

0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus

Saroj,

   Sublayer visibility is a known issue in 4.4 for now you will have to regress to 4.3.

SarojThapa1
Occasional Contributor III

Thanks Robert, Regressing to 4.3 still does not solve the issue. I will probably have to use feature layer to enable popups.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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"}
        ]
      }]
    };
0 Kudos
Noah-Sager
Esri Regular Contributor

Hi Saroj,

Did Robert's suggestion help you, or are you still having an issue with popups?

-Noah

0 Kudos
SarojThapa1
Occasional Contributor III

Hi Noah, Yes Robert's suggestion helped. Forgot to mark as a Correct Answer.