leaflet.service.ts 427 B

1234567891011121314151617181920
  1. // leaflet.service.ts
  2. import { Injectable, Inject, PLATFORM_ID } from '@angular/core';
  3. import { isPlatformBrowser } from '@angular/common';
  4. @Injectable({
  5. providedIn: 'root'
  6. })
  7. export class LeafletService {
  8. private L: any;
  9. constructor(@Inject(PLATFORM_ID) private platformId: Object) {
  10. if (isPlatformBrowser(this.platformId)) {
  11. this.L = require('leaflet');
  12. }
  13. }
  14. getLeaflet() {
  15. return this.L;
  16. }
  17. }