Calculating distance using google map based on latitude and longitude

I am developing a desktop application and I have two points (latitude, longitude). How can I get the distance between these two points? I looked at the API, and most of them are javascript or a web interface. I am not developing a webpage. How can i do this in java?

I want the distance to the road, not the direct distance

+3
source share
3 answers

If you have latitude and longitude, you can use the Haversine formula to calculate the distance between them - if you want a “straight line”.

EDIT: , , , , Directions API. - URL , XML, JSON-, .

, "JSON"!= "Javascript-based". JSON , , , Javascript.

+7

This Great Circle Distance code is above probaby OK for most applications. However, if you need more accuracy, keep in mind that it may fail in some cases due to the fact that the earth is not an ideal sphere. In this case, you are talking about more complex algorithms.

0
source

Source: https://habr.com/ru/post/1777717/


All Articles