._.
This commit is contained in:
parent
479ae99384
commit
61fff8c2e1
@ -12,6 +12,12 @@ import {
|
|||||||
import polyline from "@mapbox/polyline";
|
import polyline from "@mapbox/polyline";
|
||||||
import "./DeliveryOrderDetails.css";
|
import "./DeliveryOrderDetails.css";
|
||||||
|
|
||||||
|
const DELIVERY_CITY = {
|
||||||
|
name: "Челябинск",
|
||||||
|
latitude: 55.159902,
|
||||||
|
longitude: 61.402554,
|
||||||
|
};
|
||||||
|
|
||||||
const DeliveryOrderDetails = () => {
|
const DeliveryOrderDetails = () => {
|
||||||
const { id: deliveryOrderId } = useParams();
|
const { id: deliveryOrderId } = useParams();
|
||||||
const [deliveryAccessories, setDeliveryAccessories] = useState([]);
|
const [deliveryAccessories, setDeliveryAccessories] = useState([]);
|
||||||
@ -36,8 +42,10 @@ const DeliveryOrderDetails = () => {
|
|||||||
);
|
);
|
||||||
setCoordinates(coords);
|
setCoordinates(coords);
|
||||||
|
|
||||||
if (coords.length > 1) {
|
const fullCoordinates = [...coords, DELIVERY_CITY];
|
||||||
const waypoints = coords
|
|
||||||
|
if (fullCoordinates.length > 1) {
|
||||||
|
const waypoints = fullCoordinates
|
||||||
.map(({ longitude, latitude }) => `${longitude},${latitude}`)
|
.map(({ longitude, latitude }) => `${longitude},${latitude}`)
|
||||||
.join(";");
|
.join(";");
|
||||||
const routeUrl = `https://router.project-osrm.org/route/v1/driving/${waypoints}?overview=full`;
|
const routeUrl = `https://router.project-osrm.org/route/v1/driving/${waypoints}?overview=full`;
|
||||||
@ -62,7 +70,7 @@ const DeliveryOrderDetails = () => {
|
|||||||
<div className="delivery-order-details">
|
<div className="delivery-order-details">
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<div className="spinner-border" role="status">
|
<div className="spinner-border" role="status">
|
||||||
<span className="visually-hidden">Загрузка...</span>
|
<span className="visually-hidden"></span>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="content-container">
|
<div className="content-container">
|
||||||
@ -104,6 +112,11 @@ const DeliveryOrderDetails = () => {
|
|||||||
<Popup>{coord.city}</Popup>
|
<Popup>{coord.city}</Popup>
|
||||||
</Marker>
|
</Marker>
|
||||||
))}
|
))}
|
||||||
|
<Marker
|
||||||
|
position={[DELIVERY_CITY.latitude, DELIVERY_CITY.longitude]}
|
||||||
|
>
|
||||||
|
<Popup>{DELIVERY_CITY.name}</Popup>
|
||||||
|
</Marker>
|
||||||
{route.length > 0 && (
|
{route.length > 0 && (
|
||||||
<Polyline positions={route} color="blue" />
|
<Polyline positions={route} color="blue" />
|
||||||
)}
|
)}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user