Shorten route popup

This commit is contained in:
Eugene Burmakin 2024-05-31 20:17:14 +02:00
parent fe73b5040a
commit 12985e1fee

View file

@ -65,15 +65,12 @@ export default class extends Controller {
// Create markers for the start and end points // Create markers for the start and end points
const startMarker = L.marker([startPoint[0], startPoint[1]], { icon: startIcon }).bindPopup(`Start: ${firstTimestamp}`); const startMarker = L.marker([startPoint[0], startPoint[1]], { icon: startIcon }).bindPopup(`Start: ${firstTimestamp}`);
const endMarker = L.marker([endPoint[0], endPoint[1]], { icon: finishIcon }).bindPopup(` const endMarker = L.marker([endPoint[0], endPoint[1]], { icon: finishIcon }).bindPopup(`
Start: ${firstTimestamp}<br> <b>Start:</b> ${firstTimestamp}<br>
End: ${lastTimestamp}<br> <b>End:</b> ${lastTimestamp}<br>
Time on route: ${timeOnRoute} minutes<br> <b>Duration:</b> ${timeOnRoute} min<br>
Distance to previous route: ${Math.round(distanceToPrev)} meters<br> <b>Prev Route:</b> ${Math.round(distanceToPrev)} m, ${timeBetweenPrev} min away<br>
Distance to next route: ${Math.round(distanceToNext)} meters<br> <b>Next Route:</b> ${Math.round(distanceToNext)} m, ${timeBetweenNext} min away<br>
Time from previous route: ${timeBetweenPrev} minutes<br>
Time to next route: ${timeBetweenNext} minutes
`); `);
// Add mouseover event to highlight the polyline and show the start and end markers // Add mouseover event to highlight the polyline and show the start and end markers
@ -85,13 +82,12 @@ export default class extends Controller {
// Add mouseout event to revert the polyline style and remove the start and end markers // Add mouseout event to revert the polyline style and remove the start and end markers
polyline.on('mouseout', function(e) { polyline.on('mouseout', function(e) {
polyline.setStyle(originalStyle); polyline.setStyle(originalStyle);
map.closePopup(); map.closePopup();
map.removeLayer(startMarker); map.removeLayer(startMarker);
map.removeLayer(endMarker); map.removeLayer(endMarker);
}); });
} }
var splitPolylines = []; var splitPolylines = [];
var currentPolyline = []; var currentPolyline = [];