| 1234567891011121314151617181920 |
- // 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;
- }
- }
|