lib/stylegen.js
function generateInspectStyle(originalMapStyle, coloredLayers, opts) {
  opts = Object.assign({
    backgroundColor: '#fff'
  }, opts);

  var backgroundLayer = {
    'id': 'background',
    'type': 'background',
    'paint': {
      'background-color': opts.backgroundColor
    }
  };

  var sources = {};
  Object.keys(originalMapStyle.sources).forEach(function (sourceId) {
    var source = originalMapStyle.sources[sourceId];
    if (source.type === 'vector' || source.type === 'geojson') {
      sources[sourceId] = source;
    }
  });

  return Object.assign(originalMapStyle, {
    layers: [backgroundLayer].concat(coloredLayers),
    soources: sources
  });
}
function generateInspectStyle(originalMapStyle, coloredLayers, opts) {
  opts = Object.assign({
    backgroundColor: '#fff'
  }, opts);

  var backgroundLayer = {
    'id': 'background',
    'type': 'background',
    'paint': {
      'background-color': opts.backgroundColor
    }
  };

  var sources = {};
  Object.keys(originalMapStyle.sources).forEach(function (sourceId) {
    var source = originalMapStyle.sources[sourceId];
    if (source.type === 'vector' || source.type === 'geojson') {
      sources[sourceId] = source;
    }
  });

  return Object.assign(originalMapStyle, {
    layers: [backgroundLayer].concat(coloredLayers),
    soources: sources
  });
}
function generateInspectStyle ( originalMapStyle , coloredLayers , opts ) { opts = Object . assign ( { backgroundColor : '#fff' } , opts ) ; var backgroundLayer = { 'id' : 'background' , 'type' : 'background' , 'paint' : { 'background-color' : opts . backgroundColor } } ; var sources = { } ; Object . keys ( originalMapStyle . sources ) . forEach ( function ( sourceId ) { var source = originalMapStyle . sources [ sourceId ] ; if ( source . type === 'vector' || source . type === 'geojson' ) { sources [ sourceId ] = source ; } } ) ; return Object . assign ( originalMapStyle , { layers : [ backgroundLayer ] . concat ( coloredLayers ) , soources : sources } ) ; }
Create inspection style out of the original style and the new colored layers
@param {Object} Original map styles
@param {array} Array of colored Mapbox GL layers
@return {Object} Colored inspect style
Create inspection style out of the original style and the new colored layers