diff --git a/map4.js b/map4.js index d79294a..bac9f7e 100644 --- a/map4.js +++ b/map4.js @@ -187,7 +187,7 @@ const toRad = (deg) => (deg * Math.PI) / 180; const dLat = toRad(lat2 - lat1); - const dLng = toRad(lng2 - lng1); + const dLng = toRad(lat2 - lng1); const a = Math.sin(dLat / 2) ** 2 + @@ -315,7 +315,7 @@ hostLabel.textContent = isHost ? "あなたはホストです" : "一般メンバーです"; } - // 解散ボタンの表示制御 + // 解散ボタンの表示制御(★ここが唯一の display 制御) const disbandBtn = document.getElementById("disbandBtn"); if (disbandBtn) { disbandBtn.style.display = isHost ? "inline-block" : "none"; @@ -658,10 +658,9 @@ exitBtn.onclick = () => (location.href = "index.html"); } - // グループ解散ボタン(ホスト専用) + // グループ解散ボタン(クリックだけ設定) const disbandBtn = document.getElementById("disbandBtn"); if (disbandBtn) { - disbandBtn.style.display = isHost ? "inline-block" : "none"; disbandBtn.onclick = disbandGroup; } @@ -694,8 +693,15 @@ .eq("group_name", groupNameFromUrl) .maybeSingle(); - // グループが存在しない or 解散済み → いきなり archive へ - if (!group || group.is_active === false) { + // グループが存在しない → index へ + if (!group) { + alert("このグループは存在しません。"); + location.href = "index.html"; + return; + } + + // 解散済み → いきなり archive へ + if (group.is_active === false) { alert("このグループは解散されています。履歴ページを表示します。"); location.href = "archive.html?group=" + encodeURIComponent(groupNameFromUrl || ""); @@ -711,6 +717,12 @@ if (hostLabel) hostLabel.textContent = isHost ? "あなたはホストです" : "一般メンバーです"; + // 解散ボタンの初期表示 + const disbandBtn = document.getElementById("disbandBtn"); + if (disbandBtn) { + disbandBtn.style.display = isHost ? "inline-block" : "none"; + } + // メイン開始 main(); });