Дефолтные поля яндекса работают. А как подключить свои поля, чтобы данные маршрута передавались на карту?
<input type="text" id="from">
<input type="text" id="to">
<div id="map0"></div>
ymaps.ready(init);
function init() {
var myGeocoder = ymaps.geocode([57.626559, 39.893813]);
myGeocoder.then(function(res) {
var myMap0 = new ymaps.Map('map0', {
center: res.geoObjects.get(0).geometry.getCoordinates(),
zoom: 11,
type: 'yandex#map',
controls: []
}),
myRoute,
routePanelControl = new ymaps.control.RoutePanel({
options: {
showHeader: true,
title: 'Построение маршрута',
routePanelTypes: {
taxi: true
},
autofocus: false
}
});
routePanelControl.routePanel.state.set({
type: "taxi",
});
var zoomControl = new ymaps.control.ZoomControl({
options: {
size: 'small',
float: 'none',
position: {
bottom: 145,
right: 10
}
}
});
myMap0.controls.add(routePanelControl).add(zoomControl);
routePanelControl.routePanel.getRouteAsync().then(function(route) {
route.model.setParams({
results: 1
}, true);
route.model.events.add('requestsuccess', function() {
var activeRoute = route.getActiveRoute();
if(activeRoute) {
var length = route.getActiveRoute().properties.get("distance"),
length_value = round(length.value / 1000, 2),
duration = route.getActiveRoute().properties.get("duration"),
durationInTraffic = route.getActiveRoute().properties.get("durationInTraffic"),
points = route.getWayPoints(),
// lastPoint = points.getLength() - 1,
from = points.get(1).properties,
to = points.get(0).properties;
var price_yandex = route.properties.get("taxi").cheapest.price;
function round(a, b) {
b = b || 0;
return Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
}
}
});
});
});
}