<?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 How to load geojson geometric data and drawing grapics in background in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-load-geojson-geometric-data-and-drawing/m-p/1373758#M83434</link>
    <description>&lt;P&gt;I meet a problem when trying to&amp;nbsp;load geojson geometric data and drawing grapics in background ;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main problem is&amp;nbsp;drawing grapics in backgroud, I use graphicLayer and hope each graphic in geojson can&amp;nbsp;be drawn on it. I try use web worker to make this processing performed in the background, but it failed.&lt;/P&gt;&lt;P&gt;The main problem is many esri library such as&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;"esri/Graphic", is a complex object, and inside that has some&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;infinite loop function, that cause the web worker can not pass the object to another file, like worker.js.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The code snippet is as following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;main.ejs:&lt;BR /&gt;&amp;nbsp;var usingObject = {&lt;BR /&gt;&amp;nbsp; Graphic: Graphic&lt;BR /&gt;&amp;nbsp;}&lt;BR /&gt;&amp;nbsp;const binaryData = msgpack.encode(usingObject);&lt;BR /&gt;&amp;nbsp;const base64String = btoa(String.fromCharCode.apply(null, binaryData));&lt;BR /&gt;&amp;nbsp;const worker = new Worker("worker.js");&lt;BR /&gt;&amp;nbsp;worker.postMessage(base64String);&lt;BR /&gt;...&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;worker.js:&lt;BR /&gt;&amp;nbsp;onmessage = function(event) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; const binaryData = atob(event.dat);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; const uint8Array = new Uint8Array(binaryData.length);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; for (let i = 0; i &amp;lt; binaryData.length; i++) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; uint8Array[i] = binaryData.charCodeAt(i);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp; const usingObject = json.msgpack.decode(uint8Array);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;var graphicsLayer = PlottingOnBackground(usingObject.Graphic);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;postMessage(graphicsLayer);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my envioronement is node.js, and is there any other way to help load geojson geometric data and drawing&amp;nbsp;&lt;/P&gt;&lt;P&gt;graphics in background?&amp;nbsp; any instruction is appreciated, thanks a lot.&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Fri, 26 Jan 2024 01:38:06 GMT</pubDate>
    <dc:creator>AbramhumHsu</dc:creator>
    <dc:date>2024-01-26T01:38:06Z</dc:date>
    <item>
      <title>How to load geojson geometric data and drawing grapics in background</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-load-geojson-geometric-data-and-drawing/m-p/1373758#M83434</link>
      <description>&lt;P&gt;I meet a problem when trying to&amp;nbsp;load geojson geometric data and drawing grapics in background ;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main problem is&amp;nbsp;drawing grapics in backgroud, I use graphicLayer and hope each graphic in geojson can&amp;nbsp;be drawn on it. I try use web worker to make this processing performed in the background, but it failed.&lt;/P&gt;&lt;P&gt;The main problem is many esri library such as&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;"esri/Graphic", is a complex object, and inside that has some&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;infinite loop function, that cause the web worker can not pass the object to another file, like worker.js.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The code snippet is as following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;main.ejs:&lt;BR /&gt;&amp;nbsp;var usingObject = {&lt;BR /&gt;&amp;nbsp; Graphic: Graphic&lt;BR /&gt;&amp;nbsp;}&lt;BR /&gt;&amp;nbsp;const binaryData = msgpack.encode(usingObject);&lt;BR /&gt;&amp;nbsp;const base64String = btoa(String.fromCharCode.apply(null, binaryData));&lt;BR /&gt;&amp;nbsp;const worker = new Worker("worker.js");&lt;BR /&gt;&amp;nbsp;worker.postMessage(base64String);&lt;BR /&gt;...&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;worker.js:&lt;BR /&gt;&amp;nbsp;onmessage = function(event) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; const binaryData = atob(event.dat);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; const uint8Array = new Uint8Array(binaryData.length);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; for (let i = 0; i &amp;lt; binaryData.length; i++) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; uint8Array[i] = binaryData.charCodeAt(i);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp; const usingObject = json.msgpack.decode(uint8Array);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;var graphicsLayer = PlottingOnBackground(usingObject.Graphic);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;postMessage(graphicsLayer);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my envioronement is node.js, and is there any other way to help load geojson geometric data and drawing&amp;nbsp;&lt;/P&gt;&lt;P&gt;graphics in background?&amp;nbsp; any instruction is appreciated, thanks a lot.&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 26 Jan 2024 01:38:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-load-geojson-geometric-data-and-drawing/m-p/1373758#M83434</guid>
      <dc:creator>AbramhumHsu</dc:creator>
      <dc:date>2024-01-26T01:38:06Z</dc:date>
    </item>
  </channel>
</rss>

