diff --git a/map.js b/map.js index 28fcb4e..2688a9a 100644 --- a/map.js +++ b/map.js @@ -5,27 +5,6 @@ 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', // カスタムマーカー画像のパス @@ -304,4 +283,25 @@ localStorage.setItem('favorites', JSON.stringify(favorites)); alert(`${name}を気になるお店リストに追加しました!`); }; + +// モーダルの開閉操作 +window.openModal = function (imageSrc) { + const modal = document.getElementById('image-modal'); + const modalImage = document.getElementById('modal-image'); + modalImage.src = imageSrc; // クリックした画像のソースを設定 + modal.style.display = 'block'; // モーダルを表示 + }; + +window.closeModal = function () { + 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'; + } + }; });