<?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: Graphics added to GraphicLayer do not render until you zoom in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-added-to-graphiclayer-do-not-render-until/m-p/1337075#M82444</link>
    <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/619295"&gt;@patryks&lt;/a&gt;&amp;nbsp;! I'm having some trouble reproducing this problem. I may be misunderstanding your question, but something like this works for me:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Add graphics to map
const graphicsLayer = new GraphicsLayer();
map.add(graphicsLayer);
graphicsLayer.addMany([ ...rows, ...cols ]);

// Rotate graphics
for (const graphic of graphicsLayer.graphics) {
  graphic.geometry = geometryEngine.rotate(graphic.geometry, angle, point);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you be willing to share your code, or a simplified example of the problem in a codepen?&lt;/P&gt;</description>
    <pubDate>Wed, 11 Oct 2023 19:45:15 GMT</pubDate>
    <dc:creator>SamEngel</dc:creator>
    <dc:date>2023-10-11T19:45:15Z</dc:date>
    <item>
      <title>Graphics added to GraphicLayer do not render until you zoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-added-to-graphiclayer-do-not-render-until/m-p/1336792#M82432</link>
      <description>&lt;P&gt;I have found similar bug from 2021&amp;nbsp;&lt;A href="https://github.com/Esri/feedback-js-api-next/issues/122" target="_blank"&gt;https://github.com/Esri/feedback-js-api-next/issues/122&lt;/A&gt;&amp;nbsp;but my case is different (don't use Zone.js) and according to post in forum &lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-in-a-graphics-layer-only-appear-on-zoom/td-p/1037515" target="_blank"&gt;https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-in-a-graphics-layer-only-appear-on-zoom/td-p/1037515&lt;/A&gt; the issue should be fixed.&lt;/P&gt;&lt;P&gt;In my case I generate grid (1km x 1km) drawing polyline every 5 meters. When the vectors are straight everything works just fine and the grid renders instantly. I have an options to rotate the lines with configurable angle. To calculate the grid I rotate every vector with following code:&lt;/P&gt;&lt;PRE&gt;geometryEngine.&lt;SPAN&gt;rotate&lt;/SPAN&gt;(geometry&lt;SPAN&gt;, &lt;/SPAN&gt;angle&lt;SPAN&gt;, &lt;/SPAN&gt;point)&lt;/PRE&gt;&lt;P&gt;The problem is that the graphics are not rendered until I change the zoom level of the map. I tried to use the workaround from the post i mentioned with cloning symbols and then reapplying it to graphics after timeout and it works partialy as the other way around the old symbols stays on map until zoom level is changed.&lt;/P&gt;&lt;P&gt;Is there an option to refresh graphic or to reaply/rerender graphic symbols somehow?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2023 23:54:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-added-to-graphiclayer-do-not-render-until/m-p/1336792#M82432</guid>
      <dc:creator>patryks</dc:creator>
      <dc:date>2023-10-10T23:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: Graphics added to GraphicLayer do not render until you zoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-added-to-graphiclayer-do-not-render-until/m-p/1337075#M82444</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/619295"&gt;@patryks&lt;/a&gt;&amp;nbsp;! I'm having some trouble reproducing this problem. I may be misunderstanding your question, but something like this works for me:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Add graphics to map
const graphicsLayer = new GraphicsLayer();
map.add(graphicsLayer);
graphicsLayer.addMany([ ...rows, ...cols ]);

// Rotate graphics
for (const graphic of graphicsLayer.graphics) {
  graphic.geometry = geometryEngine.rotate(graphic.geometry, angle, point);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you be willing to share your code, or a simplified example of the problem in a codepen?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 19:45:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-added-to-graphiclayer-do-not-render-until/m-p/1337075#M82444</guid>
      <dc:creator>SamEngel</dc:creator>
      <dc:date>2023-10-11T19:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: Graphics added to GraphicLayer do not render until you zoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-added-to-graphiclayer-do-not-render-until/m-p/1337995#M82465</link>
      <description>&lt;P&gt;Thank you for your time &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/529233"&gt;@SamEngel&lt;/a&gt;. Your example helped me find the solution to my problem. My code that generates the grid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Graphic generation:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;for &lt;/SPAN&gt;(&lt;SPAN&gt;let &lt;/SPAN&gt;x = xmin&lt;SPAN&gt;; &lt;/SPAN&gt;x &amp;lt;= xmax&lt;SPAN&gt;; &lt;/SPAN&gt;x = x + precision) {&lt;BR /&gt;    x = &lt;SPAN&gt;Number&lt;/SPAN&gt;(x.&lt;SPAN&gt;toFixed&lt;/SPAN&gt;(&lt;SPAN&gt;6&lt;/SPAN&gt;))&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    let &lt;/SPAN&gt;line = &lt;SPAN&gt;new &lt;/SPAN&gt;Polyline({&lt;BR /&gt;        &lt;SPAN&gt;spatialReference&lt;/SPAN&gt;: geometry.&lt;SPAN&gt;spatialReference&lt;BR /&gt;&lt;/SPAN&gt;    })&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;    line.&lt;SPAN&gt;addPath&lt;/SPAN&gt;([[x&lt;SPAN&gt;, &lt;/SPAN&gt;ymin]&lt;SPAN&gt;, &lt;/SPAN&gt;[x&lt;SPAN&gt;, &lt;/SPAN&gt;ymax]])&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;    line = &amp;lt;Polyline&amp;gt;GeometryService.&lt;SPAN&gt;clip&lt;/SPAN&gt;(GeometryService.&lt;SPAN&gt;rotate&lt;/SPAN&gt;(line&lt;SPAN&gt;, &lt;/SPAN&gt;angle&lt;SPAN&gt;, new &lt;/SPAN&gt;Point({&lt;SPAN&gt;x&lt;/SPAN&gt;: extent.&lt;SPAN&gt;xmin&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;y&lt;/SPAN&gt;: extent.&lt;SPAN&gt;ymin&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;spatialReference&lt;/SPAN&gt;: geometry.&lt;SPAN&gt;spatialReference&lt;/SPAN&gt;}))&lt;SPAN&gt;, &lt;/SPAN&gt;extent.&lt;SPAN&gt;extent&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    const &lt;/SPAN&gt;graphic = &lt;SPAN&gt;new &lt;/SPAN&gt;Graphic({&lt;BR /&gt;        &lt;SPAN&gt;geometry&lt;/SPAN&gt;: line&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;        &lt;SPAN&gt;symbol&lt;/SPAN&gt;: StyleService.&lt;SPAN&gt;createPolylineDefaultStyle&lt;/SPAN&gt;()&lt;BR /&gt;    })&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;    graphics.&lt;SPAN&gt;push&lt;/SPAN&gt;(graphic)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;}&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN&gt;for &lt;/SPAN&gt;(&lt;SPAN&gt;let &lt;/SPAN&gt;y = ymin&lt;SPAN&gt;; &lt;/SPAN&gt;y &amp;lt;= ymax&lt;SPAN&gt;; &lt;/SPAN&gt;y = y + precision) {&lt;BR /&gt;    &lt;SPAN&gt;let &lt;/SPAN&gt;line = &lt;SPAN&gt;new &lt;/SPAN&gt;Polyline({&lt;BR /&gt;        &lt;SPAN&gt;spatialReference&lt;/SPAN&gt;: geometry.&lt;SPAN&gt;spatialReference&lt;BR /&gt;&lt;/SPAN&gt;    })&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;    line.&lt;SPAN&gt;addPath&lt;/SPAN&gt;([[xmin&lt;SPAN&gt;, &lt;/SPAN&gt;y]&lt;SPAN&gt;, &lt;/SPAN&gt;[xmax&lt;SPAN&gt;, &lt;/SPAN&gt;y]])&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;    line = &amp;lt;Polyline&amp;gt;GeometryService.&lt;SPAN&gt;clip&lt;/SPAN&gt;(GeometryService.&lt;SPAN&gt;rotate&lt;/SPAN&gt;(line&lt;SPAN&gt;, &lt;/SPAN&gt;angle&lt;SPAN&gt;, new &lt;/SPAN&gt;Point({&lt;SPAN&gt;x&lt;/SPAN&gt;: extent.&lt;SPAN&gt;xmin&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;y&lt;/SPAN&gt;: extent.&lt;SPAN&gt;ymin&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;spatialReference&lt;/SPAN&gt;: geometry.&lt;SPAN&gt;spatialReference&lt;/SPAN&gt;}))&lt;SPAN&gt;, &lt;/SPAN&gt;extent.&lt;SPAN&gt;extent&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    const &lt;/SPAN&gt;graphic = &lt;SPAN&gt;new &lt;/SPAN&gt;Graphic({&lt;BR /&gt;        &lt;SPAN&gt;geometry&lt;/SPAN&gt;: line&lt;BR /&gt;    })&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;    graphics.&lt;SPAN&gt;push&lt;/SPAN&gt;(graphic)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;}&lt;/PRE&gt;&lt;P&gt;Adding generated graphics to layer:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;this&lt;/SPAN&gt;.&lt;SPAN&gt;gridLayer&lt;/SPAN&gt;.&lt;SPAN&gt;removeAll&lt;/SPAN&gt;()&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;this&lt;/SPAN&gt;.&lt;SPAN&gt;gridLayer&lt;/SPAN&gt;.&lt;SPAN&gt;addMany&lt;/SPAN&gt;(graphics)&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;It renders correctly when I generate less than 600 lines, with more there is a problem. In my case, I am adding already rotated lines.&lt;/P&gt;&lt;P&gt;The way you did it works. You first added graphics, then modified the geometry of the graphic. With modification to my code:&lt;/P&gt;&lt;PRE&gt;const graphics = &lt;SPAN&gt;this&lt;/SPAN&gt;.&lt;SPAN&gt;calculateGridWithoutAngle&lt;/SPAN&gt;(geometry&lt;SPAN&gt;, &lt;/SPAN&gt;precision)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;this&lt;/SPAN&gt;.&lt;SPAN&gt;gridLayer&lt;/SPAN&gt;.&lt;SPAN&gt;removeAll&lt;/SPAN&gt;()&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;this&lt;/SPAN&gt;.&lt;SPAN&gt;gridLayer&lt;/SPAN&gt;.&lt;SPAN&gt;addMany&lt;/SPAN&gt;(graphics)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;this&lt;/SPAN&gt;.&lt;SPAN&gt;rotateGraphics&lt;/SPAN&gt;(geometry&lt;SPAN&gt;, &lt;/SPAN&gt;graphics&lt;SPAN&gt;, &lt;/SPAN&gt;angle)&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;everything works as expected.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Oct 2023 09:14:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/graphics-added-to-graphiclayer-do-not-render-until/m-p/1337995#M82465</guid>
      <dc:creator>patryks</dc:creator>
      <dc:date>2023-10-14T09:14:34Z</dc:date>
    </item>
  </channel>
</rss>

