diff --git a/map4.js b/map4.js index 2599117..4d657eb 100644 --- a/map4.js +++ b/map4.js @@ -30,7 +30,7 @@ const DEFAULT_LNG = 139.752799; // =================================== -// URL パラメータ読み込み +// URL パラメータ // =================================== function loadParams() { const p = new URLSearchParams(location.search); @@ -42,16 +42,14 @@ } // =================================== -// ラベル付きカスタム DivIcon +// ラベル付きカスタムアイコン // =================================== function createLabeledIcon(name, type) { let pinImg = ""; if (type === "self") { - // ★ 自分のピン(Google公式の青い星) pinImg = "https://maps.gstatic.com/mapfiles/kml/paddle/blu-stars.png"; } else { - // ★ 他人はライトグリーン pinImg = "https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-green.png"; } @@ -81,7 +79,7 @@ } // =================================== -// 地図初期化 +// 地図生成 // =================================== function initMap(lat, lng) { map = L.map("map").setView([lat, lng], 15); @@ -92,7 +90,7 @@ } // =================================== -// ★ 自分のピンを毎回描き直す(クリック反応安定) +// 自分のピン(再描画方式) // =================================== function renderSelfMarker() { if (selfMarker) map.removeLayer(selfMarker); @@ -110,7 +108,7 @@ } // =================================== -// 自分の位置保存 +// 保存 // =================================== async function saveMyLocation(lat, lng) { await supa @@ -165,7 +163,7 @@ } // =================================== -// 他ユーザーの表示 +// 他ユーザー描画 // =================================== async function showOtherUsers() { const { data } = await supa @@ -229,7 +227,7 @@ await saveMyLocation(lat, lng); await showOtherUsers(); - // ★ 自分の位置更新(毎回再描画) + // 自分の位置更新 setInterval(async () => { try { const pos = await getPosition(); @@ -241,6 +239,7 @@ } catch {} }, 8000); + // 他のユーザー位置更新 setInterval(showOtherUsers, 2000); const exit = document.getElementById("exitBtn");