Answer the question
In order to leave comments, you need to log in
How can you calculate and display the distance to a point on the map?
Good, there is an example on the site restoran.ru
where distances to establishments are displayed, are there ready-made solutions for such an implementation, if not dynamic (from the current location), then at least from a certain, predetermined point? The coordinates of the points are available through Yandex api, you need to calculate the distance to them .. Thank you
Answer the question
In order to leave comments, you need to log in
If without API, only by coordinates, there is a library
https://github.com/turfjs
Give you all a ready-made lib for every sneeze ...
We read the theory here: https://ru.wikipedia.org/wiki/%D0%A2%D0%B5%D0%BE%D...
function distantion(x1, y1, x2, y2) {
return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
}
What exactly do you need - the distance between two points on the map (which is a straight line and passes through yards / gardens / houses / other), or an adequate distance on the roads?
If the former, then Dmitry Belyaev gave the correct answer.
If the latter, you need to build a weighted digraph and look for paths from one vertex to another on it. More details (theory, algorithms, without reference to practice) - in this article https://habrahabr.ru/post/119158/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question