I am currently developing a JavaScript application that interfaces with the Google Maps API. The program has the following requirements:
- Enable users to input a location.
- Upon clicking the "find" button, convert the user's entered location into longitude and latitude coordinates.
- Run an algorithm to calculate the distance between the user's entered location and 20 predefined longitude and latitude coordinates.
- Display the calculated distance in kilometers.
- Identify the location with the shortest distance by looping through and comparing all distances.
I have successfully completed steps 1 and 2, but I am struggling to identify a method for storing the index of a location, including its longitude and latitude points. This is crucial for comparing them to the user-inputted location. Additionally, I am having difficulty devising a strategy for determining the shortest distance among all points to find the closest longitude and latitude.
Any assistance would be greatly appreciated,
THANK YOU!