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

Timeout while searching for location - Angular 2 #30

@burkeholland

Description

@burkeholland

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

  1. tns create geolocation --ng
  2. replace the code in app.component.ts with the code above
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions