math javascript for distance calculation based on lat/log