To calculate the distance between two points, it’s just
$data[] = json_decode(file_get_contents('http://maps.googleapis.com/maps/api/directions/json?origin=Kyiv&destination=Lviv&sensor=false'));
but how to do if the points are more than 2 here does not work
$data[] = json_decode(file_get_contents('http://maps.googleapis.com/maps/api/directions/json?origin=Kyiv&destination=Lviv&waypoints=Vinnica&sensor=false'));