Browse Source

feat: Add sensor data to market popup

master
Konstantinos Kamaropoulos 5 years ago
parent
commit
eccd36f13e
  1. 21
      src/app/about/about.component.ts

21
src/app/about/about.component.ts

@ -19,8 +19,8 @@ export class AboutComponent implements OnInit {
map: mapboxgl.Map; map: mapboxgl.Map;
style = 'mapbox://styles/mapbox/streets-v11'; style = 'mapbox://styles/mapbox/streets-v11';
lat = 38.06218066666667; lat = 37.9838;
lng = 23.759690166666665; lng = 23.7275;
constructor(private logsService: LogsService) {} constructor(private logsService: LogsService) {}
@ -29,7 +29,7 @@ export class AboutComponent implements OnInit {
this.map = new mapboxgl.Map({ this.map = new mapboxgl.Map({
container: 'map', container: 'map',
style: this.style, style: this.style,
center: [-77.04, 38.907], center: [this.lng, this.lat],
zoom: 9 zoom: 9
}); // Add map controls }); // Add map controls
// this.map.addControl(new mapboxgl.NavigationControl()); // this.map.addControl(new mapboxgl.NavigationControl());
@ -43,9 +43,18 @@ export class AboutComponent implements OnInit {
this.logsService.getLogs().subscribe((data: Array<Object>) => { this.logsService.getLogs().subscribe((data: Array<Object>) => {
this.data = data; this.data = data;
for (let log of data) { for (let log of data) {
var popup = new mapboxgl.Popup({ offset: 25 }).setText( let html =
'Construction on the Washington Monument began in 1848.' log['gps_data']['datestamp'] +
); ' ' +
log['gps_data']['timestamp'] +
'<br><table><tr><th>Sensor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Reading</th></tr>';
for (let record in log['sensorReadings']) {
if (Object.prototype.hasOwnProperty.call(log['sensorReadings'], record)) {
html += '<tr><td>' + record + '</td>' + '<td>' + log['sensorReadings'][record] + '</td></tr>';
}
}
html += '</table>';
var popup = new mapboxgl.Popup({ offset: 25 }).setHTML(html);
var marker = new mapboxgl.Marker({ var marker = new mapboxgl.Marker({
draggable: false draggable: false
}) })

Loading…
Cancel
Save