diff --git a/map.js b/map.js index c4bc543..28fcb4e 100644 --- a/map.js +++ b/map.js @@ -5,6 +5,27 @@ attribution: '© OpenStreetMap contributors' }).addTo(map); +// モーダルの開閉操作 +function openModal(imageSrc) { + const modal = document.getElementById('image-modal'); + const modalImage = document.getElementById('modal-image'); + modalImage.src = imageSrc; // クリックした画像のソースを設定 + modal.style.display = 'block'; // モーダルを表示 +} + +function closeModal() { + const modal = document.getElementById('image-modal'); + modal.style.display = 'none'; // モーダルを非表示 +} + +// モーダル外をクリックして閉じる +window.onclick = function (event) { + const modal = document.getElementById('image-modal'); + if (event.target === modal) { + modal.style.display = 'none'; + } +}; + // カスタムアイコンを定義 const customIcon = L.icon({ iconUrl: 'images/marker-icon.png', // カスタムマーカー画像のパス @@ -257,27 +278,6 @@ iconAnchor: [16, 32], popupAnchor: [0, -32] }); - -// モーダルの開閉操作 -function openModal(imageSrc) { - const modal = document.getElementById('image-modal'); - const modalImage = document.getElementById('modal-image'); - modalImage.src = imageSrc; // クリックした画像のソースを設定 - modal.style.display = 'block'; // モーダルを表示 -} - -function closeModal() { - const modal = document.getElementById('image-modal'); - modal.style.display = 'none'; // モーダルを非表示 -} - -// モーダル外をクリックして閉じる -window.onclick = function (event) { - const modal = document.getElementById('image-modal'); - if (event.target === modal) { - modal.style.display = 'none'; - } -}; const marker = L.marker([snack.lat, snack.lng], { icon: markerIcon }).addTo(map); const popupContent = `