Select to view content in your preferred language

JSAPI UniqueValueRenderer with FeatureLayer and Source (not URL) Work?

457
4
03-18-2022 10:31 AM
rbossio
New Contributor II

I'm building a FeatureLayer dynamically on the UI. Basically, I create a new FeatureLayer and set the Source field. Using basic renderer, the layer displays correctly (simple-fill symbol with specific color). But, if I use UniqueValueRenderer no features render. I can verify that I'm referencing the correct field in the UniqueValueInfo. My first questions is, does the UniqueValueRenderer work with a FeatureLayer built entirely on the client using "Source" field, rather than referencing an online layer? If so, are there any examples of that (I can't find any). Thanks.

Tags (1)
0 Kudos
4 Replies
KristianEkenes
Esri Regular Contributor

Yes, this works. Do you have a link to your app so I can take a look at where it's failing? Here's an example of this working: https://codepen.io/kekenes/pen/JjMXKVa?editors=100

0 Kudos
rbossio
New Contributor II

Thanks Kristian - unfortunately, the app is internal only. I think I have a bigger problem in that I can't get a simple UniqueValueRender to work from esri tutorials. I'm wondering if I'm missing something. Link below defines the renderer, adds a UniqueValueInfo, creates the FeatureLayer with the renderer, and adds to the map. If I display the hosted feature layer without specifying a renderer, I can see all the features. When I add the renderer to the feature layer, no features display. Am I missing some setting maybe?

NOTE: Link to feature in codepen is a public feauture layer 

https://codepen.io/rjbtampa/pen/PoEGPVL

Sample Feature Data:

rbossio_0-1647965961572.png

 

 

 

0 Kudos
JoelBennett
MVP Regular Contributor

If the data you're using is point data, as in your example, you should use SimpleMarkerSymbol instead, which is intended for rendering points.  SimpleFillSymbol, on the other hand, is intended for rendering polygons.

0 Kudos
KristianEkenes
Esri Regular Contributor

Yep. Joel is correct. If you use simple marker symbols, it works: https://codepen.io/kekenes/pen/popegLv?editors=1000

This can be a little confusing. You can use SimpleFillSymbol and SimpleMarkerSymbol on polygon layers, but only SimpleMarkerSymbol for point layers.

0 Kudos