駅名標に住所の表示を開始

This commit is contained in:
harukin-expo-dev-env 2024-09-01 04:46:26 +00:00
parent 45021b2427
commit c9b59c3b62
3 changed files with 48 additions and 4 deletions

View File

@ -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> = (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 (
<Text
style={{
fontSize: parseInt("10%"),
color: isMatsuyama ? "white" : "#005170",
position: "absolute",
bottom: isMatsuyama ? "25.5%" : "0%",
textAlign: "center",
width: "100%",
fontWeight: "bold",
}}
>
{stationAddress}
</Text>
);
};

View File

@ -11,6 +11,7 @@ import { StationNameArea } from "./StationNameArea";
import { StationNumberMaker } from "./StationNumberMaker"; import { StationNumberMaker } from "./StationNumberMaker";
import { NextPreStationLine } from "./NextPreStationLine"; import { NextPreStationLine } from "./NextPreStationLine";
import { LottieDelayView } from "./LottieDelayView"; import { LottieDelayView } from "./LottieDelayView";
import { AddressText } from "./AddressText";
export default function Sign(props) { export default function Sign(props) {
const { const {
@ -162,6 +163,7 @@ export default function Sign(props) {
<View style={styleSheet[isMatsuyama ? "下帯内容B" : "下帯内容"]}> <View style={styleSheet[isMatsuyama ? "下帯内容B" : "下帯内容"]}>
<NextPreStationLine {...{ nexStation, preStation, isMatsuyama }} /> <NextPreStationLine {...{ nexStation, preStation, isMatsuyama }} />
</View> </View>
<AddressText {...{ currentStation, isMatsuyama }} />
</TouchableOpacity> </TouchableOpacity>
); );
} }
@ -176,10 +178,10 @@ const styleSheet = {
}, },
下帯: { 下帯: {
position: "absolute", position: "absolute",
bottom: "0%", bottom: "8%",
left: "0%", left: "0%",
width: "100%", width: "100%",
height: "30%", height: "27%",
backgroundColor: "#0099CC", backgroundColor: "#0099CC",
}, },
下帯B: { 下帯B: {
@ -200,8 +202,8 @@ const styleSheet = {
}, },
下帯内容: { 下帯内容: {
position: "absolute", position: "absolute",
bottom: "0%", bottom: "8%",
height: "30%", height: "27%",
width: "100%", width: "100%",
alignItems: "center", alignItems: "center",
flexDirection: "column", flexDirection: "column",

View File

@ -116,6 +116,7 @@ export const getStationList = async (props) => {
if (element.properties.name == stationName) { if (element.properties.name == stationName) {
data.lat = element.geometry.coordinates[1]; data.lat = element.geometry.coordinates[1];
data.lng = element.geometry.coordinates[0]; data.lng = element.geometry.coordinates[0];
data.jslodApi = element.properties.uri;
} }
}); });
return data; return data;
@ -182,6 +183,7 @@ export const getStationList = async (props) => {
JrHpUrl: "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/sakaide/", JrHpUrl: "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/sakaide/",
lat: 34.313222, lat: 34.313222,
lng: 133.856325, 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", JrHpUrl: "http://www.jr-odekake.net/eki/top.php?id=0651304",
lat: 34.462562, lat: 34.462562,
lng: 133.807809, lng: 133.807809,
jslodApi: "https://uedayou.net/jrslod/四国旅客鉄道/本四備讃線/児島",
}, },
{ {
Station_JP: "宇多津", Station_JP: "宇多津",
@ -209,6 +212,7 @@ export const getStationList = async (props) => {
JrHpUrl: "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/utazu/", JrHpUrl: "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/utazu/",
lat: 34.306379, lat: 34.306379,
lng: 133.813784, lng: 133.813784,
jslodApi: "https://uedayou.net/jrslod/四国旅客鉄道/本四備讃線/宇多津",
}, },
]; ];
status = stationList; status = stationList;