I am currently developing an app for getting nearest banks and atms from the current location of user. I am successfully getting all the details from Google Places API but now i wish to sort them according to nearest to the user. Right now it is giving me random means the first results which i am getting is not nearest to user. I want that the first data and others are sorted on the basis of distance from users current location.
If anyone has idea then please kindly help me.
Thanks!!!
First try to current latitude and longitude of the end user and bank or ATMs.
Then, calculate the distance between (the current location and all the banks and ATMs) both of them with the method
distanceTo().Store the distance in the hashmap or arraylist as convenient to you.
Then, sort this distance. Whichever distance is less, retrieve it. It will be the nearest place.
Use this.