AnsweredAssumed Answered

Follow up: Feature service layer symbol/renderer change

Question asked by processing... on Mar 8, 2016
Latest reply on Mar 11, 2016 by processing...

As a follow up question to this link: https://community.esri.com/message/593549

 

I select the symbol that I want to change by creating img elements and adding attributes such as index, id, etc. It's the onclick of that image that triggers the iteration through the layer's symbols to match the img.attribute['index'] with the iteration of the symbol loop. Then, I setUrl for that symbol.

 

I couldn't find the proper way to look at a collection of symbols. I noticed that if a layer/service has 1 symbol in the renderer, there is a layer.renderer.symbol object. If there is a collection of symbols, layer.renderer.symbol is undefined but layer.renderer._symbols is an object. I iterate through _symbols with for (key in layer.renderer_symbols).

 

I check the layer.renderer._symbols[key].type for 'picturemarkersymbol' then check to see if the img element (that the user clicked) index attribute matches key (so that I am stopping the loop to setUrl on the correct symbol).

 

I sort of do the same thing if the type is simplemarkersymbol. The difference is that I can't setUrl of a simplemarkersymbol so I try to do layer.renderer._symbols[key].setSymbol(new PictureMarkerSymbol...). However, layer.renderer._symbols[key] does not support 'setSymbol'.

 

I also tried messing with the setRenderer but that affects all of the other symbols on the layer. This particular layer that I'm testing has several symbols of different types.

 

What is the proper way to set the symbol of just one symbol in a collection of symbols?

 

Is there a better way to reference the collection of symbols in lieu of layer.renderer._symbols?

 

I feel like I'm also going to have the same issues when I try to change the simpleline and simplefill symbols? I will be changing their colors and thickness only though. I won't be changing the simpleline to a picture or anything too off the wall.

 

Thank you

Outcomes