getConstrainedZoom(targetZoom, direction) {
    const targetRes = this.getResolutionForZoom(targetZoom);
    return this.getZoomForResolution(
      this.getConstrainedResolution(targetRes, direction),
    );
  }
Get a valid zoom level according to the current view constraints.
@param {number|undefined} targetZoom Target zoom.
@param {number} [direction] Indicate which resolution should be used
by a renderer if the view resolution does not match any resolution of the tile source.
If 0, the nearest resolution will be used. If 1, the nearest lower resolution
will be used. If -1, the nearest higher resolution will be used.
@return {number|undefined} Valid zoom level.