Вписывание маршрута в экран; Новый цвет маршрута
This commit is contained in:
parent
181cf43f37
commit
39c7abe761
|
|
@ -14,6 +14,19 @@ function buildRoute()
|
||||||
|
|
||||||
$('#wayPoints div').each(function(i, el)
|
$('#wayPoints div').each(function(i, el)
|
||||||
{
|
{
|
||||||
|
lat = points[$(el).attr('pointId')]._latlng.lat;
|
||||||
|
lng = points[$(el).attr('pointId')]._latlng.lng;
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
bounds = [[lat, lng],[lat, lng]];
|
||||||
|
} else {
|
||||||
|
if (lat < bounds[0][0]) bounds[0][0] = lat;
|
||||||
|
if (lng < bounds[0][1]) bounds[0][1] = lng;
|
||||||
|
if (lat > bounds[1][0]) bounds[1][0] = lat;
|
||||||
|
if (lng > bounds[1][1]) bounds[1][1] = lng;
|
||||||
|
}
|
||||||
|
|
||||||
wayPoints.push({latLng: points[$(el).attr('pointId')]._latlng});
|
wayPoints.push({latLng: points[$(el).attr('pointId')]._latlng});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -27,10 +40,19 @@ function buildRoute()
|
||||||
route = L.Routing.line(routes[0]);
|
route = L.Routing.line(routes[0]);
|
||||||
distance = Math.round(routes[0].summary.totalDistance / 1000);
|
distance = Math.round(routes[0].summary.totalDistance / 1000);
|
||||||
$('#routeDistance').html('Протяженность <b>' + distance + '</b> км.');
|
$('#routeDistance').html('Протяженность <b>' + distance + '</b> км.');
|
||||||
|
|
||||||
|
route.options.styles = [
|
||||||
|
{color: 'black', opacity: 0.5, weight: 9},
|
||||||
|
{color: 'green', opacity: 0.7, weight: 7},
|
||||||
|
{color: 'orange', opacity: 1, weight: 3}
|
||||||
|
];
|
||||||
|
|
||||||
route.addTo(myMap);
|
route.addTo(myMap);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
myMap.fitBounds(bounds).zoomOut();
|
||||||
|
|
||||||
routeToURL();
|
routeToURL();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue