diff --git a/map4.js b/map4.js index c6afc59..07339e9 100644 --- a/map4.js +++ b/map4.js @@ -61,6 +61,46 @@ } // =================================== +// エレベーター情報(CSV読み込み) +// =================================== + +let elevatorInfo = new Map(); + +fetch("./elevators.csv") // ← 同じフォルダなのでこれ + .then(res => res.text()) + .then(text => { + const lines = text.split("\n").slice(1); // 1行目ヘッダ + + lines.forEach(line => { + if (!line.trim()) return; + + const [station, hasEV] = line.split(","); + elevatorInfo.set(station.trim(), hasEV.trim() === "1"); + }); + + console.log("エレベーターデータ読込完了:", elevatorInfo); + }); + +const elevatorIcon = L.icon({ + iconUrl: "./elevator.png", // ← 同じ場所にある画像を使う + iconSize: [22, 22] +}); + +// 駅のピン表示(既存) +const mk = L.marker([st.lat, st.lon]).addTo(map); +mk.bindPopup(name + "駅"); +stationMarkers.push(mk); + +// ★ エレベーターがある駅は EVアイコンを重ねて表示 +if (elevatorInfo.get(name)) { + const ev = L.marker([st.lat, st.lon], { icon: elevatorIcon }) + .addTo(map) + .bindPopup(`${name}:エレベーターあり`); + + stationMarkers.push(ev); +} + +// =================================== // URL パラメータ // =================================== function loadParams() {