Essentials · Angular, React and OpenLayers

Zoom limits on a satellite map

Restrict OpenLayers camera zoom between minZoom and maxZoom over Esri World Imagery using an ArcGIS {z}/{y}/{x} image tile source and attributions.

Satellite imagery of Kraków and its surroundings at zoom 11, with the Vistula crossing the city.
A screenshot of the example. Imagery: Esri World Imagery (Esri, Maxar, Earthstar Geographics and the GIS User Community).

What this example shows

Esri World Imagery opens over Kraków and the Vistula river bend at zoom 11 and restricts camera scale strictly to levels 9 through 13. Mouse-wheel scrolling, pinch gestures, keyboard shortcuts and zoom buttons all stop cleanly at the regional overview (zoom 9) and neighbourhood aerial view (zoom 13), with required provider credits shown in the corner.

When you need it

Satellite orthophotos, specialized thematic rasters and commercial tile feeds are frequently licensed, cached or visually meaningful only across a bounded range of map scales.

Blocking zoom-out past regional coverage saves tile quota on irrelevant territory, while capping zoom-in prevents missing-tile 404 errors or pixelated overscaling beyond native sensor resolution.

The code

The example uses cc-openlayers, my Angular component library for OpenLayers: each aol-… element creates the OpenLayers object it names, updates it from its inputs and disposes of it with the component.

zoom-constrained.ts
import { ChangeDetectionStrategy, Component } from '@angular/core';
import {
  CoordinateComponent,
  DefaultControlComponent,
  DefaultInteractionComponent,
  LayerTileComponent,
  MapComponent,
  SourceImageTileComponent,
  ViewComponent,
} from 'cc-openlayers';

/** Esri's World Imagery over Kraków in a view that zooms only between levels 9 and 13. */
@Component({
  selector: 'app-zoom-constrained',
  imports: [
    CoordinateComponent,
    DefaultControlComponent,
    DefaultInteractionComponent,
    LayerTileComponent,
    MapComponent,
    SourceImageTileComponent,
    ViewComponent,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <aol-map height="480px">
      <aol-interaction-default />
      <aol-control-defaults />
      <aol-view [zoom]="11" [minZoom]="9" [maxZoom]="13">
        <aol-coordinate [x]="19.9368" [y]="50.0614" srid="EPSG:4326" />
      </aol-view>
      <aol-layer-tile>
        <aol-source-imagetile
          url="https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
          attributions="Tiles © Esri — Source: Esri, Maxar, Earthstar Geographics, and the GIS User Community"
        />
      </aol-layer-tile>
    </aol-map>
  `,
})
export class ZoomConstrained {}

Architecture and OpenLayers mechanics

OpenLayers separates view scale constraints from layer visibility ranges. Declaring [minZoom]="9" and [maxZoom]="13" on the view clamps camera resolution across every gesture and control, whereas setting minZoom and maxZoom on a layer leaves the camera unconstrained and simply hides that layer outside the interval.

aol-source-imagetile connects directly to Esri’s REST cache using ArcGIS’s row-first URL template ({z}/{y}/{x}) alongside explicit attributions metadata.

How it works

  • [minZoom]="9" and [maxZoom]="13" on the view stop mouse wheel, pinch, keyboard and button zooming at the configured scale bounds.
  • aol-source-imagetile requests Esri World Imagery tiles using ArcGIS’s {z}/{y}/{x} template, where tile row {y} precedes column {x}.
  • attributions supplies mandatory Esri and imagery-partner credits to the default attribution control.
  • Starting the camera at zoom 11 places the initial viewport right in the middle of the allowed five-level range.

Pitfalls

  • Swapping {x} and {y} in an ArcGIS REST URL loads valid tiles from completely wrong locations on Earth without throwing network errors—always verify whether a service expects XYZ or ZYX order.
  • Setting minZoom and maxZoom on the layer instead of the view hides the imagery outside levels 9–13 rather than stopping the user from zooming further.
  • Programmatic fit() calls also obey view maxZoom and minZoom ceilings, so small geometries will stop at zoom 13.

The same feature in the OpenLayers examples .

Background: state and lifecycle of maps in Angular with OpenLayers, which the components of cc-openlayers take care of.