<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Rotation with an offset in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/rotation-with-an-offset/m-p/1168028#M77146</link>
    <description>&lt;P&gt;Hi Nicolai,&lt;/P&gt;&lt;P&gt;I believe you can achieve the desired result using a CIMSymbol. Is this the behavior you're seeking to achieve?&amp;nbsp;&lt;A href="https://codepen.io/kekenes/pen/GRybwZV" target="_blank"&gt;https://codepen.io/kekenes/pen/GRybwZV&lt;/A&gt;&amp;nbsp;Rather than use a rotation visual variable, I set a primitive override for rotation on just the arrow symbol layer. That will rotate the arrow symbol layer in place and not the entire symbol.&amp;nbsp;&lt;/P&gt;&lt;P&gt;CIM is a bit complicated, so let me now if you find the code in the pen confusing, or if you would like further explanation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kristian&lt;/P&gt;</description>
    <pubDate>Tue, 26 Apr 2022 18:03:30 GMT</pubDate>
    <dc:creator>KristianEkenes</dc:creator>
    <dc:date>2022-04-26T18:03:30Z</dc:date>
    <item>
      <title>Rotation with an offset</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/rotation-with-an-offset/m-p/1167890#M77135</link>
      <description>&lt;P&gt;The following code shows 2 layers. Each of them containing features with the same coordinates.&lt;BR /&gt;The goal of these featues is #1 to display a coordinate (red point) and #2 display a fixed direction from this coordinate (yellow arrow).&lt;/P&gt;&lt;P&gt;What I noticed is, when you change the value of 'field' (field: WIND_DIRECT) in the visualVariable array, the arrow turns/points in the direction &lt;EM&gt;on its own axis&lt;/EM&gt;, as expected. However, &lt;EM&gt;when you define an offset &lt;/EM&gt;(y or x, in this case yoffset) in the symbol (in this case the arrow, to make it visible behind the red dot), the arrow then &lt;EM&gt;doesn't rotates on its own axis anymore but rotates around the red dot &lt;/EM&gt;(or the defined coordinate).&lt;/P&gt;&lt;P&gt;So my question is, is it possible to give the arrow an offset of (e.g. yoffset: 10 ) but at a fixed position next to the red dot? -So that the arrow still recieves values through the WIND_DIRECT field, but then rotating itself around its own axis, &lt;EM&gt;at a fixed position next to the red dot&lt;/EM&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: I've already tried a few solutions to fix this, and adjusting the angle in the symbol is currently not an option&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The Problem&lt;/STRONG&gt; (arrow rotates around the red dot and not staying at a fixed position next to it, when changing the rotationExpression/field value):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DotsArrowProblem.png" style="width: 781px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/39850i2FB55F1D55E9E51F/image-dimensions/781x392?v=v2" width="781" height="392" role="button" title="DotsArrowProblem.png" alt="DotsArrowProblem.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta
      name="viewport"
      content="initial-scale=1, maximum-scale=1,user-scalable=no"
    /&amp;gt;
    &amp;lt;title&amp;gt;
      Visualize data with rotation | Sample | ArcGIS API for JavaScript 4.23
    &amp;lt;/title&amp;gt;

    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
      }
    &amp;lt;/style&amp;gt;

    &amp;lt;link
      rel="stylesheet"
      href="https://js.arcgis.com/4.23/esri/themes/light/main.css"
    /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.23/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script&amp;gt;
      require(["esri/Map", "esri/views/MapView", "esri/layers/FeatureLayer"], (
        Map,
        MapView,
        FeatureLayer
      ) =&amp;gt; {
        const symbolArrow = {
          type: "simple-marker", 
          path: "M14.5,29 23.5,0 14.5,9 5.5,0z",
          color: "#ffff00",
          outline: {
            color: [0, 0, 0, 0.7],
            width: 0.5
          },
          angle: 180,
          size: 15,
          yoffset: 15
        };
        let symbolRedDot = {
          type: "simple-marker",  
          color: "red",
          outline: {  
          color: [ 128, 128, 128, 1 ],
            outline: {
            color: [0, 0, 0, 0.7],
            width: 0.5
          },
          width: "0.1px"
          }
        };
        const rotationRendererYellow = {
          type: "simple", 
          symbol: symbolArrow,
          visualVariables: [
            {
              type: "rotation",
              field: "WIND_DIRECT",
              rotationType: "geographic"
            },
            {
              type: "size",
              field: "WIND_SPEED",
              minDataValue: 0,
              maxDataValue: 60,
              minSize: 10,
              maxSize: 10,
            }
          ]
        };
        const rotationRendererRed = {
          type: "simple", 
          symbol: symbolRedDot,
        };
        
        const layerRed = new FeatureLayer({
          url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/weather_stations_010417/FeatureServer/0",
          renderer: rotationRendererRed
        });
        const layerYellow = new FeatureLayer({
          url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/weather_stations_010417/FeatureServer/0",
          renderer: rotationRendererYellow
        });

        const map = new Map({
          basemap: "satellite",
          layers: [layerYellow, layerRed]
        });

        const view = new MapView({
          container: "viewDiv",
          map: map,
          extent: {
            spatialReference: { wkid: 3857 },
            xmin: -41525513,
            ymin: 4969181,
            xmax: -36687355,
            ymax: 9024624
          }
        });
      });
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 12:50:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/rotation-with-an-offset/m-p/1167890#M77135</guid>
      <dc:creator>Nicolai045</dc:creator>
      <dc:date>2022-04-26T12:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: Rotation with an offset</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/rotation-with-an-offset/m-p/1167910#M77137</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm quite new to this, but I have an idea.&lt;/P&gt;&lt;P&gt;Would it be possible to calculate the yoffset and xoffset based on the angle? Since you always want to have the arrow on position X=0 and Y=15, when the arrow would point to the for example right you need to cancel the offset by X-15 and Y+15 to get back to the top of the circle.&lt;/P&gt;&lt;P&gt;Seems like a simple Pythagorean theorem. But I'm not sure whether you can feed data to calculate the renderer. You might need to query the angle first for each feature.&lt;/P&gt;&lt;P&gt;I hope this helps a bit. Good luck!&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 13:46:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/rotation-with-an-offset/m-p/1167910#M77137</guid>
      <dc:creator>MartinPorteš</dc:creator>
      <dc:date>2022-04-26T13:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Rotation with an offset</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/rotation-with-an-offset/m-p/1167916#M77138</link>
      <description>&lt;P&gt;I did a really quick check if the idea can work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you change&amp;nbsp;&lt;SPAN&gt;symbolArrow to&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;yoffset&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;xoffset&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;SPAN&gt; -&lt;/SPAN&gt;&lt;SPAN&gt;15 and use definition on the&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;layerYellow:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;definitionExpression&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;"WIND_DIRECT = 90" shown arrows render as you described.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Basically you need to calculete where on the circle the arrow would end up and then move it accordingly to fit the visualisation. As I said not sure if you can calculate that for each point, but maybe you can return that from query using the fromJson method for VisualVariable?&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-visualVariables-VisualVariable.html#fromJSON" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-visualVariables-VisualVariable.html#fromJSON&lt;/A&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Martin&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 14:03:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/rotation-with-an-offset/m-p/1167916#M77138</guid>
      <dc:creator>MartinPorteš</dc:creator>
      <dc:date>2022-04-26T14:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Rotation with an offset</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/rotation-with-an-offset/m-p/1167946#M77139</link>
      <description>&lt;P&gt;Hi Martin,&lt;/P&gt;&lt;P&gt;Thank you for your thoughtful reply. While it seems like a considerable solution for the shown example above, my actual code varies a bit from the displayed one. I also apologize for not making it clear in that case. Similar to the angle I currently can't dynamically change any value inside the Symbol. I've actually tried it with Arcade Expressions from Esri, but it doesn't work in my case. Therefore, I'm searching for a solution that happens outside of the Symbol.&amp;nbsp; I know it is very specific, but it is what is is. Nevertheless, thank you for the effort!&lt;/P&gt;&lt;P&gt;Nicolai&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 15:17:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/rotation-with-an-offset/m-p/1167946#M77139</guid>
      <dc:creator>Nicolai045</dc:creator>
      <dc:date>2022-04-26T15:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Rotation with an offset</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/rotation-with-an-offset/m-p/1168028#M77146</link>
      <description>&lt;P&gt;Hi Nicolai,&lt;/P&gt;&lt;P&gt;I believe you can achieve the desired result using a CIMSymbol. Is this the behavior you're seeking to achieve?&amp;nbsp;&lt;A href="https://codepen.io/kekenes/pen/GRybwZV" target="_blank"&gt;https://codepen.io/kekenes/pen/GRybwZV&lt;/A&gt;&amp;nbsp;Rather than use a rotation visual variable, I set a primitive override for rotation on just the arrow symbol layer. That will rotate the arrow symbol layer in place and not the entire symbol.&amp;nbsp;&lt;/P&gt;&lt;P&gt;CIM is a bit complicated, so let me now if you find the code in the pen confusing, or if you would like further explanation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kristian&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 18:03:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/rotation-with-an-offset/m-p/1168028#M77146</guid>
      <dc:creator>KristianEkenes</dc:creator>
      <dc:date>2022-04-26T18:03:30Z</dc:date>
    </item>
  </channel>
</rss>

