AnsweredAssumed Answered

Highlight features in a featurelayer using JSAPI 3.x

Question asked by ddeln@lakelandgov.net_LakelandFlorida on Oct 12, 2020
Latest reply on Oct 13, 2020 by ddeln@lakelandgov.net_LakelandFlorida

Hello All,

 

I am writing a custom trace tool widget, and will need to highlight features on a web map returned from the REST API.  I have a function called getFeatureLayers, and I'm calling it from the widget startup function, passing in a layerStructure that I get from the LayerStructure.getInstance().  To test highlighting, I am trying to highlight all features on the map first.  I thought I needed to use the selectFeatures method on FeatureLayer, but nothing gets highlighted on the map.  No errors or warnings are thrown, but nothing happens.  The traversal seems to work, as I get back 14 feature layers.  My code is below.  What am I missing?

 

       getFeatureLayers: function(layerStructure)
       {   
        var query = new Query();
        layerStructure.traversal(function(layerNode
        { 
          layerNode.getLayerType().then(function(ltype)
          { 
            if (ltype == 'FeatureLayer')
            {
              layerNode.getLayerObject().then(function(val)
              {
                query.where = '1 = 1';
                query.returnGeometry = true;
                query.outFields = ["*"];
                var symbol = new SimpleMarkerSymbol();
                symbol.style = SimpleMarkerSymbol.STYLE_SQUARE;
                symbol.setSize(8);
                symbol.setColor(new Color([255,255,0,0.5]));
                val.setSelectionSymbol(symbol);
                val.selectFeatures(queryFeatureLayer.SELECTION_NEWfunction(result){console.log(result)});
              });
            }
          });
        });
       }

Outcomes