JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<head>
<title>Длинна маршрута</title>
<script src="http://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
ymaps.ready(init);
var myMap;
var coord;
function init(){
myMap = new ymaps.Map("map", {
center: [53.5,45.69],
zoom: 1
});
ymaps.route(['Москва', 'Санкт-Петербург']).then(
function (route) {
myMap.geoObjects.add(route);
},
function (error) {
alert('Возникла ошибка: ' + error.message);
}
);
var routeLength = route.getLength(); // Длина маршрута
alert(routeLength);
}
</script>
<div id="map" style="width: 600px; height: 400px"></div>
</body>
</html>