src/reducers/map.js
function clusterPoints(state, action) {
  const source = state.sources[action.sourceName];
  if (!source) {
    return state;
  }
  const src_mixin = [];
  const cluster_settings = {};

  if (typeof action.cluster !== 'undefined') {
    cluster_settings.cluster = action.cluster;
    // Mapbox GL style spec defaults to 50,
    //  whereas OpenLayers defaults to 20px.
    cluster_settings.clusterRadius = source.clusterRadius ? source.clusterRadius : 50;
  }

  // The radius can be overridden at any time.
  if (typeof action.radius !== 'undefined') {
    cluster_settings.clusterRadius = action.radius;
  }
  src_mixin[action.sourceName] = Object.assign({}, source, cluster_settings);

  const newState = Object.assign({}, state, {
    sources: Object.assign({}, state.sources, src_mixin),
  }, incrementVersion(state.metadata, SOURCE_VERSION_KEY));
  return newState;
}
function clusterPoints(state, action) {
  const source = state.sources[action.sourceName];
  if (!source) {
    return state;
  }
  const src_mixin = [];
  const cluster_settings = {};

  if (typeof action.cluster !== 'undefined') {
    cluster_settings.cluster = action.cluster;
    // Mapbox GL style spec defaults to 50,
    //  whereas OpenLayers defaults to 20px.
    cluster_settings.clusterRadius = source.clusterRadius ? source.clusterRadius : 50;
  }

  // The radius can be overridden at any time.
  if (typeof action.radius !== 'undefined') {
    cluster_settings.clusterRadius = action.radius;
  }
  src_mixin[action.sourceName] = Object.assign({}, source, cluster_settings);

  const newState = Object.assign({}, state, {
    sources: Object.assign({}, state.sources, src_mixin),
  }, incrementVersion(state.metadata, SOURCE_VERSION_KEY));
  return newState;
}
function clusterPoints ( state , action ) { const source = state . sources [ action . sourceName ] ; if ( ! source ) { return state ; } const src_mixin = [ ] ; const cluster_settings = { } ; if ( typeof action . cluster !== 'undefined' ) { cluster_settings . cluster = action . cluster ; // Mapbox GL style spec defaults to 50, //  whereas OpenLayers defaults to 20px. cluster_settings . clusterRadius = source . clusterRadius ? source . clusterRadius : 50 ; } // The radius can be overridden at any time. if ( typeof action . radius !== 'undefined' ) { cluster_settings . clusterRadius = action . radius ; } src_mixin [ action . sourceName ] = Object . assign ( { } , source , cluster_settings ) ; const newState = Object . assign ( { } , state , { sources : Object . assign ( { } , state . sources , src_mixin ) , } , incrementVersion ( state . metadata , SOURCE_VERSION_KEY ) ) ; return newState ; }
Cluster points.
@param {Object} state Current state.
@param {Object} action Action to handle.

@returns {Object} The new state.
Cluster points . @param { Object } state Current state . @param { Object } action Action to handle .