get location home component

This commit is contained in:
2023-01-31 15:54:13 +01:00
parent 21f2d2d002
commit be568dc118
3 changed files with 14 additions and 1 deletions

View File

@@ -6,7 +6,13 @@ import {Component, OnInit} from '@angular/core';
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
latitude: number | undefined;
longitude: number | undefined;
ngOnInit(): void {
navigator.geolocation.getCurrentPosition(position => {
this.latitude = position.coords.latitude;
this.longitude = position.coords.longitude;
})
}
}