_setDiffStyle(prevStyle, nextStyle) {
    const prevKeysMap = prevStyle && styleKeysMap(prevStyle) || {};
    const nextKeysMap = styleKeysMap(nextStyle);
    function styleKeysMap(style) {
      return style.map(() => true).delete('layers').delete('sources').toJS();
    }
    function propsOtherThanLayersOrSourcesDiffer() {
      const prevKeysList = Object.keys(prevKeysMap);
      const nextKeysList = Object.keys(nextKeysMap);
      if (prevKeysList.length !== nextKeysList.length) {
        return true;
      }
      // `nextStyle` and `prevStyle` should not have the same set of props.
      if (nextKeysList.some(
        key => prevStyle.get(key) !== nextStyle.get(key)
        // But the value of one of those props is different.
      )) {
        return true;
      }
      return false;
    }

    const map = this._map;

    if (!prevStyle || propsOtherThanLayersOrSourcesDiffer()) {
      map.setStyle(nextStyle.toJS());
      return;
    }

    const {sourcesDiff, layersDiff} = diffStyles(prevStyle, nextStyle);

    // TODO: It's rather difficult to determine style diffing in the presence
    // of refs. For now, if any style update has a ref, fallback to no diffing.
    // We can come back to this case if there's a solid usecase.
    if (layersDiff.updates.some(node => node.layer.get('ref'))) {
      map.setStyle(nextStyle.toJS());
      return;
    }

    for (const enter of sourcesDiff.enter) {
      map.addSource(enter.id, enter.source.toJS());
    }
    for (const update of sourcesDiff.update) {
      this._updateSource(map, update);
    }
    for (const exit of sourcesDiff.exit) {
      map.removeSource(exit.id);
    }
    for (const exit of layersDiff.exiting) {
      if (map.style.getLayer(exit.id)) {
        map.removeLayer(exit.id);
      }
    }
    for (const update of layersDiff.updates) {
      if (!update.enter) {
        // This is an old layer that needs to be updated. Remove the old layer
        // with the same id and add it back again.
        map.removeLayer(update.id);
      }
      map.addLayer(update.layer.toJS(), update.before);
    }
  }
/* eslint-disable max-statements, complexity */
eslint-disable max-statements, complexity
eslint - disable max - statements complexity
_setDiffStyle(prevStyle, nextStyle) {
    const prevKeysMap = prevStyle && styleKeysMap(prevStyle) || {};
    const nextKeysMap = styleKeysMap(nextStyle);
    function styleKeysMap(style) {
      return style.map(() => true).delete('layers').delete('sources').toJS();
    }
    function propsOtherThanLayersOrSourcesDiffer() {
      const prevKeysList = Object.keys(prevKeysMap);
      const nextKeysList = Object.keys(nextKeysMap);
      if (prevKeysList.length !== nextKeysList.length) {
        return true;
      }
      if (nextKeysList.some(
        key => prevStyle.get(key) !== nextStyle.get(key)
      )) {
        return true;
      }
      return false;
    }
    const map = this._map;
    if (!prevStyle || propsOtherThanLayersOrSourcesDiffer()) {
      map.setStyle(nextStyle.toJS());
      return;
    }
    const {sourcesDiff, layersDiff} = diffStyles(prevStyle, nextStyle);
    if (layersDiff.updates.some(node => node.layer.get('ref'))) {
      map.setStyle(nextStyle.toJS());
      return;
    }
    for (const enter of sourcesDiff.enter) {
      map.addSource(enter.id, enter.source.toJS());
    }
    for (const update of sourcesDiff.update) {
      this._updateSource(map, update);
    }
    for (const exit of sourcesDiff.exit) {
      map.removeSource(exit.id);
    }
    for (const exit of layersDiff.exiting) {
      if (map.style.getLayer(exit.id)) {
        map.removeLayer(exit.id);
      }
    }
    for (const update of layersDiff.updates) {
      if (!update.enter) {
        map.removeLayer(update.id);
      }
      map.addLayer(update.layer.toJS(), update.before);
    }
  }
_setDiffStyle ( prevStyle , nextStyle ) { const prevKeysMap = prevStyle && styleKeysMap ( prevStyle ) || { } ; const nextKeysMap = styleKeysMap ( nextStyle ) ; function styleKeysMap ( style ) { return style . map ( ( ) => true ) . delete ( 'layers' ) . delete ( 'sources' ) . toJS ( ) ; } function propsOtherThanLayersOrSourcesDiffer ( ) { const prevKeysList = Object . keys ( prevKeysMap ) ; const nextKeysList = Object . keys ( nextKeysMap ) ; if ( prevKeysList . length !== nextKeysList . length ) { return true ; } if ( nextKeysList . some ( key => prevStyle . get ( key ) !== nextStyle . get ( key ) ) ) { return true ; } return false ; } const map = this . _map ; if ( ! prevStyle || propsOtherThanLayersOrSourcesDiffer ( ) ) { map . setStyle ( nextStyle . toJS ( ) ) ; return ; } const { sourcesDiff , layersDiff } = diffStyles ( prevStyle , nextStyle ) ; if ( layersDiff . updates . some ( node => node . layer . get ( 'ref' ) ) ) { map . setStyle ( nextStyle . toJS ( ) ) ; return ; } for ( const enter of sourcesDiff . enter ) { map . addSource ( enter . id , enter . source . toJS ( ) ) ; } for ( const update of sourcesDiff . update ) { this . _updateSource ( map , update ) ; } for ( const exit of sourcesDiff . exit ) { map . removeSource ( exit . id ) ; } for ( const exit of layersDiff . exiting ) { if ( map . style . getLayer ( exit . id ) ) { map . removeLayer ( exit . id ) ; } } for ( const update of layersDiff . updates ) { if ( ! update . enter ) { map . removeLayer ( update . id ) ; } map . addLayer ( update . layer . toJS ( ) , update . before ) ; } }
eslint-disable max-statements, complexity
eslint - disable max - statements complexity
// `nextStyle` and `prevStyle` should not have the same set of props. // But the value of one of those props is different. // TODO: It's rather difficult to determine style diffing in the presence // of refs. For now, if any style update has a ref, fallback to no diffing. // We can come back to this case if there's a solid usecase. // This is an old layer that needs to be updated. Remove the old layer // with the same id and add it back again.