From d1bf01eafc764c82e9a7cf5de101357b788fb8c3 Mon Sep 17 00:00:00 2001 From: Pavel Kustov Date: Sat, 19 Sep 2026 17:05:09 +0800 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=81=D1=82=D1=80=D0=BE=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BF=D0=B5=D1=88=D0=B5=D1=85=D0=BE=D0=B4=D0=BD?= =?UTF-8?q?=D1=8B=D0=B9=20=D0=BC=D0=B0=D1=80=D1=88=D1=80=D1=83=D1=82=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BA=D0=B0=D1=80=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fragments/route.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/fragments/route.php b/fragments/route.php index c89ab44..cd67740 100644 --- a/fragments/route.php +++ b/fragments/route.php @@ -32,9 +32,20 @@ ]; const routeMap = L.map(mapElement,{scrollWheelZoom:false,zoomControl:false}); L.control.zoom({position:'bottomright'}).addTo(routeMap); - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{maxZoom:19,attribution:'© OpenStreetMap contributors'}).addTo(routeMap); + L.tileLayer('https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',{maxZoom:19,attribution:'© OpenStreetMap contributors, Tiles style by HOT'}).addTo(routeMap); const coordinates = stops.map(([,lat,lng]) => [lat,lng]); - L.polyline(coordinates,{color:'#d8a653',weight:5,opacity:.9,lineCap:'round',lineJoin:'round'}).addTo(routeMap); + const routeStyle = {color:'#d8a653',weight:5,opacity:.95,lineCap:'round',lineJoin:'round'}; + const directRoute = L.polyline(coordinates,{...routeStyle,dashArray:'8 8',opacity:.55}).addTo(routeMap); + const walkingCoordinates = coordinates.map(([lat,lng]) => `${lng},${lat}`).join(';'); + fetch(`https://routing.openstreetmap.de/routed-foot/route/v1/driving/${walkingCoordinates}?overview=full&geometries=geojson&steps=false`) + .then(response => response.ok ? response.json() : Promise.reject(new Error('Walking route unavailable'))) + .then(data => { + const route = data.routes?.[0]?.geometry; + if (!route) return; + routeMap.removeLayer(directRoute); + L.geoJSON(route,{style:routeStyle}).addTo(routeMap); + }) + .catch(() => {}); const bounds = L.latLngBounds(coordinates); stops.forEach(([title,lat,lng],index) => { const marker = L.marker([lat,lng],{icon:L.divIcon({className:'route-marker-wrap',html:`${index+1}`,iconSize:[36,36],iconAnchor:[18,18]})}).addTo(routeMap);