ymaps.ready(function () {
var suggestView = new ymaps.SuggestView(
'delivery_address',
{boundedBy: [[56.146539,92.547415],[55.931698,93.273221]]}
);
console.log(suggestView);
suggestView.events.add('select',function(event){
selected = event.get('item').value;
let dist = search_address(selected);
delivery(dist);
});
});
var distance = [];
function search_address (address) {
//var total_sum = $('#total').val();
var route = ymaps.route(
[
'Россия, Красноярск, Взлётная улица, 7',
address
],
).then(
function(route){
let dist = route.getLength() / 1000;
distance.push(dist);
},
function (error) {
console.log(error);
console.log("Возникла ошибка: " + error.message);
}
)
var route2 = ymaps.route(
[
'Россия, Красноярск, Дубровинского, 62а',
address
],
).then(
function(route){
let dist = route.getLength() / 1000;
distance.push(dist);
},
function (error) {
console.log(error);
console.log("Возникла ошибка: " + error.message);
}
);
return distance;
}
function delivery(dist) {
let min = Math.min(dist[0],dist[1]);
}
ymaps.ready(function () {
var suggestView = new ymaps.SuggestView(
'delivery_address',
{boundedBy: [[56.146539,92.547415],[55.931698,93.273221]]}
);
console.log(suggestView);
suggestView.events.add('select',function(event){
selected = event.get('item').value;
let dist = search_address(selected);
delivery(dist);
});
});
var distance = [];
function search_address (address) {
//var total_sum = $('#total').val();
var route = ymaps.route(
[
'Россия, Красноярск, Взлётная улица, 7',
address
],
).then(
function(route){
let dist = route.getLength() / 1000;
distance.push(dist);
},
function (error) {
console.log(error);
console.log("Возникла ошибка: " + error.message);
}
).then (
route = ymaps.route(
[
'Россия, Красноярск, Дубровинского, 62а',
address
],
).then(
function(route){
let dist = route.getLength() / 1000;
distance.push(dist);
delivery(distance);
},
function (error) {
console.log(error);
console.log("Возникла ошибка: " + error.message);
}
)
);
}
function delivery(dist) {
if (dist) {
let min = Math.min(dist[0],dist[1]);
}
}