This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Description
Description Of The Issue
When requesting a users location after a successful location services request, the getCurrentLocation method times out.
import {Component, OnInit} from "@angular/core";
var geolocation = require("nativescript-geolocation");
@Component({
selector: "my-app",
templateUrl: "app.component.html",
})
export class AppComponent implements OnInit {
status:string = "Location services not enabled";
ngOnInit() {
if (!geolocation.isEnabled()) {
geolocation.enableLocationRequest().then(() => {
this.getLocation();
});
}
else {
this.getLocation();
}
}
getLocation() {
// this method times out when called from the enableLocationRequest promise
geolocation.getCurrentLocation({ timeout: 20000 }).then((location) => {
this.status = `Latitide: ${location.latitude}, Latitude: ${location.longitude}`;
});
}
}
Expected Result
The application should request access to the user's location and then display their latitude and longitude.
Actual Results
The getCurrentLocation method times out.
geolocation-timeout-log.txt
Steps To Recreate
tns create geolocation --ng
- replace the code in app.component.ts with the code above
tns livesync ios --emualtor --watch or tns livesync android --watch (Android Studio Emulator)
Environment Configuration
- NativeScript CLI 2.2.1
- Node 5.4.0
- iOS Simulator version 9.3
- Android API version 22 Emulator