diff --git a/have-been-to/countries.db b/have-been-to/countries.db index 7fee22d..da5f862 100644 Binary files a/have-been-to/countries.db and b/have-been-to/countries.db differ diff --git a/have-been-to/static/js/globe.js b/have-been-to/static/js/globe.js index 325241f..0f44f21 100644 --- a/have-been-to/static/js/globe.js +++ b/have-been-to/static/js/globe.js @@ -446,13 +446,26 @@ function updateRendererSize() { } function setupMapSelection() { - const mapSelect = document.getElementById('map-select'); - if (mapSelect) { - mapSelect.addEventListener('change', (event) => { - changeMapType(event.target.value); + const mapTypeSelector = document.getElementById('map-type-selector'); + if (mapTypeSelector) { + // Load preview images for map type options + Object.entries(mapTextures).forEach(([type, url]) => { + const option = mapTypeSelector.querySelector(`[data-map-type="${type}"]`); + if (option) { + option.style.backgroundImage = `url(${url})`; + option.style.backgroundSize = 'cover'; + option.style.backgroundPosition = 'center'; + option.addEventListener('click', () => changeMapType(type)); + + // Set initial selected state + if (type === currentMapType) { + option.classList.add('ring-2', 'ring-blue-500', 'border-blue-500'); + option.classList.remove('border-gray-600'); + } + } }); } else { - console.error('Map select element not found'); + console.error('Map type selector element not found'); } } @@ -463,6 +476,18 @@ function changeMapType(mapType) { map.material.map = newTexture; map.material.needsUpdate = true; saveMapType(mapType); + + // Update selected state visually + const mapTypeSelector = document.getElementById('map-type-selector'); + mapTypeSelector.querySelectorAll('.map-type-option').forEach(option => { + if (option.dataset.mapType === mapType) { + option.classList.add('ring-2', 'ring-blue-500', 'border-blue-500'); + option.classList.remove('border-gray-600'); + } else { + option.classList.remove('ring-2', 'ring-blue-500', 'border-blue-500'); + option.classList.add('border-gray-600'); + } + }); } } @@ -472,7 +497,6 @@ function loadSavedMapType() { .then(data => { if (data.mapType) { changeMapType(data.mapType); - document.getElementById('map-select').value = data.mapType; } }); } @@ -487,7 +511,8 @@ function saveMapType(mapType) { }); } -// Move this to the end of the file +// Ensure setupMapSelection is called after DOM is loaded document.addEventListener('DOMContentLoaded', () => { init(); + setupMapSelection(); }); diff --git a/have-been-to/templates/index.html b/have-been-to/templates/index.html index c5561a8..f07ce1b 100644 --- a/have-been-to/templates/index.html +++ b/have-been-to/templates/index.html @@ -41,12 +41,12 @@