import { Injectable } from '@angular/core'; import { isEnabled, enableLocationRequest, getCurrentLocation, watchLocation, distance, clearWatch, Location } from "nativescript-geolocation"; @Injectable({ providedIn: 'root' }) export class MyGeoLocationService { loc: Location; constructor() { } getLocation(): Promise { this.isLocationEnabled(); var result = getCurrentLocation({ desiredAccuracy: 3, timeout: 5000 }); return result; } private isLocationEnabled() { isEnabled().then(function (isEnabled) { if (!isEnabled) { enableLocationRequest().then(function () { }, function (e) { alert("Error: " + (e.message || e)); }); } }, function (e) { alert("Error: " + (e.message || e)); }); } }