Fit the extent on the map. Can be used to zoom to a layer for instance.
@param {Object} state Current state.
@param {Object} action Action to handle.

@returns {Object} The new state.
function fitExtent(state, action) {
  const extent = action.extent;
  const resolution = getResolutionForExtent(extent, action.size, action.projection);
  const zoom = getZoomForResolution(resolution, action.projection);
  const center = [(extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2];
  return Object.assign({}, state, {center, zoom});
}