feat: add journey creation functionality
Co-authored-by: aider (ollama/qwen2.5-coder:32b) <aider@aider.chat>
This commit is contained in:
4 files changed
+170
-4
No files matched your search
+64
@@ -1,5 +1,69 @@
|
||||
// /Volumes/Data/Code/FHGR/Frontend/js/main.js
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Journey Management
|
||||
let currentJourney = {
|
||||
name: "",
|
||||
description: "",
|
||||
markers: []
|
||||
};
|
||||
|
||||
function saveJourney() {
|
||||
const journeyData = {
|
||||
name: document.getElementById('journey-name').value,
|
||||
description: document.getElementById('journey-desc').value,
|
||||
markers: currentJourney.markers.map(marker => ({
|
||||
lat: marker.getLatLng().lat,
|
||||
lng: marker.getLatLng().lng
|
||||
}))
|
||||
};
|
||||
|
||||
// Save to backend
|
||||
fetch('/api/journeys', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(journeyData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log('Journey saved:', data);
|
||||
alert('Journey saved successfully!');
|
||||
currentJourney = {
|
||||
name: "",
|
||||
description: "",
|
||||
markers: []
|
||||
};
|
||||
document.getElementById('journey-name').value = '';
|
||||
document.getElementById('journey-desc').value = '';
|
||||
})
|
||||
.catch(error => console.error('Error saving journey:', error));
|
||||
}
|
||||
|
||||
function updateMarkersList() {
|
||||
const container = document.getElementById('markers-list');
|
||||
container.innerHTML = '';
|
||||
|
||||
currentJourney.markers.forEach((marker, index) => {
|
||||
const markerElement = document.createElement('div');
|
||||
markerElement.className = 'marker-item';
|
||||
markerElement.innerHTML = `
|
||||
<strong>${index + 1}</strong>
|
||||
${marker.getLatLng().lat.toFixed(4)}, ${marker.getLngLat().lng.toFixed(4)}
|
||||
`;
|
||||
|
||||
// Add click handler to focus on marker
|
||||
markerElement.addEventListener('click', () => {
|
||||
map.flyTo(marker.getLatLng(), 10);
|
||||
});
|
||||
|
||||
container.appendChild(markerElement);
|
||||
});
|
||||
}
|
||||
|
||||
// Event Listeners
|
||||
document.getElementById('save-journey').addEventListener('click', saveJourney);
|
||||
|
||||
// Initialize current journey when page loads
|
||||
window.currentJourney = {
|
||||
id: Date.now(),
|
||||
|
||||
Reference in new issue
Block a user