Hi,

Have a stored some json data for locations in local storage as I dont want to load the list every time. The data looks like this.

If I have the users latitude & longitude how would I go about getting the ID of record with closest latitude & longitude values?

Do I need to loop through them all comparing how different each one is and store the ID of the one that is 'Least' different? Or is there a function that could perform a search of this type?


I really dont know where to start with this so any pointers would be appreciated.

Code:
{"Locations":{"Location":[{"id":"3066","latitude":"57.6494","longitude":"-3.5606","name":"Kinloss"},{"id":"3080","latitude":"57.077","longitude":"-2.836","name":"Aboyne"},{"id":"3091","latitude":"57.206","longitude":"-2.202","name":"Aberdeen Dyce"},{"id":"3134","latitude":"55.907","longitude":"-4.533","name":"Glasgow/Bishopton"},{"id":"3136","latitude":"55.515","longitude":"-4.585","name":"Prestwick Rnas"},{"id":"3144","latitude":"56.326","longitude":"-3.729","name":"Strathallan"},