Tile and image services · Angular, React and OpenLayers
An ArcGIS MapServer layer
Export Kraków municipal trees from an ArcGIS MapServer REST service as a single dynamic viewport image over OpenStreetMap with load status.

What this example shows
Zoomed onto Kraków’s Old Town and the green Planty ring, municipal street and park trees maintained by the city’s greenery authority stream live from Kraków’s ArcGIS MapServer (MSIP) as a transparent single-image overlay atop OpenStreetMap, accompanied by a fullscreen button and a live load-state indicator below.
When you need it
Municipalities, utilities and environmental agencies running ArcGIS Enterprise frequently publish dynamic MapServer endpoints without pre-built tile caches.
Requesting a single dynamic export image per settled viewport avoids cut-off labels at tile seams and asks ArcGIS Server to reproject the service’s native data into Web Mercator on the fly.
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.
arcgis-image.tsimport { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import {
ControlFullScreenComponent,
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerImageComponent,
LayerTileComponent,
MapComponent,
SourceImageArcGISRestComponent,
SourceOsmComponent,
ViewComponent,
} from 'cc-openlayers';
/** Kraków's city trees exported by the city's ArcGIS MapServer (MSIP) as one image per view, with its load status. */
@Component({
selector: 'app-arcgis-image',
imports: [
ControlFullScreenComponent,
CoordinateComponent,
DefaultControlComponent,
DefaultInteractionComponent,
LayerImageComponent,
LayerTileComponent,
MapComponent,
SourceImageArcGISRestComponent,
SourceOsmComponent,
ViewComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<aol-map height="480px">
<aol-interaction-default />
<aol-control-defaults />
<aol-control-fullscreen />
<aol-view [zoom]="15"><aol-coordinate [x]="19.9368" [y]="50.0614" srid="EPSG:4326" /></aol-view>
<aol-layer-tile><aol-source-osm /></aol-layer-tile>
<aol-layer-image>
<aol-source-imagearcgisrest
projection="EPSG:3857"
[ratio]="1"
url="https://msip.um.krakow.pl/arcgis/rest/services/ZZM/ZZM_Drzewa/MapServer"
attributions="Trees: Zarząd Zieleni Miejskiej w Krakowie (MSIP)"
(imageLoadStart)="status.set('Loading…')"
(imageLoadEnd)="status.set('Loaded')"
/>
</aol-layer-image>
</aol-map>
<div class="example-controls">
<output>{{ status() }}</output>
</div>
`,
})
export class ArcgisImage {
readonly status = signal('–');
} 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.
arcgis-image.react.tsximport { useState } from 'react';
import {
Coordinate,
DefaultControls,
DefaultInteractions,
FullScreenControl,
ImageArcGISRestSource,
ImageLayer,
Map,
OSMSource,
TileLayer,
View,
} from 'cc-openlayers/react';
/** Kraków's city trees exported by the city's ArcGIS MapServer (MSIP) as one image per view, with its load status. */
export function ArcgisImage() {
const [status, setStatus] = useState('–');
return (
<>
<Map height="480px">
<DefaultInteractions />
<DefaultControls />
<FullScreenControl />
<View zoom={15}>
<Coordinate x={19.9368} y={50.0614} srid="EPSG:4326" />
</View>
<TileLayer>
<OSMSource />
</TileLayer>
<ImageLayer>
<ImageArcGISRestSource
projection="EPSG:3857"
ratio={1}
url="https://msip.um.krakow.pl/arcgis/rest/services/ZZM/ZZM_Drzewa/MapServer"
attributions="Trees: Zarząd Zieleni Miejskiej w Krakowie (MSIP)"
onImageLoadStart={() => setStatus('Loading…')}
onImageLoadEnd={() => setStatus('Loaded')}
/>
</ImageLayer>
</Map>
<div className="example-controls">
<output>{status}</output>
</div>
</>
);
}How the React version works
Kraków's city trees from the city's ArcGIS MapServer as one image per view, with a loading status below the map.
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-source-imagearcgisrest> | <ImageArcGISRestSource> |
(imageLoadStart), (imageLoadEnd) on the source | onImageLoadStart, onImageLoadEnd |
signal('') with the status | useState('') |
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
aol-source-imagearcgisrest calls the REST export operation whenever the camera settles, passing the visible bounding box and pixel dimensions. Setting [ratio]="1" requests an image matching the exact viewport size (rather than OpenLayers’ default 1.5× pan buffer), while projection="EPSG:3857" instructs MSIP to reproject tree points into the map’s Spherical Mercator coordinate system.
Image load lifecycle events update the status line beneath the canvas, and aol-control-fullscreen enables full-screen inspection.
How it works
aol-source-imagearcgisrestinvokes the ArcGIS RESTexportendpoint for the current view extent, reprojecting the service’s native data into Web Mercator.[ratio]="1"andprojection="EPSG:3857"request an exact viewport-sized PNG in the map’s coordinate system.- Source image load events drive the Loading / Loaded status indicator beneath the map.
aol-control-fullscreenmounts declaratively alongside the standard map controls.
Pitfalls
- Without a
LAYERSfilter in params, ArcGISexportrenders every default-visible sublayer in the MapServer document—specifyLAYERS(show:0,2 etc.) whenever you want only selected sublayers. - Check service metadata for token authentication, maximum image pixel limits (maxImageWidth / maxImageHeight) and CORS headers before wiring third-party ArcGIS servers.
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.