Select to view content in your preferred language

Pass dynamic value to Feature Layer renderer

1062
2
Jump to solution
08-25-2021 10:42 AM
RyanRundle
New Contributor

Hi. A little newer to ArcGIS. I'm trying to render a simple marker via a feature layer renderer but pass a dynamic angle value. We have a number of different markers based on certain field values so we're using the `unique-value` type. 

Layer looks like this:

          layerRef.current = new FeatureLayer({
            title         : stuff..
            id            : stuff..
            source        : graphics
            objectIdField : stuff..
            outFields     : stuff..
            fields        : stuff..
            renderer      : getHistoryByAssetRenderer(),
            popupTemplate : stuff..
          });

 

Here's a dumb version of the array of the source objects:

const graphics = [
    {
        eventType : 'direction',
        angle     : 67
    },
    { 
        eventType : 'turning'
        angle.    : 234
    }
]

then the renderer looks like so:

const getHistoryByAssetRenderer = () => ({
    type          : 'unique-value',
    field         : 'eventType',
    uniqueValueInfos : [
        ...,
        {
            value  : 'direction',
            symbol : {
                type    : 'simple-marker',
                style   : 'path',
                path    : EVENT_TRIANGLE_PATH,
                angle   : HOW DO I GET PASS THE ANGLE HERE???
                size.   : 10
                color   : fillColor,
                outline : {
                    color : outlineColor,
                    width
                }
        }
    ]
})
       
        

 

So of course the renderer handles finding the `eventType` field and rendering the marker based on the that field, but i'm not sure how to pass the angle to the symbol so the marker can be rotated. 

Some notes on what I've tried: 

Not sure if there is a way to use Roatation but it seems to balk when the renderer type is `unique-value`

Similar question: 

https://community.esri.com/t5/arcgis-appstudio-questions/how-to-rotate-renderer-icon-graphic-dynamic...

0 Kudos
1 Solution

Accepted Solutions
JohnGrayson
Esri Regular Contributor

Maybe try using a Rotation VisualVariable to do this task?  If it doesn't work for you, having a simple codepen (or similar) so we can see the code and experience the issue really helps.

View solution in original post

0 Kudos
2 Replies
JohnGrayson
Esri Regular Contributor

Maybe try using a Rotation VisualVariable to do this task?  If it doesn't work for you, having a simple codepen (or similar) so we can see the code and experience the issue really helps.

0 Kudos
RyanRundle
New Contributor

Ah thanks John. It worked once I added `angle` to the fields list that gets passed to the renderer (which I marked above as 'stuff'). Then added this to the renderer: 

    visualVariables : [{
      type         : 'rotation',
      field        : 'angle',
      rotationType : 'geographic'
    }]

 

0 Kudos