Me and a few of my friends are trying to create an app that finds the closest location to your current one. The locations are a list of objects with properties of latitude, longitude, and location name. I found a post that tried to do a similar thing with the spherical law of cosines, but it won’t work when I try and implement it with my code. Is anyone able to find an error with my code or has an idea on how to fix it? I want to continue to use the locations list that I have already implemented if possible because there a lot of locations I am working with.
The location that I keep on receiving is shown below, but there are much closer locations in the list.