I want to get the current position of the user and calculate the distance between this position and others positions. I am using this tutorial : Create a Nearby Places List with Google Maps in Ionic 2. This is the code:
let usersLocation;
Geolocation.getCurrentPosition().then((position) => {
usersLocation = { lat :position.coords.latitude , lng : position.coords.longitude }
locations.map((location) => {
let placeLocation = {
lat: location.latitude,
lng: location.longitude
};
location.distance = this.getDistanceBetweenPoints(
usersLocation,
placeLocation,
'miles'
).toFixed(2);
});
});
The problem is : The usersLocation variable is not set with the latitude and the longitude of the current user's postion. Can you help me!!