Files
jrshikoku/components/TrainMenu/MapPin.tsx
harukin-expo-dev-env e8a2547ca4 tsx化
2025-12-05 10:43:57 +00:00

38 lines
1.1 KiB
TypeScript

import React, { FC } from "react";
import { Marker } from "react-native-maps";
import { useNavigation } from "@react-navigation/native";
import { useStationList } from "@/stateBox/useStationList";
import { StationProps } from "@/lib/CommonTypes";
type Props = {
index: number;
indexBase: number;
latlng: string[];
D: StationProps;
d: string;
navigate: (screen: string) => void;
webview: React.RefObject<any>;
};
export const MapPin: FC<Props> = (props) => {
const { index, indexBase, latlng, D, d, navigate, webview } = props;
const { goBack } = useNavigation();
const { getInjectJavascriptAddress } = useStationList();
return (
<Marker
key={index + indexBase}
coordinate={{
latitude: parseFloat(latlng[0]),
longitude: parseFloat(latlng[1]),
}}
onPress={() => {
const address = getInjectJavascriptAddress(D.StationNumber);
if (!address) return;
webview.current?.injectJavaScript(address);
if (navigate) goBack();
}}
image={require("../../assets/reccha-small.png")}
></Marker>
);
};