diff --git a/components/trainMenu.js b/components/trainMenu.js index b80a8c9..4b3e4c0 100644 --- a/components/trainMenu.js +++ b/components/trainMenu.js @@ -34,11 +34,6 @@ export default function TrainMenu({ style }) { "" ).split(","); if (latlng.length == 0) return null; - if (index == 0 && stationPin.length > 0) { - webview.current - ?.injectJavaScript(`MoveDisplayStation('${d}_${D.MyStation}_${D.Station_JP}'); - document.getElementById("disp").insertAdjacentHTML("afterbegin", "
");`); - } stationPinData.push({ D, d, latlng, indexBase: 0, index }); }); }); @@ -150,7 +145,26 @@ export default function TrainMenu({ style }) { opacity: selectedLine == d ? 1 : !selectedLine ? 1 : 0.5, zIndex: 10, }} - onPress={() => setSelectedLine(selectedLine == d ? undefined : d)} + onPress={() => { + const s = selectedLine == d ? undefined : d; + setSelectedLine(s); + Object.keys(stationData).forEach((data, indexBase) => { + stationData[data].forEach((D, index) => { + if (!D.StationMap) return null; + if (s && s != data) return; + const latlng = D.StationMap.replace( + "https://www.google.co.jp/maps/place/", + "" + ).split(","); + if (latlng.length == 0) return null; + if (index == 0 && stationPin.length > 0) { + webview.current + ?.injectJavaScript(`MoveDisplayStation('${data}_${D.MyStation}_${D.Station_JP}'); + document.getElementById("disp").insertAdjacentHTML("afterbegin", "
");`); + } + }); + }); + }} >