Feature Layer/Service - Changing Symbols

2486
3
Jump to solution
03-07-2016 11:39 AM
TyroneBiggums
Occasional Contributor III

My UI is set up with 2 lists. The first list shows the symbols of a selected feature layer. The second list shows options of what a symbol can be changed to.

For example, if the layer's renderer has a single picturemarkersymbol, the image displays in one list and the second list will show a series of graphics the user can select from.

Another example, if the layer's renderer has a collection of symbols (some picturemarkersymbols, some simplemakersymbols), all of the symbols are represented in the first list and the second list shows a series of images.

The idea is to select 1 from the first list and 1 from the second list. When the user submits, the new symbols should replace the old symbol.

I have everything done except for updating the symbols. Breaking down my code, and simplifying it, I have:

var path = jqueryUnorderedList.find('img')[0].attributes['src'].value;
map.getLayer(id).renderer.symbol.setUrl(path);

Nothing happens. The original PMS still exist on the map. What am I missing?

Also, what's the proper way to change renderer's completely? If I have a SMS and want to change to a PMS, do I need to setRenderer on the layer? I tried that too... nothing happens. Nothing on the map changes and nothing shows in the F12 console log.

Thank you for the help!

0 Kudos
1 Solution

Accepted Solutions
TimWitt2
MVP Alum

Did you try and run yourfeaturelayername.redraw(); after you set the render?

Also this is what I use to set the render of a featurelayer:

FeatureLayer | API Reference | ArcGIS API for JavaScript

View solution in original post

3 Replies
TimWitt2
MVP Alum

Did you try and run yourfeaturelayername.redraw(); after you set the render?

Also this is what I use to set the render of a featurelayer:

FeatureLayer | API Reference | ArcGIS API for JavaScript

TyroneBiggums
Occasional Contributor III

That was it. I was missing the redraw. I didn't know it existed.

I am using the setRenderer too if the symbol is a SMS. If the symbol is already a PMS, I just setUrl... both need redraw... apparently.


Thanks!

0 Kudos
TimWitt2
MVP Alum

No problem, I had the same issue until I decided to redraw

0 Kudos