Spaces:
Running

File size: 1,902 Bytes
f6cd1d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
document.addEventListener('DOMContentLoaded', function() {
    // Initialize map (mock implementation)
    const mapContainer = document.getElementById('map-container');
    
    // Mock route data
    const routes = {
        light: [[10, 10], [30, 30], [50, 50], [70, 70], [90, 90]],
        standard: [[10, 10], [20, 40], [30, 30], [60, 60], [90, 90]],
        heavy: [[10, 10], [40, 20], [30, 50], [70, 60], [90, 90]]
    };

    // Vehicle selection handler
    document.addEventListener('vehicleSelected', function(e) {
        const type = e.detail.type;
        const notification = document.querySelector('custom-route-notification');
        
        // Show notification
        notification.setAttribute('visible', 'true');
        notification.setAttribute('type', type);
        
        // Draw route (mock implementation)
        drawRoute(routes[type]);
        
        // Hide notification after 3 seconds
        setTimeout(() => {
            notification.setAttribute('visible', 'false');
        }, 3000);
    });

    function drawRoute(points) {
        // In a real app, this would use a mapping library like Leaflet or Google Maps
        const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
        svg.setAttribute('width', '100%');
        svg.setAttribute('height', '100%');
        svg.setAttribute('class', 'absolute top-0 left-0 z-10');
        
        const path = document.createElementNS("http://www.w3.org/2000/svg", "polyline");
        path.setAttribute('points', points.map(p => `${p[0]}%,${p[1]}%`).join(' '));
        path.setAttribute('class', 'route-line');
        path.setAttribute('fill', 'none');
        
        svg.appendChild(path);
        
        // Clear previous route
        const oldSvg = mapContainer.querySelector('svg');
        if (oldSvg) oldSvg.remove();
        
        mapContainer.appendChild(svg);
    }
});