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);
|
||||
|
||||
updateMarkersList(); // Call the new function to update the list
|
||||
|
||||
return marker;
|
||||
};
|
||||
|
||||
// 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() {
|
||||
if (!map.hasLayer(journeyPath)) {
|
||||
journeyPath = L.polyline([], {color: '#3887be', weight: 4});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user