Legend for MapImageLayer using Class Breaks Renderer is getting reversed

292
1
12-01-2022 08:45 PM
LakshanaRajendran
New Contributor

Hi, I am using ArcGIS API for JavaScript 4.x in my app. A MapImageLayer has been added on to the map and it is loaded properly in the app. Initially, the legend shows the categorized classes from least to most for this service.  On clicking anywhere on the map, the order of categorized classes is getting reversed in the legend.

How to prevent this?

For your information, the service uses Class Breaks Renderer to classify it into different classes.

Here is a sample code demonstrating how it has been added:

 

 

        const layer = new MapImageLayer({
          portalItem: {
            id: "73c67b3d082b4ef58c3c8ce14add8c9d",
          },
          sublayers: [
            {
              id: 3,
              popupEnabled: true,
              definitionExpression: "TallShrubCC>0",
              popupTemplate: {
                title: "Tall Shrub Canopy Cover: {Map_Group}",
                content: [
                  {
                    type: "fields",
                    fieldInfos: [
                      {
                        fieldName: "Map_Group",
                        visible: true,
                        label: "Map_Group",
                      },
                      {
                        fieldName: "Dominance_Type",
                        visible: true,
                        label: "Dominance_Type",
                      },
                    ],
                  },
                ],
                overwriteActions: true,
              },
            },
          ],
        });

        /*****************************************************************
         * Add the layer to a map
         *****************************************************************/
        const map = new Map({
          basemap: "topo-vector",
          layers: [layer],
        });

        const view = new MapView({
          container: "viewDiv",
          map: map,
          extent: {
            xmax: -16725224.278226044,
            xmin: -16789584.256042186,
            ymax: 8432236.729622887,
            ymin: 8383240.594492071,
            spatialReference: 102100,
          },
        });
        const legend = new Legend({
          view: view,
        });
        view.ui.add(legend, "bottom-right");

 

 

 

0 Kudos
1 Reply
Sage_Wall
Esri Contributor

Hi @LakshanaRajendran ,

Thanks so much for taking the time to post here.  I can replicate the behavior of the class breaks reversing order in the Legend after clicking on the map.  It seems to only happen when popups are enabled.  I'll submit it as a bug, this is unexpected behavior.

0 Kudos