From c9b59c3b62f199cfd5ea0d39620da7a8210a28f4 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Sun, 1 Sep 2024 04:46:26 +0000 Subject: [PATCH] =?UTF-8?q?=E9=A7=85=E5=90=8D=E6=A8=99=E3=81=AB=E4=BD=8F?= =?UTF-8?q?=E6=89=80=E3=81=AE=E8=A1=A8=E7=A4=BA=E3=82=92=E9=96=8B=E5=A7=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/駅名表/AddressText.tsx | 38 ++++++++++++++++++++++++++++ components/駅名表/Sign.js | 10 +++++--- lib/getStationList.js | 4 +++ 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 components/駅名表/AddressText.tsx diff --git a/components/駅名表/AddressText.tsx b/components/駅名表/AddressText.tsx new file mode 100644 index 0000000..d743477 --- /dev/null +++ b/components/駅名表/AddressText.tsx @@ -0,0 +1,38 @@ +import React, { FC, useEffect } from "react"; +import { Text } from "react-native"; +type Props = { + currentStation: any[]; + isMatsuyama: boolean; +}; +export const AddressText: FC = (props) => { + const { currentStation, isMatsuyama } = props; + const [stationAddress, setStationAddress] = React.useState(""); + useEffect(() => { + if (!!currentStation[0].jslodApi) { + fetch(`${currentStation[0].jslodApi}.json`) + .then((response) => response.json()) + .then((data) => { + const c = + data[currentStation[0].jslodApi][ + "http://dbpedia.org/ontology/address" + ][0]["value"]; + setStationAddress(c); + }); + } + }, [currentStation]); + return ( + + {stationAddress} + + ); +}; diff --git a/components/駅名表/Sign.js b/components/駅名表/Sign.js index 507df2b..47af867 100644 --- a/components/駅名表/Sign.js +++ b/components/駅名表/Sign.js @@ -11,6 +11,7 @@ import { StationNameArea } from "./StationNameArea"; import { StationNumberMaker } from "./StationNumberMaker"; import { NextPreStationLine } from "./NextPreStationLine"; import { LottieDelayView } from "./LottieDelayView"; +import { AddressText } from "./AddressText"; export default function Sign(props) { const { @@ -162,6 +163,7 @@ export default function Sign(props) { + ); } @@ -176,10 +178,10 @@ const styleSheet = { }, 下帯: { position: "absolute", - bottom: "0%", + bottom: "8%", left: "0%", width: "100%", - height: "30%", + height: "27%", backgroundColor: "#0099CC", }, 下帯B: { @@ -200,8 +202,8 @@ const styleSheet = { }, 下帯内容: { position: "absolute", - bottom: "0%", - height: "30%", + bottom: "8%", + height: "27%", width: "100%", alignItems: "center", flexDirection: "column", diff --git a/lib/getStationList.js b/lib/getStationList.js index dcad90e..8603396 100644 --- a/lib/getStationList.js +++ b/lib/getStationList.js @@ -116,6 +116,7 @@ export const getStationList = async (props) => { if (element.properties.name == stationName) { data.lat = element.geometry.coordinates[1]; data.lng = element.geometry.coordinates[0]; + data.jslodApi = element.properties.uri; } }); return data; @@ -182,6 +183,7 @@ export const getStationList = async (props) => { JrHpUrl: "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/sakaide/", lat: 34.313222, lng: 133.856325, + jslodApi: "https://uedayou.net/jrslod/四国旅客鉄道/予讃線/坂出", }, { @@ -196,6 +198,7 @@ export const getStationList = async (props) => { JrHpUrl: "http://www.jr-odekake.net/eki/top.php?id=0651304", lat: 34.462562, lng: 133.807809, + jslodApi: "https://uedayou.net/jrslod/四国旅客鉄道/本四備讃線/児島", }, { Station_JP: "宇多津", @@ -209,6 +212,7 @@ export const getStationList = async (props) => { JrHpUrl: "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/utazu/", lat: 34.306379, lng: 133.813784, + jslodApi: "https://uedayou.net/jrslod/四国旅客鉄道/本四備讃線/宇多津", }, ]; status = stationList;