Prevent Errors or 2D Views Loading 3D Layers

Idea created by ryan.sutcliffe on May 1, 2020
    • ryan.sutcliffe

    This isn't an exciting new feature idea. It's just a fix to a vexing problem with ESRI's ArcGIS JavaScript API that I think needs to be looked at.


    In the API  you can have a single map instance utilized by several Views. This is great. In apps I've worked on we often have a 2d MapView and a 3D SceneView sharing a Map instance and running simultaneously in the browser. 


    A 2D MapView does not support 3D Layer types like ElevationLayer, BuildingSceneLayer, or whatnot. And the 3D SceneView doesn't support some other layer types like KmlLayer. Fine, makes sense. But, the problem is that instead of a 2D View recognizing standard 3D layer types and ignoring them (perhaps with a graceful warning in the browser console), it tries to add them to the view and fails, throwing errors like below:

    MapView error on ElevationLayer

    Above example is with an ElevationLayer in a MapView. I haven't tested but assume simular behaviour w. incompatible layer types. (tested at  4.15)


    This clutters our logs, confuses users, and suggests that the JavaScript API could be wasting resources trying to create a layerView when it cannot. We should be able to expect if we're using an ESRI defined layer type that is not compatible with the View type that the API will handle it gracefully and not throw errors.