Answer the question
In order to leave comments, you need to log in
PHP. Yandex maps. How to determine the distance between two points along the roads?
There are two addresses, I get their coordinates. How can I determine the distance between these addresses using the Yandex.Maps API, taking into account road traffic?
Answer the question
In order to leave comments, you need to log in
Can be counted on google maps
$from = "Санкт-Петергубг Ленина 5";
$to = "Выборг Ленина 20";
$from = urlencode($from);
$to = urlencode($to);
$data = file_get_contents("http://maps.googleapis.com/maps/api/distancematrix/json?origins=$from&destinations=$to&language=ru-RU&sensor=false");
$data = json_decode($data);
echo "Откуда: ".$data->destination_addresses[0] . "<br/>" .
"Куда: ". $data->origin_addresses[0] . "<br/>" .
"Время: ". $data->rows[0]->elements[0]->distance->text . "<br/>" .
"Путь: ".$data->rows[0]->elements[0]->duration->text;
You can, for example, read the documentation.
https://tech.yandex.ru/maps/doc/jsapi/2.1/dg/conce...
Here you can see the documentation on getting the duration and distance of the route between two points using CURL
https://tech.yandex.ru/routing/doc/distance_matrix...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question