Answer the question
In order to leave comments, you need to log in
Yandex Maps for taxis, how to add conditions so that a single tariff is displayed up to 45 km?
Good evening, I can’t figure it out, you need to display a condition so that tariffs up to 45 km display a fixed price
var map, mapRoute;
ymaps.ready(function() {
map = new ymaps.Map('map', {
center: [53.902257, 27.561831],
zoom: 12
});
});
function createRoute(radio) {
// Remove old route
if (mapRoute) {
map.geoObjects.remove(mapRoute);
}
var routeFrom = document.getElementById('froms').value;
var routeTo = document.getElementById('where').value;
// Create a route
ymaps.route([routeFrom, routeTo], {mapStateAutoApply:true}).then(
function(route) {
map.geoObjects.add(route);
var radio = $( 'option:selected' ).val();
var froms = $('#froms').val();
var where = $('#where').val();
if(froms.toLowerCase() || where.toLowerCase() == 'minsk airport') {
if(radio == 1){
var tarif = 1.36;
}
else if(radio == 2){
var tarif = 1.36 ;
}
else if(radio == 3){
var tarif = 1.70 ;
}
else if(radio = = 4){
var tarif = 1.9;
}
else if(radio == 5){
var tarif = 1.9;
}
}else{
if(radio == 1){
var tarif = 0.45;
}
else if(radio == 2){
var tarif = 0.55;
}
else if(radio == 3){
var tarif = 0.65;
}
else if(radio == 4){
var tarif = 0.8;
}
else if(radio == 5){
var tarif = 0.9;
}}
var res = Math.round(route.getLength() /1000);
//var cena = route.split(' ')[0];
//var math =Number(cena.replace(/\D+/g,""));
document.getElementById('route-length').innerHTML = '' + 'Route length: ' + route.getHumanLength()+ '
Price: '+Math.round(res*tarif) +'
Dollars: '+Math.round (res*tarif/2) +'
Rubles: '+Math.round(res*tarif/0.0322) + '';
mapRoute = route;
//$(document).trigger('hasDistance',mapRoute); //send event with parameter
},
function(error) {
alert('Unable to build route');
}
);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question