This application requires JavaScript.
maps for angular

Angular maps, the boring infra part sorted.

Drop maplibre-gl into ngAfterViewInit, store the instance on the component, and tear it down in ngOnDestroy. No Angular wrappers required.

install
pnpm add maplibre-gl
ts
import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild } from '@angular/core';
import maplibregl, { Map as MapLibreMap } from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';

const MAP_STYLE = 'https://maps.guru/api/v1/styles/standard/light/style.json?key=YOUR_API_KEY';

@Component({
  selector: 'app-city-map',
  template: `<div #host class="map-canvas"></div>`,
  styles: [`.map-canvas { width: 100%; height: 480px; }`],
  standalone: true,
})
export class CityMapComponent implements AfterViewInit, OnDestroy {
  @ViewChild('host', { static: true }) host!: ElementRef<HTMLDivElement>;
  private map?: MapLibreMap;

  ngAfterViewInit(): void {
    this.map = new maplibregl.Map({
      container: this.host.nativeElement,
      style: MAP_STYLE,
      center: [77.209, 28.6139],
      zoom: 11,
    });
    this.map.addControl(new maplibregl.NavigationControl());
  }

  ngOnDestroy(): void {
    this.map?.remove();
  }
}
live · Angular preview

Why Angular teams ship on maps.guru

Free-tier generous enough for real production traffic. 50,000 tile requests/month , no credit card.

  • Mount inside ngAfterViewInit; the @ViewChild(ref) is queried before the lifecycle fires.
  • Tear down with map.remove() inside ngOnDestroy to release the WebGL context.
  • Standalone components keep the template + styles inline for trivial islands.

Frequently asked

Ready to build with
beautiful basemaps?

Join developers worldwide who trust maps.guru for their mapping needs. Start free, no credit card required.

Contact us
Free forever plan
5-minute setup
No credit card