code: private double checkResolution(double resolution, ZoomOption zoomOption) {
  		double allowedResolution = resolution;
  		double maximumResolution = getMaximumResolution();
  		double minimumResolution = getMinimumResolution();
  		if (allowedResolution > maximumResolution) {
  			allowedResolution = maximumResolution;
  		} else if (allowedResolution < minimumResolution) {
  			allowedResolution = minimumResolution;
  		}
  
  		if (zoomOption == ZoomOption.FREE) {
  			return allowedResolution;
  		}
  
  		for (int i = 0; i < resolutions.size() - 1; i++) {
  			double upper = resolutions.get(i);
  			double lower = resolutions.get(i + 1);
  
  			if (allowedResolution == upper) {
  				return upper;
  			} else if (allowedResolution == lower) {
  				return lower;
  			} else if (allowedResolution < upper && allowedResolution > lower) {
  				switch (zoomOption) {
  					case LEVEL_FIT:
  						return upper;
  					case LEVEL_CLOSEST:
  						if (Math.abs(upper - allowedResolution) < Math.abs(allowedResolution - lower)) {
  							return upper;
  						} else {
  							return lower;
  						}
  					default:
  						return allowedResolution;
  				}
  			}
  		}
  		return allowedResolution;
  	}
docs: Returns a resolution as requested by the zoom option: