What unit is Zoom in OpenLayer3?

What unit is Zoom in OpenLayer3?

I need to know the type of unit that Zoom, or maxZoom/minZoom has. I've been finding in OpenLayers API but without success.

Do you have any idea?

Short answer: The zoom ofol.Viewis not in any unit, it is just an incrementing integer id for a given resolution.

Longer answer:

Zooming in OpenLayers 3 is entirely based on resolution. The resolution is the number of map units per pixel and can vary continuously between theminResolutionandmaxResolution. The resolution is however constrained to a set of resolutions, which the map will snap to after zoom interactions.

The zoom index/number is nothing more than an enumeration of these resolutions, where0is the highest resolution,1is the second and so on. So when you doview.setZoom(6), all you're doing is setting the resolution to the seventh constraint resolution.

So what are those resolutions? It all depends on your configuration:

  • If using theresolutionoption, it's value is the constraint resolutions
  • Otherwise, the resolutions will be calculated from themaxResolutionandzoomFactor:
    • ThezoomFactordefaults to2, but is configurable
    • ThemaxResolutionis calculated as the resolution for fitting the projection's extent in 256*256 pixels, if not explicitly provided
    • The resolution for a given zoom level when calculated this way will bemaxResolution / Math.pow(zoomFactor, zoomLevel)
    • TheminZoomandmaxZoomoptions will limit which of these resolutions that will be usable.maxZoomwill determine how many such resolutions are calculated, ifmaxZoomis 20 then there will be 21 resolutions. But ifminZoomis more than 0 the firstminZoomof those resolutions will be ignored.

Watch the video: QGIS Tutorial 112: OpenLayers Plugin, Navigation, Web layers