feat: add marker list ordering in sidebar with clickable zoom
Co-authored-by: aider (ollama/qwen2.5-coder:32b) <aider@aider.chat>
This commit is contained in:
parent
e0653c654b
commit
942de8c297
31
js/map.js
31
js/map.js
@ -51,10 +51,41 @@ window.createMarker = function(lngLat, content = {}) {
|
|||||||
}
|
}
|
||||||
markersContainer.appendChild(markerElement);
|
markersContainer.appendChild(markerElement);
|
||||||
|
|
||||||
|
updateMarkersList(); // Call the new function to update the list
|
||||||
|
|
||||||
return marker;
|
return marker;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update the updateJourneyPath function to handle cases where markers array is empty
|
// Update the updateJourneyPath function to handle cases where markers array is empty
|
||||||
|
function updateMarkersList() {
|
||||||
|
const markersContainer = document.getElementById('markers-container');
|
||||||
|
markersContainer.innerHTML = '';
|
||||||
|
|
||||||
|
if (currentJourney.markers.length === 0) {
|
||||||
|
markersContainer.innerHTML = '<p class="empty-message">No markers yet. Click on the map to add markers.</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 zoom to marker
|
||||||
|
markerElement.addEventListener('click', () => {
|
||||||
|
map.flyTo({
|
||||||
|
center: [marker.getLatLng().lat, marker.getLatLng().lng],
|
||||||
|
zoom: 10
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
markersContainer.appendChild(markerElement);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function updateJourneyPath() {
|
function updateJourneyPath() {
|
||||||
if (!map.hasLayer(journeyPath)) {
|
if (!map.hasLayer(journeyPath)) {
|
||||||
journeyPath = L.polyline([], {color: '#3887be', weight: 4});
|
journeyPath = L.polyline([], {color: '#3887be', weight: 4});
|
||||||
|
|||||||
2
map.html
2
map.html
@ -104,6 +104,8 @@
|
|||||||
attribution: '© OpenStreetMap contributors'
|
attribution: '© OpenStreetMap contributors'
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
|
||||||
|
updateMarkersList(); // Call the new function to update the list
|
||||||
|
|
||||||
// Add controls
|
// Add controls
|
||||||
const controls = document.createElement('div');
|
const controls = document.createElement('div');
|
||||||
controls.className = 'map-controls';
|
controls.className = 'map-controls';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user