[Solved] How do I find/add Map Markers Nearest to the User (Haversine formula)

I wanted to share a fun solultion that I created for another project


You can feed it the lat and long for both location 1 and 2, true/false for returning miles or KM. this will return an object that has the distance!

Quick and easy. each response takes apx 44 seconds when the function is warm. If you are doing a 1 off calculation, it takes about a second.

i also replicated it in cloudflare for fun. always faster than the one above