Tile and image services · Angular, React and OpenLayers
A WMTS layer's time dimension
Browse daily NASA MODIS Terra satellite imagery over Poland in OpenLayers by binding a date slider to a REST WMTS Time dimension parameter.

What this example shows
Across Poland and Central Europe at zoom 6, NASA’s daily true-colour MODIS Terra satellite composite from August 2025 renders over OpenStreetMap—opening on 1 August 2025, while the captured screenshot shows the nearly cloudless 14 August 2025 pass over Poland with Alpine cloud systems swirling to the south.
Dragging the date slider below the viewport steps day by day through August 2025, cross-fading each new satellite overpass smoothly over the previous day’s imagery.
When you need it
Earth-observation archives (NASA GIBS, Copernicus Marine/Atmosphere), meteorological ensembles and 4D ocean models publish multi-year daily rasters as a single WMTS layer parameterised by a Time or Elevation dimension.
Binding reactive UI state to WMTS dimensions lets users scrub through historical floods, wildfires, snow cover or crop growth without creating separate layers per date.
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.
wmts-dimensions.tsimport { ChangeDetectionStrategy, Component, computed, signal } from '@angular/core';
import {
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerTileComponent,
MapComponent,
SourceOsmComponent,
SourceTileWMTSComponent,
ViewComponent,
} from 'cc-openlayers';
import { getTopLeft, getWidth } from 'ol/extent';
import { get as getProjection } from 'ol/proj';
import WMTSTileGrid from 'ol/tilegrid/WMTS';
const AUGUST_2025 = Date.UTC(2025, 7, 1);
const DAY = 24 * 60 * 60 * 1000;
/** GIBS's GoogleMapsCompatible_Level9 matrix set: the Spherical Mercator grid of 256-pixel tiles, levels 0 to 9. */
function level9Grid(): WMTSTileGrid {
const extent = getProjection('EPSG:3857')?.getExtent() ?? [];
const levels = [...Array(10).keys()];
return new WMTSTileGrid({
origin: getTopLeft(extent),
resolutions: levels.map((level) => getWidth(extent) / 256 / 2 ** level),
matrixIds: levels.map(String),
});
}
/**
* A WMTS dimension changed continuously: the slider picks a day of August 2025, and the same source asks NASA GIBS
* for that day's true-colour image from MODIS Terra, whose tiles fade in over the last day's.
*/
@Component({
selector: 'app-wmts-dimensions',
imports: [
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerTileComponent,
MapComponent,
SourceOsmComponent,
SourceTileWMTSComponent,
ViewComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<aol-map height="480px">
<aol-interaction-default />
<aol-control-defaults />
<aol-view [zoom]="6">
<aol-coordinate [x]="19.9373" [y]="50.0617" srid="EPSG:4326" />
</aol-view>
<aol-layer-tile><aol-source-osm /></aol-layer-tile>
<aol-layer-tile [opacity]="0.8">
<aol-source-tilewmts
url="https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/MODIS_Terra_CorrectedReflectance_TrueColor/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpeg"
layer="MODIS_Terra_CorrectedReflectance_TrueColor"
matrixSet="GoogleMapsCompatible_Level9"
format="image/jpeg"
requestEncoding="REST"
[style]="'default'"
[tileGrid]="tileGrid"
[dimensions]="{ Time: date() }"
attributions="Imagery: NASA GIBS, MODIS Terra"
/>
</aol-layer-tile>
</aol-map>
<div class="example-controls">
<label>
Day
<input id="slider" type="range" min="0" max="30" [value]="day()" (input)="slide($event)" />
</label>
<span id="theinfo">{{ date() }}</span>
</div>
`,
})
export class WmtsDimensions {
readonly day = signal(0);
protected readonly date = computed(() => new Date(AUGUST_2025 + this.day() * DAY).toISOString().slice(0, 10));
protected readonly tileGrid = level9Grid();
protected slide(event: Event): void {
this.day.set(Number((event.target as HTMLInputElement).value));
}
} 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.
wmts-dimensions.react.tsximport { useState, type ChangeEvent } from 'react';
import { getTopLeft, getWidth } from 'ol/extent.js';
import { get as getProjection } from 'ol/proj.js';
import WMTSTileGrid from 'ol/tilegrid/WMTS.js';
import {
Coordinate,
DefaultControls,
DefaultInteractions,
Map,
OSMSource,
TileLayer,
View,
WMTSSource,
} from 'cc-openlayers/react';
const AUGUST_2025 = Date.UTC(2025, 7, 1);
const DAY = 24 * 60 * 60 * 1000;
/** GIBS's GoogleMapsCompatible_Level9 matrix set: the Spherical Mercator grid of 256-pixel tiles, levels 0 to 9. */
function level9Grid(): WMTSTileGrid {
const extent = getProjection('EPSG:3857')?.getExtent() ?? [];
const levels = [...Array(10).keys()];
return new WMTSTileGrid({
origin: getTopLeft(extent),
resolutions: levels.map((level) => getWidth(extent) / 256 / 2 ** level),
matrixIds: levels.map(String),
});
}
/**
* A WMTS dimension changed continuously: the slider picks a day of August 2025, and the same source asks NASA GIBS
* for that day's true-colour image from MODIS Terra, whose tiles fade in over the last day's.
*/
export function WmtsDimensions() {
const [day, setDay] = useState(0);
const [tileGrid] = useState(level9Grid);
const date = new Date(AUGUST_2025 + day * DAY).toISOString().slice(0, 10);
const slide = (event: ChangeEvent<HTMLInputElement>) => setDay(Number(event.target.value));
return (
<>
<Map height="480px">
<DefaultInteractions />
<DefaultControls />
<View zoom={6}>
<Coordinate x={19.9373} y={50.0617} srid="EPSG:4326" />
</View>
<TileLayer>
<OSMSource />
</TileLayer>
<TileLayer opacity={0.8}>
<WMTSSource
url="https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/MODIS_Terra_CorrectedReflectance_TrueColor/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpeg"
layer="MODIS_Terra_CorrectedReflectance_TrueColor"
matrixSet="GoogleMapsCompatible_Level9"
format="image/jpeg"
requestEncoding="REST"
style="default"
tileGrid={tileGrid}
dimensions={{ Time: date }}
attributions="Imagery: NASA GIBS, MODIS Terra"
/>
</TileLayer>
</Map>
<div className="example-controls">
<label>
Day
<input id="slider" type="range" min="0" max="30" value={day} onChange={slide} />
</label>
<span id="theinfo">{date}</span>
</div>
</>
);
}How the React version works
NASA GIBS's daily MODIS Terra image over OpenStreetMap; a slider chooses a day of August 2025, and the same source fetches the new day's tiles.
What both versions share
OpenLayers renders the map and handles the interactions; the cc-openlayers/core layer gives both adapters the same view binding (MapViewBinding) and the same conversion of coordinates from EPSG:4326 to the map's projection.
From Angular to React
| Angular | React |
|---|---|
[dimensions]="{ Time: date() }" | dimensions={{ Time: date }}: the adapter compares the dimensions by their entries and calls updateDimensions |
(input)="slide($event)" | onChange={slide} |
Who creates, updates and disposes
Map creates the ol/Map in useLayoutEffect and disposes of it on unmount; each layer, source and interaction component adds its object to the parent it gets from context and removes it in its effect's cleanup, as ngOnDestroy does in Angular.
Architecture and OpenLayers mechanics
Configured with requestEncoding="REST", the WMTS source populates URL template tokens directly: {TileMatrix}, {TileRow} and {TileCol} from tile coordinates, {TileMatrixSet} from matrixSet, and {Time} from [dimensions]. Whenever the slider updates Time, OpenLayers invalidates stale requests and fetches tiles for the newly chosen ISO date while retaining previous tiles underneath until replacements arrive.
level9Grid defines NASA GIBS’s GoogleMapsCompatible_Level9 Web Mercator pyramid (256-pixel tiles across levels 0–9), automatically upscaling level-9 tiles if the user zooms closer.
How it works
requestEncoding="REST"fills{TileMatrixSet},{TileMatrix},{TileRow},{TileCol}and{Time}directly in NASA GIBS’s RESTful URL template.- Binding
Timeinside[dimensions]triggers fresh daily tile requests whenever the date slider moves. level9Gridconfigures the 256-pixelGoogleMapsCompatible_Level9Web Mercator grid (levels 0–9), overzooming cleanly past zoom 9.- Outgoing daily tiles stay visible until incoming tiles decode and fade in, avoiding blank flashes while scrubbing dates.
Pitfalls
- While new tiles stream in over slow connections, adjacent squares can momentarily show two different dates side by side—watch layer load events if analysts must know when the entire frame reflects one single day.
- True-colour optical sensors like MODIS capture real cloud cover alongside land surfaces, so cloudy summer days naturally obscure the ground.
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.