Looking to determine the current position of a user and calculate the distance between their location and others? Utilizing a helpful tutorial for this task, available at: Create a Nearby Places List with Google Maps in Ionic 2. Here's some code excerpt from the tutorial:
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);
});
});
Encountering an issue where the usersLocation variable is not being properly set with the latitude and longitude coordinates of the current user's postion. Seeking assistance to resolve this problem!