Controls · Angular, React and OpenLayers
An overview map
Mount an expanded OpenLayers OverviewMap inset control with its own dedicated OpenStreetMap tile layer to frame the main viewport in context.

What this example shows
Zoomed closely into the streets around Wawel Castle in Kraków, an expanded inset map in the bottom-left corner shows the wider city context with a draggable extent box indicating the exact area currently visible in the main viewport.
Panning or zooming the main map updates the inset box in real time, dragging the inset box repositions the main map, and clicking the corner toggle button folds the overview away when extra canvas room is needed.
When you need it
When analysts inspect utility trenches, cadastral parcels or high-zoom aerial imagery at 1:1 000 scale, surrounding district landmarks disappear off screen and spatial orientation is easily lost.
A classic cartographic overview inset preserves macro regional context alongside micro street detail without splitting the screen into two equal maps.
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.
overview.tsimport { ChangeDetectionStrategy, Component } from '@angular/core';
import {
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerTileComponent,
MapComponent,
SourceOsmComponent,
ViewComponent,
} from 'cc-openlayers';
import { ControlOverviewMapComponent } from 'cc-openlayers/overview';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';
/** OpenLayers' overview map control: a small map that shows and moves the main map's extent. */
@Component({
selector: 'app-overview',
imports: [
ControlOverviewMapComponent,
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerTileComponent,
MapComponent,
SourceOsmComponent,
ViewComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<aol-map height="480px">
<aol-interaction-default />
<aol-control-defaults />
<aol-control-overviewmap [collapsed]="false" [layers]="overviewLayers" />
<aol-view [zoom]="15">
<aol-coordinate [x]="19.9356" [y]="50.054" srid="EPSG:4326" />
</aol-view>
<aol-layer-tile><aol-source-osm /></aol-layer-tile>
</aol-map>
`,
})
export class Overview {
/** OpenLayers' overview map shows only the layers it is given. */
protected readonly overviewLayers = [new TileLayer({ source: new OSM() })];
} 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.
overview.react.tsximport { useState } from 'react';
import TileLayer from 'ol/layer/Tile.js';
import OSM from 'ol/source/OSM.js';
import {
Coordinate,
DefaultControls,
DefaultInteractions,
Map,
OSMSource,
OverviewMapControl,
TileLayer as MapTileLayer,
View,
} from 'cc-openlayers/react';
/** OpenLayers' overview map control: a small map that shows and moves the main map's extent. */
export function Overview() {
/** OpenLayers' overview map shows only the layers it is given. */
const [overviewLayers] = useState(() => [new TileLayer({ source: new OSM() })]);
return (
<Map height="480px">
<DefaultInteractions />
<DefaultControls />
<OverviewMapControl collapsed={false} layers={overviewLayers} />
<View zoom={15}>
<Coordinate x={19.9356} y={50.054} srid="EPSG:4326" />
</View>
<MapTileLayer>
<OSMSource />
</MapTileLayer>
</Map>
);
}How the React version works
An overview map, expanded from the start, shows OpenStreetMap and the rectangle of the main map's view.
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 |
|---|---|
<aol-control-overviewmap [layers]> | <OverviewMapControl layers={overviewLayers} collapsed={false} /> |
| a class field with the overview layer | useState with an initialiser: the overview layers are created once |
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. The control is a child of Map, as in the Angular template; the adapter adds it to the map and removes it on unmount. The control has an ol/Map of its own, so two maps live in the test; unmounting disposes of both.
Architecture and OpenLayers mechanics
aol-control-overviewmap (imported from cc-openlayers/overview) mounts an independent miniature OpenLayers Map instance inside the control overlay. Because OpenLayers renders nothing inside an overview by default—and strictly forbids sharing a single Layer instance across two Map instances—the component supplies a dedicated TileLayer + OSM source array through [layers].
Setting [collapsed]="false" opens the inset on startup, while OpenLayers automatically scales the overview zoom so the indicator box stays between roughly 10% and 75% of the inset frame.
How it works
aol-control-overviewmapfromcc-openlayers/overviewattaches OpenLayers’ interactive overview inset control.[layers]provides a dedicated OpenStreetMap tile layer exclusively for the overview map instance.[collapsed]="false"starts the inset open on initial render while retaining its corner collapse/expand button.
Pitfalls
- Never pass the main map’s own Layer instances into
[layers]: each OpenLayers Layer object can belong to only one Map at a time, so always instantiate separate layer objects (which can still share stateless tile URLs) for the overview. - Avoid locking a fixed zoom on a custom overview View unless intended—OpenLayers’ default dynamic overview scaling keeps the viewport indicator box legible across all zoom levels instead of shrinking it to an invisible dot.
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.