Select to view content in your preferred language

Rotate a webstyle symbol with visual variables

729
5
04-26-2022 09:15 AM
Erlend_Førde_Schjetne
New Contributor II

Hi, I'm struggling with rotating a webstyle symbol that i've created. 

The rotationVariable i set on the renderer is prettty much disregarded, it wont rotate based on the field value ive specified. For some reason the only time I am able to rotate the symbol in any way is when i use the random function in Arcade in a ValueExpression to generate a random rotational direction between 0 and 360. If i try to return the field "rotation"'s value in the valueExpression, nothing happens.  

Any clue to what might be hindering the rotation based on a field value?

        const renderer = {
          type: "simple", // autocasts as new SimpleRenderer()
          symbol: {
            type: "web-style", // autocasts as new WebStyleSymbol()
			styleUrl: "https://someOrgAccount.maps.arcgis.com/sharing/rest/content/items/xxxxxxxxxxxxxxxxxxx/data",
            name: "Point symbol"
          },
          label: "label"
        };

		var sv = new SizeVariable();
		sv.field = "hoyde";
		sv.axis= "height";
		sv.minDataValue= 2;
		sv.maxDataValue= 3;
		sv.minSize= 2;
		sv.maxSize= 3;

		var rv = new RotationVariable();
		rv.field = "rotation";
		rv.rotationType = "geographic";
		rv.axis = "heading";
		rv.valueExpression = "Random() * 360";

		renderer.visualVariables = [ rv, sv ];

 

 

0 Kudos
5 Replies
KristianEkenes
Esri Regular Contributor

Hi, 

Do you happen to have a codepen or some other way to share the app code? Or alternatively a link to the data you're using? The code above looks correct. It's hard to diagnose the issue without the data. Something like this might happen if the field you reference is a string field, or has null values.

0 Kudos
Erlend_Førde_Schjetne
New Contributor II

I see now after setting up a Codepen with a new sample point dataset, that rotating the symbols and varying size based on attribute values works with data that are in Epsg 3857 (Web Mercator).

My original dataset was in Epsg 25833, and that didnt work. But as soon as I reprojected the dataset  to Epsg 3857 it was working fine. 

I dont know if this is a bug or intentional, but I cant see anything about this in the JS API docs.

0 Kudos
KristianEkenes
Esri Regular Contributor

That's definitely a bug. Not intentional. I'll try to reproduce on my side.

0 Kudos
Erlend_Førde_Schjetne
New Contributor II

I just tested with a new dataset in 25833 with the same fields and values and now it worked. So it seems like its not linked to the coordsys, but could be something wrong with my original dataset, or maybe som cached files in my browser which caused it to now load as it should.

Since its now working as expected and i dont know what caused it i guess this thread can be delted. 

Thanks for the help though!

0 Kudos