Getdistance geolocation


#1

public getDistance() {
// >> get-distance
let startLocation: Location = new Location();
startLocation.longitude = this.startpointLongitude;
startLocation.latitude = this.startpointLatitude;

    let endLocation: Location = new Location();
    endLocation.longitude = this.endpointLongitude;
    endLocation.latitude = this.endpointLatitude;
    this.distance = distance(startLocation, endLocation);
    // << get-distance

    console.log("distance - " + this.distance);
    this.distanceResult = (this.distance * 0.001).toFixed(3);
}

When importing Location does not work and I get error that could be?


#2

Did you see this page?

https://docs.nativescript.org/hardware/location

Specifically the distance part:

https://docs.nativescript.org/hardware/location#distance


#3

Yes, but the function distance does not work for me. :frowning:


#4

Can you provide some code, console error messages etc?


#5

Thanks for your help, I have already solved my requirement in javascript