`;
marker.bindPopup(popupContent);
hotelMarkers.push(marker);
});
}
function planRoute() {
if (routeLine) {
map.removeLayer(routeLine);
}
// Simulate a route between LA and Denver
const latlngs = [ [34.05, -118.24], [36.17, -115.14], [39.10, -108.59], [39.74, -104.99] ];
routeLine = L.polyline(latlngs, {color: 'blue', weight: 5, opacity: 0.7}).addTo(map);
map.fitBounds(routeLine.getBounds().pad(0.1));
displayHotels();
}
function generatePdf() {
// Correctly instantiate jsPDF
const { jsPDF } = jspdf;
const pdf = new jsPDF();
const start = document.getElementById('start-location').value;
const end = document.getElementById('end-location').value;
pdf.setFontSize(22);
pdf.text(`Pet-Friendly Road Trip`, 105, 20, { align: 'center' });
pdf.setFontSize(16);
pdf.text(`${start} to ${end}`, 105, 30, { align: 'center' });
let y = 45;
pdf.setFontSize(12);
hotelMarkers.forEach((marker, index) => {
const hotel = mockHotels.find(h => h.lat === marker.getLatLng().lat);
if (hotel) {
if (y > 270) {
pdf.addPage();
y = 20;
}
pdf.setFontSize(14);
pdf.setTextColor(40, 40, 180);
pdf.text(`${index + 1}. ${hotel.name}`, 15, y);
y += 7;
pdf.setFontSize(11);
pdf.setTextColor(50, 50, 50);
pdf.text(`- Pet Fee: ${hotel.fee > 0 ? `$${hotel.fee}` : 'None'}`, 20, y);
y += 6;
pdf.text(`- Weight Limit: ${hotel.weightLimit ? `${hotel.weightLimit} lbs` : 'None'}`, 20, y);
y += 6;
pdf.text(`- On-site Relief Area: ${hotel.reliefArea ? 'Yes' : 'No'}`, 20, y);
y += 10;
}
});
pdf.save('pet-friendly-itinerary.pdf');
}
document.getElementById('plan-route-btn').addEventListener('click', planRoute);
document.querySelectorAll('.filter-cb').forEach(cb => cb.addEventListener('change', displayHotels));
document.getElementById('pdf-download-btn').addEventListener('click', generatePdf);
// Initial load
planRoute();
});
