Livebeat is now able to send, store and show beats
This commit is contained in:
32
frontend/src/app/dashboard/dashboard.component.ts
Normal file
32
frontend/src/app/dashboard/dashboard.component.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { AfterViewInit, Component, OnInit } from '@angular/core';
|
||||
import { Map } from 'mapbox-gl';
|
||||
import { APIService } from '../api.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard',
|
||||
templateUrl: './dashboard.component.html',
|
||||
styleUrls: ['./dashboard.component.scss']
|
||||
})
|
||||
export class DashboardComponent implements AfterViewInit {
|
||||
map: Map;
|
||||
|
||||
data: GeoJSON.FeatureCollection<GeoJSON.LineString> = {
|
||||
type: 'FeatureCollection', features: [
|
||||
{
|
||||
type: 'Feature',
|
||||
properties: null,
|
||||
geometry: { type: 'LineString', coordinates: [] }
|
||||
}]
|
||||
};
|
||||
|
||||
constructor(private api: APIService) { }
|
||||
|
||||
async ngAfterViewInit(): Promise<void> {
|
||||
const beats = await this.api.getBeats();
|
||||
beats.forEach((beat) => {
|
||||
this.data.features[0].geometry.coordinates.push([beat.coordinate[1], beat.coordinate[0]]);
|
||||
});
|
||||
console.log("Now:", this.data.features);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user