Is HTML5 canvas-driven layers part of the ArcGIS javascript toolkit's future?

4352
4
01-19-2012 09:55 AM
RexBradford
New Contributor II
I'm just curious if there are any plans to use HTML5 <canvas> elements as an option in layers.

I am exploring creating a custom "feature layer" using a <canvas> overlaid on the map because in my admittedly informal testing it seems much faster for drawing lots of small marker-type images (i.e., a couple of thousand), compared to doing them in a Graphics layer.  Complications of this "outside the toolkit" approach include layer stacking (always on top is all I need, but...) and proper mouse event handling (i.e., routing events not handled by the <canvas> layer to the underlying map layers).

Obviously this would require HTML5 browsers, which doesn't include IE 7/8 without use of far slower compatibility add-on libraries, but still it seems like a nice option to have in the toolkit - i.e., if the toolkit could use <canvas> rather than svg optionally for the whole stack of layers.

Are there any plans or tentative plans or experiments in this direction?

Rex Bradford
Direct Relief International
0 Kudos
4 Replies
derekswingley1
Frequent Contributor
You can already do it!

Since graphics layers (and feature layers) use dojox.gfx to draw shapes, you can explicitly tell dojo to use canvas. This is as simple as specifying canvas for gfxrenderer:
    <script>
      var dojoConfig = { 
        "gfxRenderer": "canvas",
        "isDebug": true,
        "parseOnLoad": true 
      };
    </script>


I've done some testing with this and didn't see huge gains over using SVG. YMMV.
0 Kudos
DonnyVelazquez
Occasional Contributor
The only thing that means is that dojo's implementation of drawing on canvas is slow.
0 Kudos
RexBradford
New Contributor II
Thanks.  I tried it out and it worked.  Though when panning the map the canvas layer didn't redraw at the same time as the base map, which was disconcerting.

There was no obvious performance improvement over svg in my one test, though I didn't try to measure carefully.

Rex
0 Kudos
mingchunfan
New Contributor
hill,I am doing this?
do you have a demo about "Is HTML5 canvas-driven layers part of the ArcGIS javascript toolkit's future?" .