chosenLayer3D id added for fixing mapbox bug. probably causing the crash on the 3D toggle
A extra layer with the id 'chosenLayer3D' is added for fixing a mapbox bug See Mapbox issue: https://github.com/mapbox/mapbox-gl-js/issues/9731 Since this is not fixed (yet) a workaround is adding the Fill extrusion layer with a different layer ID. Implemented now.
This fixes probable problems with the 3D toggle. Switching from fill to fill-extrusion.
Also added extra check on updating paint properties on the active layer. (fill or fill-extrusion)
Why it crashed on tab switch I am not sure. This makes the 3D toggle overall better and hopefully fixes these problems in the overall flow.