diff --git a/shonai_tiiiki_map.html b/shonai_tiiiki_map.html new file mode 100644 index 0000000..38d1589 --- /dev/null +++ b/shonai_tiiiki_map.html @@ -0,0 +1,37 @@ + + + + + 庄内町の地域のお店マップ + + + + + + + + + + +

庄内町の地域のお店マップ

+ +    + +
+ + + + + + + + + + + + diff --git a/shonai_tiiki_map.css b/shonai_tiiki_map.css new file mode 100644 index 0000000..b553891 --- /dev/null +++ b/shonai_tiiki_map.css @@ -0,0 +1,115 @@ +/* 全体のスタイル */ +body { + font-family: 'Arial', sans-serif; + margin: 0; + padding: 0; + box-sizing: border-box; + background-color: #fdf6e3; /* 和紙風の薄いベージュ */ + color: #3b2f2f; /* こげ茶 */ +} + +h1 { + font-family: 'Playfair Display', serif; + font-size: 32px; + text-align: center; + margin: 0; + padding: 20px; + background-color: #2e8b57; /* 深緑 */ + color: white; + font-weight: 700; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); + letter-spacing: 1px; + border-bottom: 4px solid #8b4513; /* こげ茶アクセント */ +} + +a { + color: #b22222; /* 赤茶 */ +} + +/* モーダル */ +.modal { + display: none; + position: fixed; + z-index: 1000; + left: 0; + top: 0; + width: 100%; + height: 100%; + overflow: auto; + background-color: rgba(0, 0, 0, 0.8); +} + +.modal-content { + margin: auto; + display: block; + max-width: 90%; + max-height: 90%; + border-radius: 8px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); +} + +.close { + position: absolute; + top: 10px; + right: 25px; + color: white; + font-size: 35px; + font-weight: bold; + cursor: pointer; +} +.close:hover, +.close:focus { + color: #ccc; +} + +/* ポップアップ */ +.popup-content h3 { + font-size: 24px; + margin-bottom: 10px; + color: #8b4513; /* 老舗看板っぽい茶色 */ +} + +.popup-content p { + margin: 8px 0; + color: #3b2f2f; +} + +/* マップ枠 */ +#map { + height: 500px; + margin: 20px; + border: 2px solid #8b4513; /* 茶色 */ + border-radius: 8px; +} + + /* レスポンシブ対応 */ + @media (max-width: 768px) { + #map { + height: 600px; + } + + .search-container input[type="text"] { + font-size: 16px; + padding: 12px; + } + } + +/* サブリンク */ +.sub-link { + text-align: center; + margin: 10px 0 20px 0; + font-size: 18px; +} + +.sub-link a { + color: #2e8b57; /* 深緑 */ + text-decoration: none; + font-weight: bold; + border-bottom: 2px solid transparent; + transition: 0.3s; +} + +.sub-link a:hover { + border-bottom: 2px solid #8b4513; /* 茶色 */ + color: #b22222; /* 赤茶 */ +} diff --git a/shonai_tiiki_map.csv b/shonai_tiiki_map.csv new file mode 100644 index 0000000..48c40b1 --- /dev/null +++ b/shonai_tiiki_map.csv @@ -0,0 +1,6 @@ +name,latitude,longitude,description1,description2,description3,img1,img2,icon,osusume,osusume_images +例:余目第3小学校,38.854124,139.914247,営業時間 8:00〜15:00,住所 山形県東田川郡庄内町廿六木三百地6−1,開業(設立)年数 1874年,images/daigaku.jpg,images/2枚目.jpg,images/school.png,味噌ラーメン,images/daigaku.jpg +名前1,緯度1,経度1,営業時間 ,住所,地元の人に親しみられているお店です,images/sample1-1.jpeg,images/sample1-2.jpeg(画像が一枚のみの場合は名前のみ削除する),images/icon1.png,ハンバーグ,images/hanbaagu.jpg +名前2,緯度2,経度2,営業時間 ,住所,一つ一つ手作りです,images/sample2-1.jpeg,images/sample2-2.jpeg(画像が一枚のみの場合は名前のみ削除する),images/icon2.png,チキンライス,images/tikinraisu.jpg +名前3,緯度3,経度3,営業時間 ,住所,のんびり過ごせるお店です,images/sample3-1.jpeg,images/sample3-2.jpeg(画像が一枚のみの場合は名前のみ削除する),images/icon3.png,味噌ラーメン,images/misoraamen.jpg +名前3,緯度3,経度3,営業時間 ,住所,のんびり過ごせるお店です,images/sample3-1.jpeg,images/sample3-2.jpeg(画像が一枚のみの場合は名前のみ削除する),images/icon3.png,味噌ラーメン,images/misoraamen.jpg diff --git a/shonai_tiiki_map.js b/shonai_tiiki_map.js new file mode 100644 index 0000000..340cd4a --- /dev/null +++ b/shonai_tiiki_map.js @@ -0,0 +1,78 @@ +document.addEventListener('DOMContentLoaded', () => { + const map = L.map('map').setView([38.855235,139.910744], 16); + + // OSMタイル + L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: '© OpenStreetMap contributors' + }).addTo(map); + + // CSV読み込み + Papa.parse("shonai_tiiki_map.csv", { + download: true, + header: true, + complete: function(results) { + results.data.forEach(row => { + if (row.latitude && row.longitude) { + const lat = parseFloat(row.latitude); + const lng = parseFloat(row.longitude); + + // 説明文(空欄は無視) + const descriptions = [row.description1, row.description2, row.description3] + .filter(desc => desc && desc.trim() !== "") + .map(desc => `

${desc}

`) + .join(""); + + // 画像処理(空欄は完全に無視、クリックでモーダル) + let images = ""; + if (row.img1 && row.img1.trim() !== "") { + images += ``; + } + if (row.img2 && row.img2.trim() !== "") { + images += ``; + } + + // ポップアップ内容 + const popupContent = ` + + `; + + // アイコンをCSVから取得、なければデフォルト + const iconUrl = row.icon && row.icon.trim() !== "" ? row.icon : "images/defaultpin.png"; + const customIcon = L.icon({ + iconUrl: iconUrl, + iconSize: [32, 32], // アイコンサイズ + iconAnchor: [16, 32], // ピンの先端位置 + popupAnchor: [0, -32] // ポップアップの位置 + }); + + // マーカー追加(独自アイコン付き) + L.marker([lat, lng], { icon: customIcon }).addTo(map).bindPopup(popupContent); + } + }); + } + }); + + 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'; + } + }; +});