graphicsLayer has a method: setRenderer(renderer)

How to set certain graphic elements of graphicsLayer using UniqueValueRenderer? Any example available? Did not find anything like this on Google therefore opened this issue here. Using: js arcgis 3.23 Is this actually supported in js arcgis version 3.x? As far as I know it is not supported in js arcgis version 4.x

  • Don't forget to to take the Tour. For questions that involve code we ask that you show us where you are stuck with your own code by including a code snippet in your question. There is an edit button beneath your question which will enable you to do that and a {} button that enables you to format any highlighted code nicely. – PolyGeo May 29 '18 at 7:58
  • Dear @PolyGeo [link] (gis.stackexchange.com/users/115/polygeo) - I found solution to my question and I have answered it. See: "THE ANSWER: LINK" that I added at the end of the original question as I did not find a way to publish it as the answer - probably because you placed my question on hold. I'm happy I managed to document this important issue as public SDK/manual coverage was missing. Good day! – Moshe May 30 '18 at 4:19
  • The answer you gave at Stack Overflow is code only, but if you plan to add some explanatory text to it here, then ping me and I can re-open to enable you to do so. – PolyGeo May 30 '18 at 4:58
  • @PolyGeo - Yes I plan to add some explanatory text to it here. Thanks and have a good day! – Moshe May 30 '18 at 5:40
  • It's re-opened now. – PolyGeo May 30 '18 at 5:54

Did not find a solution on the web so I had no choice but to investigate it on my own. The main question was: how to talk to each graphic element that belongs to a certain graphicsLayer using UniqueValueRenderer. Could not figure out from the ESRI js arcgis 3.23 API and examples what could be the right interface and syntax to use. After experimenting a lot with the code came to the following conclusions:

  1. Symbols defined at the Graphic layer always override symbols defined in a renderer. Therefore I instanced each Graphic using no Symbol.
  2. In order to communicate with each Graphic separately UniqueValueRenderer needs to find some attribute on each Graphic therefore I added an attribute to each Graphic.
  3. Now I attempted to use the Graphic attribute name in the UniqueValueRenderer while using Graphic attribute value to let UniqueValueRenderer select custom symbol for each Graphic.
  4. The syntax for UniqueValueRenderer integration with graphicsLayer was not clear from the available documentation and ESRI examples but I experimented with various options and possibilities intuitively and I managed to make it work!

Here you can find the solution code snippet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.