// leaflet.service.ts import { Injectable, Inject, PLATFORM_ID } from '@angular/core'; import { isPlatformBrowser } from '@angular/common'; @Injectable({ providedIn: 'root' }) export class LeafletService { private L: any; constructor(@Inject(PLATFORM_ID) private platformId: Object) { if (isPlatformBrowser(this.platformId)) { this.L = require('leaflet'); } } getLeaflet() { return this.L; } }