Blame view
src/app/component/map/map.component.ts
839 Bytes
c666d6db6 add map graph and... |
1 |
import { Component, OnInit } from '@angular/core'; |
c4e00deb9 add map |
2 3 4 |
import * as L from 'leaflet'; import {Vessels} from '../../model/vessels'; import {VesselsService} from '../../service/vessels.service'; |
c666d6db6 add map graph and... |
5 6 7 8 9 10 11 |
@Component({ selector: 'app-map', templateUrl: './map.component.html', styleUrls: ['./map.component.scss'] }) export class MapComponent implements OnInit { |
c4e00deb9 add map |
12 |
vessels: Vessels; |
c666d6db6 add map graph and... |
13 |
|
c4e00deb9 add map |
14 |
constructor(private vesselsService: VesselsService) { } |
c666d6db6 add map graph and... |
15 16 |
ngOnInit(): void { |
c4e00deb9 add map |
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
this.connectVesselObservable(); this.initMap(); } connectVesselObservable(): void { this.vesselsService.currentVessels.subscribe(vessels => { this.vessels = vessels; }); } initMap(): void { const myMap = L.map('map').setView([0, 0], 1); L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: 'map' }).addTo(myMap); |
c666d6db6 add map graph and... |
32 33 34 |
} } |