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.

Kraków's Old Town and the Planty ring with the city's trees from MSIP as dots over OpenStreetMap, and the status Loaded below it.
A screenshot of the example. Trees: Zarząd Zieleni Miejskiej w Krakowie (MSIP). Map data © OpenStreetMap contributors.

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.ts
import { 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('–');
}

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-imagearcgisrest invokes the ArcGIS REST export endpoint for the current view extent, reprojecting the service’s native data into Web Mercator.
  • [ratio]="1" and projection="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-fullscreen mounts declaratively alongside the standard map controls.

Pitfalls

  • Without a LAYERS filter in params, ArcGIS export renders every default-visible sublayer in the MapServer document—specify LAYERS (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.

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.