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); } });