Creating a custom LayerView.

05-25-2019 10:16 AM
New Contributor III


I have a few questions about LayerViews that I can't seem to answer anyplace else:

        1. - What is the lifecycle of a LayerView, specifically the

GraphicsLayerView ("esri/views/2d/layers/GraphicsLayerView2D") or FeatureLayerView.  I looking for something like: attach, cache and watch graphics, render, catch update events and render, detach?

         2. - can I tell the LayerView to watch an alternate graphics or source collection than the main one for the layer?

         3. - Can I create a subclass of the GraphicsLayerView or FeatureLayerView, and override attach to set up my own                graphics caching while allowing the LayerView to do all of its other functions about which I don't care?

A single layer can be watched by several views and each view can have a different zoom reference to the same layer, so our old clustering logic will only work in one view and cause or graphics to llogically display in other views since it replaces the content of the layer graphics for all views. 

What I want to do is create a custom LayerView that extends the Graphics or Feature layer, avoiding the task of writing gfx code, and replace or override its graphics collection with one I can control.  I want to be able to give that LayerView only those graphics that are available at that view's, resolution and zoom level.  If zoomed out, some features will be clustered, when zoomed in, those features will be individuals again.  

If the solution is as simple as asking the existing LayerView to change its relationship to the layer's graphics, then I am very open to this.

0 Replies