angular get geolocation

Solutions on MaxInterview for angular get geolocation by the best coders in the world

showing results for - "angular get geolocation"
Gabriele
20 Nov 2018
1locationService.ts 
2getPosition(): Promise<any>
3  {
4    return new Promise((resolve, reject) => {
5
6      navigator.geolocation.getCurrentPosition(resp => {
7
8          resolve({lng: resp.coords.longitude, lat: resp.coords.latitude});
9        },
10        err => {
11          reject(err);
12        });
13    });
14
15  }
16component.ts
17this.locationService.getPosition().then(pos=>
18  {
19     console.log(`Positon: ${pos.lng} ${pos.lat}`);
20});
21