Raster, GeoTIFF and WebGL · Angular, React and OpenLayers
Retina image tiles on a logical XYZ grid
Render 512-pixel @2x Retina WebP satellite tiles on a standard 256-pixel logical XYZ grid over Kraków using OpenLayers ImageTile and WebGL.

What this example shows
Centred on Rynek Główny in Kraków across zooms 11 through 13, crisp 512 × 512 pixel @2x WebP Sentinel-2 satellite tiles render on a standard 256-pixel logical XYZ map grid through OpenLayers’ ImageTile and WebGL adapters while preserving Copernicus attribution.
When you need it
High-DPI tile endpoints (@2x WebP/PNG pyramids) pack four times as many image pixels into each standard {z}/{x}/{y} geographic square so fine urban textures stay sharp on Retina phones and 4K monitors.
Keeping the logical XYZ grid at 256 CSS pixels ensures tile coordinates and geographic bounds stay 100% aligned with standard vector and raster overlays.
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.
xyz-retina.shared.tsimport type { Extent } from 'ol/extent';
import type { DefaultsOptions } from 'ol/control/defaults';
import coverage from '../../../assets/krakow/retina-tiles/coverage.json';
export const XYZ_RETINA_URL = 'assets/krakow/retina-tiles/{z}/{x}/{y}@2x.webp';
export const RETINA_TILE_SIZE = coverage.tileSize;
export const RETINA_ATTRIBUTION_OPTIONS: DefaultsOptions['attributionOptions'] = { collapsible: false };
export const RETINA_MIN_ZOOM = coverage.zoomLevels[0];
export const RETINA_MAX_ZOOM = coverage.zoomLevels[coverage.zoomLevels.length - 1];
export const RETINA_EXTENT = coverage.extent as Extent;
export const RETINA_ATTRIBUTIONS = [
'Contains modified Copernicus Sentinel data 2024. ' +
'<a href="https://cds.climate.copernicus.eu/licences/ec-sentinel" target="_blank" rel="noreferrer">' +
'Copernicus Sentinel notice</a>; ' +
'<a href="https://dataspace.copernicus.eu/terms-and-conditions" target="_blank" rel="noreferrer">' +
'Copernicus Data Space terms</a>',
];xyz-retina.tsimport { ChangeDetectionStrategy, Component } from '@angular/core';
import {
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
MapComponent,
SourceImageTileComponent,
ViewComponent,
} from 'cc-openlayers';
import { LayerWebGLTileComponent } from 'cc-openlayers/webgl';
import {
RETINA_ATTRIBUTIONS,
RETINA_ATTRIBUTION_OPTIONS,
RETINA_EXTENT,
RETINA_MAX_ZOOM,
RETINA_MIN_ZOOM,
RETINA_TILE_SIZE,
XYZ_RETINA_URL,
} from './xyz-retina.shared';
/** Displays the local Kraków crop from 512 px WebP tiles on OpenLayers' 256 px tile grid. */
@Component({
selector: 'app-xyz-retina',
imports: [
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerWebGLTileComponent,
MapComponent,
SourceImageTileComponent,
ViewComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<aol-map height="480px" ariaLabel="Kraków Sentinel XYZ density example">
<aol-interaction-default />
<aol-control-defaults [attributionOptions]="attributionOptions" />
<aol-view [extent]="extent" [constrainOnlyCenter]="true" [minZoom]="minZoom" [maxZoom]="maxZoom" [zoom]="12">
<aol-coordinate [x]="19.9368" [y]="50.0614" srid="EPSG:4326" />
</aol-view>
<aol-layer-webgltile [extent]="extent">
<aol-source-imagetile
[url]="url"
[tileSize]="tileSize"
[minZoom]="minZoom"
[maxZoom]="maxZoom"
projection="EPSG:3857"
[wrapX]="false"
[attributions]="attributions"
/>
</aol-layer-webgltile>
</aol-map>
`,
})
export class XyzRetina {
protected readonly attributions = RETINA_ATTRIBUTIONS;
protected readonly attributionOptions = RETINA_ATTRIBUTION_OPTIONS;
protected readonly extent = RETINA_EXTENT;
protected readonly minZoom = RETINA_MIN_ZOOM;
protected readonly maxZoom = RETINA_MAX_ZOOM;
protected readonly tileSize = RETINA_TILE_SIZE;
protected readonly url = XYZ_RETINA_URL;
} The React version uses the library's React adapter, cc-openlayers/react: each component creates the OpenLayers object it names when it mounts, updates it from its props and disposes of it when it unmounts.
xyz-retina.react.tsximport { Coordinate, DefaultControls, DefaultInteractions, ImageTileSource, Map, View } from 'cc-openlayers/react';
import { WebGLTileLayer } from 'cc-openlayers/react/webgl';
import {
RETINA_ATTRIBUTIONS,
RETINA_ATTRIBUTION_OPTIONS,
RETINA_EXTENT,
RETINA_MAX_ZOOM,
RETINA_MIN_ZOOM,
RETINA_TILE_SIZE,
XYZ_RETINA_URL,
} from './xyz-retina.shared';
/** Displays the local Kraków crop from 512 px WebP tiles on OpenLayers' 256 px tile grid. */
export function XyzRetinaReact() {
return (
<Map height="480px" ariaLabel="Kraków Sentinel XYZ density example">
<DefaultInteractions />
<DefaultControls attributionOptions={RETINA_ATTRIBUTION_OPTIONS} />
<View extent={RETINA_EXTENT} constrainOnlyCenter minZoom={RETINA_MIN_ZOOM} maxZoom={RETINA_MAX_ZOOM} zoom={12}>
<Coordinate x={19.9368} y={50.0614} srid="EPSG:4326" />
</View>
<WebGLTileLayer extent={RETINA_EXTENT}>
<ImageTileSource
url={XYZ_RETINA_URL}
tileSize={RETINA_TILE_SIZE}
minZoom={RETINA_MIN_ZOOM}
maxZoom={RETINA_MAX_ZOOM}
projection="EPSG:3857"
wrapX={false}
attributions={RETINA_ATTRIBUTIONS}
/>
</WebGLTileLayer>
</Map>
);
}xyz-retina.shared.tsimport type { Extent } from 'ol/extent';
import type { DefaultsOptions } from 'ol/control/defaults';
import coverage from '../../../assets/krakow/retina-tiles/coverage.json';
export const XYZ_RETINA_URL = 'assets/krakow/retina-tiles/{z}/{x}/{y}@2x.webp';
export const RETINA_TILE_SIZE = coverage.tileSize;
export const RETINA_ATTRIBUTION_OPTIONS: DefaultsOptions['attributionOptions'] = { collapsible: false };
export const RETINA_MIN_ZOOM = coverage.zoomLevels[0];
export const RETINA_MAX_ZOOM = coverage.zoomLevels[coverage.zoomLevels.length - 1];
export const RETINA_EXTENT = coverage.extent as Extent;
export const RETINA_ATTRIBUTIONS = [
'Contains modified Copernicus Sentinel data 2024. ' +
'<a href="https://cds.climate.copernicus.eu/licences/ec-sentinel" target="_blank" rel="noreferrer">' +
'Copernicus Sentinel notice</a>; ' +
'<a href="https://dataspace.copernicus.eu/terms-and-conditions" target="_blank" rel="noreferrer">' +
'Copernicus Data Space terms</a>',
];How the React version works
Local Kraków satellite tiles return 512×512 image pixels for a 256×256 logical XYZ tile. The same projected cell keeps its geographic footprint; a denser payload does not change the map grid or imply finer satellite ground detail.
What both versions share
The pair composes the existing ImageTile source and WebGL tile layer, matching the original OpenLayers example. Its @2x.webp URL selects the high-density files. It does not set tilePixelRatio or choose a source according to DPR; that separate behavior belongs to wmts-hidpi. The lossless WebP tiles are sampled directly from the accepted 10 m Sentinel crop. Generated coverage.json owns the finite EPSG:3857 extent and zoom levels. The source and layer restrict requests to the local fixture. Center constraints must not prevent the viewport reaching zoom 11; constrainOnlyCenter keeps the center inside the crop while allowing blank space around the finite image.
From Angular to React
| Angular | React |
|---|---|
<aol-source-imagetile> | <ImageTileSource> |
<aol-layer-webgltile> | <WebGLTileLayer> |
| The view receives generated extent/zoom bounds | The view receives the same generated extent/zoom bounds |
| Default controls keep attribution expanded | Default controls keep the same attribution expanded |
Who creates, updates and disposes
The existing adapters own the map, layer and image-tile source lifecycle. The example owns only fixture configuration; it does not implement a second tile loader or rendering layer. A named map and the expanded actual-source credit remain part of the rendered example.
Architecture and OpenLayers mechanics
Local same-origin XYZ URLs point directly at 512 × 512 @2x WebP crops sampled from a 10 m Copernicus Sentinel-2 scene over Kraków, while the source’s logical tile grid remains the standard 256-pixel Web Mercator pyramid—matching upstream OpenLayers’ ImageTile Retina pattern without altering geographic cell footprints.
How it works
- Same-origin
@2xWebP tile files supply 512 × 512 image pixels per standard 256-pixel logical XYZ cell. - Following the upstream ImageTile pattern, the source keeps the default 256-pixel logical grid without switching URLs by device DPR.
- A bounded local Sentinel-2 fixture over Kraków (zooms 11–13) provides self-contained high-density imagery with visible Copernicus attribution.
- Tiles stay crisp to about zoom 12 (~12 m/px); at zoom 13 the 2x tiles interpolate the 10 m source, so no sub-sensor detail appears.
Pitfalls
- Do not change the logical
tileSizeto512when a server returns@2xtiles for standard 256-pixel XYZ coordinates—doubling logical grid size shifts zoom levels and misplaces every tile. - Upscaling a blurry 256 px tile to 512 px wastes bandwidth; true
@2xtiles must be rendered or sampled from higher-resolution source data. - Keep view zoom and extent aligned with bounded local tile fixtures so out-of-coverage cells are not requested.
Related examples
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.