Vector data · Angular, React and OpenLayers

Feature properties from vector tiles

Inspect vector-tile RenderFeature attributes under the pointer as formatted JSON in OpenLayers over Esri World Basemap Mapbox Vector Tiles.

Esri's vector basemap around Kraków in OpenLayers' default blue style with the tile edges among its lines, and below the map the JSON properties of the S7 expressway's label line under the pointer.
A screenshot of the example. Vector tiles: Esri World Basemap (Esri, TomTom, Garmin, FAO, NOAA, USGS, OpenStreetMap contributors and the GIS User Community).

What this example shows

Esri’s World Basemap vector-tile pyramid renders around Kraków with OpenLayers’ default vector style—thin blue outlines over translucent white fills—making tile seams, label anchors and road centrelines clearly visible, while hovering over any geometry prints its full attribute dictionary as formatted JSON beneath the map.

When you need it

Before authoring flat style expressions or Mapbox GL rules for a new MVT service, cartographers and developers must discover exact source-layer names, road classification codes and label fields carried inside the binary tiles.

Hovering over raw vector tiles with an attribute inspector reveals the real schema at every zoom level instantaneously.

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.

vector-tile-info.ts
import { ChangeDetectionStrategy, Component, signal, viewChild } from '@angular/core';
import {
  CoordinateComponent,
  DefaultControlComponent,
  DefaultInteractionComponent,
  FormatMVTComponent,
  LayerVectorTileComponent,
  MapComponent,
  SourceVectorTileComponent,
  ViewComponent,
} from 'cc-openlayers';
import type MapBrowserEvent from 'ol/MapBrowserEvent';

/** A vector tile layer whose feature properties appear below the map while the pointer is over a feature. */
@Component({
  selector: 'app-vector-tile-info',
  imports: [
    CoordinateComponent,
    DefaultControlComponent,
    DefaultInteractionComponent,
    FormatMVTComponent,
    LayerVectorTileComponent,
    MapComponent,
    SourceVectorTileComponent,
    ViewComponent,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <aol-map height="480px" (pointerMove)="show($event)" (pointerleave)="info.set('')">
      <aol-interaction-default />
      <aol-control-defaults />
      <aol-view [zoom]="9"><aol-coordinate [x]="19.9368" [y]="50.0614" srid="EPSG:4326" /></aol-view>
      <aol-layer-vectortile>
        <aol-source-vectortile
          url="https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer/tile/{z}/{y}/{x}.pbf"
        >
          <aol-format-mvt />
        </aol-source-vectortile>
      </aol-layer-vectortile>
    </aol-map>
    <div class="example-controls">
      <pre>{{ info() || 'Move the pointer over a feature.' }}</pre>
    </div>
  `,
})
export class VectorTileInfo {
  readonly info = signal('');
  private readonly map = viewChild.required(MapComponent);

  /** The properties of the first feature under the pointer, or nothing while the map is dragged. */
  protected show(event: MapBrowserEvent): void {
    if (event.dragging) return;
    const [feature] = this.map().instance.getFeaturesAtPixel(event.pixel);
    this.info.set(feature ? JSON.stringify(feature.getProperties(), null, 2) : '');
  }
}

Architecture and OpenLayers mechanics

Mounting aol-source-vectortile with aol-format-mvt decodes binary Mapbox Vector Tiles into lightweight OpenLayers render features painted in default blue when no custom style is attached.

As the pointer moves across the canvas, getFeaturesAtPixel retrieves intersecting features, reads the topmost feature’s dictionary via getProperties() (which includes the MVT layer name injected by the decoder), formats it with JSON.stringify, and clears the readout on (pointerleave).

How it works

  • aol-source-vectortile paired with aol-format-mvt decodes Esri World Basemap vector tiles in OpenLayers’ diagnostic default blue style.
  • getFeaturesAtPixel resolves features beneath the cursor and prints the first hit’s getProperties() dictionary via JSON.stringify.
  • OpenLayers’ MVT decoder attaches a layer property naming the originating MVT sub-layer (such as Road/label).
  • (pointerleave) clears the JSON panel whenever the cursor exits the map viewport.

Pitfalls

  • Default MVT features are lightweight read-only RenderFeature instances clipped along tile boundaries—meaning a single motorway or river exists as separate fragments across neighbouring tiles.
  • Default unstyled vector tiles draw water polygons, road lines and label anchor points with that same pale fill and blue outline; pair the source with a dedicated style function or Mapbox style document for production cartography.

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.