How to get the LayerView style

259
0
10-08-2020 03:13 PM
GregoryBologna
Occasional Contributor II

I have a SketchViewModel for a graphics layer. When I add the layerView to it I need to change some styling at runtime.

// create a featureLayer

//

const featureLayer = new FeatureLayer({
   url: myurl
});

map.add(featureLayer);

// create a mapview and 

//

var view = new MapView({
   map: map

   / / other stuff here

});

// Given this basic featureLayer example, I will wait for the layerView to be ready.

//

view.whenLayerView(featureLayer).then(function(layerView) {

      How would you go about accessing and changing the style for a LayerView without

   sifting through all the layers as in the example below?
}); 

Is there a shorter way to get to the layerview style?

// this is just an example of what I do not want to do

//

var maplayers = item.layer.parent.allLayers.filter(function (a) {
   return a.title === "my layer";
});

var style  = maplayers.items[0].sublayers.items.filter(function (a) {

// do my runtime styling work here

});

Tags (1)
0 Kudos
0 Replies