src/setup.js
function() {
      ctx.options.styles.forEach(style => {
        if (ctx.map.getLayer(style.id)) {
          ctx.map.removeLayer(style.id);
        }
      });

      if (ctx.map.getSource(Constants.sources.COLD)) {
        ctx.map.removeSource(Constants.sources.COLD);
      }

      if (ctx.map.getSource(Constants.sources.HOT)) {
        ctx.map.removeSource(Constants.sources.HOT);
      }
    }
function() {
      ctx.options.styles.forEach(style => {
        if (ctx.map.getLayer(style.id)) {
          ctx.map.removeLayer(style.id);
        }
      });

      if (ctx.map.getSource(Constants.sources.COLD)) {
        ctx.map.removeSource(Constants.sources.COLD);
      }

      if (ctx.map.getSource(Constants.sources.HOT)) {
        ctx.map.removeSource(Constants.sources.HOT);
      }
    }
function ( ) { ctx . options . styles . forEach ( style => { if ( ctx . map . getLayer ( style . id ) ) { ctx . map . removeLayer ( style . id ) ; } } ) ; if ( ctx . map . getSource ( Constants . sources . COLD ) ) { ctx . map . removeSource ( Constants . sources . COLD ) ; } if ( ctx . map . getSource ( Constants . sources . HOT ) ) { ctx . map . removeSource ( Constants . sources . HOT ) ; } }
Check for layers and sources before attempting to remove If user adds draw control and removes it before the map is loaded, layers and sources will be missing
Check for layers and sources before attempting to remove If user adds draw control and removes it before the map is loaded layers and sources will be missing