src/reducers/vis-state-updaters.js
function addNewLayersToSplitMap(splitMaps, layers) {
  const newLayers = Array.isArray(layers) ? layers : [layers];

  if (!splitMaps || !splitMaps.length || !newLayers.length) {
    return splitMaps;
  }

  // add new layer to both maps,
  //  don't override, if layer.id is already in splitMaps.settings.layers
  return splitMaps.map(settings => ({
    ...settings,
    layers: {
      ...settings.layers,
      ...newLayers.reduce(
        (accu, newLayer) =>
          newLayer.config.isVisible
            ? {
                ...accu,
                [newLayer.id]: settings.layers[newLayer.id]
                  ? settings.layers[newLayer.id]
                  : generateLayerMetaForSplitViews(newLayer)
              }
            : accu,
        {}
      )
    }
  }));
}
function addNewLayersToSplitMap(splitMaps, layers) {
  const newLayers = Array.isArray(layers) ? layers : [layers];

  if (!splitMaps || !splitMaps.length || !newLayers.length) {
    return splitMaps;
  }

  // add new layer to both maps,
  //  don't override, if layer.id is already in splitMaps.settings.layers
  return splitMaps.map(settings => ({
    ...settings,
    layers: {
      ...settings.layers,
      ...newLayers.reduce(
        (accu, newLayer) =>
          newLayer.config.isVisible
            ? {
                ...accu,
                [newLayer.id]: settings.layers[newLayer.id]
                  ? settings.layers[newLayer.id]
                  : generateLayerMetaForSplitViews(newLayer)
              }
            : accu,
        {}
      )
    }
  }));
}
function addNewLayersToSplitMap ( splitMaps , layers ) { const newLayers = Array . isArray ( layers ) ? layers : [ layers ] ; if ( ! splitMaps || ! splitMaps . length || ! newLayers . length ) { return splitMaps ; } // add new layer to both maps, //  don't override, if layer.id is already in splitMaps.settings.layers return splitMaps . map ( settings => ( { ... settings , layers : { ... settings . layers , ... newLayers . reduce ( ( accu , newLayer ) => newLayer . config . isVisible ? { ... accu , [ newLayer . id ] : settings . layers [ newLayer . id ] ? settings . layers [ newLayer . id ] : generateLayerMetaForSplitViews ( newLayer ) } : accu , { } ) } } ) ) ; }
Add new layers to both existing maps
@param {Object} splitMaps
@param {Object|Array<Object>} layers
@returns {Array<Object>} new splitMaps
Add new layers to both existing maps