<?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: Custom canvas drawing in MapView v4.10 in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645804#M60194</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Yann,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yeah I've been trying to use BaseLayerView2D, but just can't get it quite right. It's working ok without the fade out of the existing drawing, so essentially an object will move around the canvas but without the trail. I can't stop it from clearing the context on each render call. Even with this happening, there is some flicker when zoomed out though.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using render() and requestRender() to form the animation loop, so something is happening in that pipeline that&amp;nbsp;won't maintain the previously drawn frame into the&amp;nbsp;current&amp;nbsp;frame...or more likely I'm just doing it wrong &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm guessing this has to do with the copying of the 2d context canvas to the webgl context for the actual drawing?? Have overridden the &lt;SPAN&gt;BaseLayerView2D&amp;nbsp;&lt;/SPAN&gt;containers doRender() method and played around in it a little to try and get around this, but no&amp;nbsp;joy so far. Didn't want to&amp;nbsp;go too far down the hole of overriding api code though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been trying all of this on a new layer that which will behave very similar to the existing one, but will be driven by feature polygons and not just GRIB data so it's more generic.&amp;nbsp;If I put the progress on github, whenever you get a chance would you be able to take a look?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Nick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Dec 2018 23:34:01 GMT</pubDate>
    <dc:creator>NickCameron2</dc:creator>
    <dc:date>2018-12-19T23:34:01Z</dc:date>
    <item>
      <title>Custom canvas drawing in MapView v4.10</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645802#M60192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm currently using one custom layer and am building another that draws on a canvas manually in a map view.&lt;/P&gt;&lt;P&gt;The existing one is here:&amp;nbsp;&lt;A href="https://github.com/nickcam/AnimatedEnvironmentLayer"&gt;https://github.com/nickcam/AnimatedEnvironmentLayer&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In v4.9 at a high level the following steps would&amp;nbsp;allow this to happen.&lt;/P&gt;&lt;P&gt;- Subclass a layer&lt;/P&gt;&lt;P&gt;- Create a new canvas element and append it to the container element of the layer.&lt;/P&gt;&lt;P&gt;- If a feature layer swap the context of the layer with one created from the new canvas.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In 4.10 with the drawing occurring all in one webgl context (which is great by the way!), I can't inject&amp;nbsp;a new canvas to&amp;nbsp;essentially replace the svg or the existing canvas for an individual layer.&lt;/P&gt;&lt;P&gt;I've tried using the BaseLayerView2D and can get part of the way, but each render() call seems to clear the context and I'm looking to maintain drawing across frames as in the layer linked above. I&amp;nbsp;don't have a simple example of this at the moment but can put one together if it would help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are there any examples or patterns that could help with this? Perhaps a custom draw BaseLayerView in a future release?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Dec 2018 21:40:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645802#M60192</guid>
      <dc:creator>NickCameron2</dc:creator>
      <dc:date>2018-12-19T21:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Custom canvas drawing in MapView v4.10</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645803#M60193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I checked out the project locally, pretty cool &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;To integrate properly in 2D you will have to implement a custom layerview by extending the BaseLayerView2D.&lt;/P&gt;&lt;P&gt;See&amp;nbsp;&lt;A class="jivelink10" href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-layers-BaseLayerView2D.html" title="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-layers-BaseLayerView2D.html"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-layers-BaseLayerView2D.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically you implement the base class and its render function. This function is called at each frame with the current view state as well as a canvas' ContextRendering2D that you can use to draw. Then we compose the canvas with the rest of the webgl content.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The base class also gives you information about tiles if you want this kind of info.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Yann&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Dec 2018 22:54:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645803#M60193</guid>
      <dc:creator>YannCabon</dc:creator>
      <dc:date>2018-12-19T22:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: Custom canvas drawing in MapView v4.10</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645804#M60194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Yann,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yeah I've been trying to use BaseLayerView2D, but just can't get it quite right. It's working ok without the fade out of the existing drawing, so essentially an object will move around the canvas but without the trail. I can't stop it from clearing the context on each render call. Even with this happening, there is some flicker when zoomed out though.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using render() and requestRender() to form the animation loop, so something is happening in that pipeline that&amp;nbsp;won't maintain the previously drawn frame into the&amp;nbsp;current&amp;nbsp;frame...or more likely I'm just doing it wrong &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm guessing this has to do with the copying of the 2d context canvas to the webgl context for the actual drawing?? Have overridden the &lt;SPAN&gt;BaseLayerView2D&amp;nbsp;&lt;/SPAN&gt;containers doRender() method and played around in it a little to try and get around this, but no&amp;nbsp;joy so far. Didn't want to&amp;nbsp;go too far down the hole of overriding api code though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been trying all of this on a new layer that which will behave very similar to the existing one, but will be driven by feature polygons and not just GRIB data so it's more generic.&amp;nbsp;If I put the progress on github, whenever you get a chance would you be able to take a look?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Nick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Dec 2018 23:34:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645804#M60194</guid>
      <dc:creator>NickCameron2</dc:creator>
      <dc:date>2018-12-19T23:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: Custom canvas drawing in MapView v4.10</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645805#M60195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I see,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The layerview is probably clearing the trail at every frame when it sets the canvas size which clears the previous content. What you can do is create your own canvas, draw the data in it, then use drawImage(canvas) on the context of the layerview.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Dec 2018 23:45:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645805#M60195</guid>
      <dc:creator>YannCabon</dc:creator>
      <dc:date>2018-12-19T23:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Custom canvas drawing in MapView v4.10</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645806#M60196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok cool. Will give that a crack.&lt;/P&gt;&lt;P&gt;I had originally tried creating and drawing on a new canvas as that worked prior to 4.10, and it draws fine using my own animation loop, but it was then outside the flow of the general map and it's layers. As in setting properties on the layer wouldn't affect the drawing, ie: opacity, visible, ordering, so basically broke the api to the layer. Could manually handle these except for the ordering I imagine though.&lt;/P&gt;&lt;P&gt;Anyway, will give that another go - thanks for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Dec 2018 23:59:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645806#M60196</guid>
      <dc:creator>NickCameron2</dc:creator>
      <dc:date>2018-12-19T23:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: Custom canvas drawing in MapView v4.10</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645807#M60197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ohhh...I think i misunderstood, now I get what you mean. Draw on the custom canvas, separate animation loop or whatever, but don't display it I guess, then draw that canvas contents to the internal api context as part of the render pipeline loop. That would keep the drawn layer in the normal flow. Once again, thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Dec 2018 00:20:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645807#M60197</guid>
      <dc:creator>NickCameron2</dc:creator>
      <dc:date>2018-12-20T00:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: Custom canvas drawing in MapView v4.10</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645808#M60198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for the spam comments...but just tried that out and it worked a treat!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Dec 2018 00:25:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645808#M60198</guid>
      <dc:creator>NickCameron2</dc:creator>
      <dc:date>2018-12-20T00:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: Custom canvas drawing in MapView v4.10</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645809#M60199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;no worries! happy that you got that working!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Dec 2018 00:27:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/custom-canvas-drawing-in-mapview-v4-10/m-p/645809#M60199</guid>
      <dc:creator>YannCabon</dc:creator>
      <dc:date>2018-12-20T00:27:18Z</dc:date>
    </item>
  </channel>
</rss>

