Y
Y
Yuri Petrashevich2015-07-30 13:03:45
PHP
Yuri Petrashevich, 2015-07-30 13:03:45

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

3 answer(s)
A
Alexander Kalinin, 2017-08-15
@kentovsky

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;

F
forgotten, 2015-07-30
@forgotten

You can, for example, read the documentation.
https://tech.yandex.ru/maps/doc/jsapi/2.1/dg/conce...

M
Misha Seryak, 2019-01-21
@Seryak

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 question

Ask a Question

731 491 924 answers to any question