mileage calculation

Good morning people, everything fine ?

I need to calculate mileage, I have latitude and longitude and address information.

Example:

Origin: Lat -19.4582874 Long -44.2395946

Destiny: Lat -21.30936992 Long -47.73005598

This results in the mileage of 321KM.

An important point, if possible, would be that it brings the time very similar to that of Google, like the photo attached.