import React, { useState, useEffect } from "react"; import GlMap, { Source, Marker, Layer } from "react-map-gl/maplibre"; import { Flex, Layout, Col, Row, Modal, Form, Input, Button, Image, Card, } from "antd"; const { Header, Content } = Layout; const layout = { labelCol: { span: 8 }, wrapperCol: { span: 16 }, }; const geostyle = { id: "data", type: "line", paint: { "line-color": "red", "line-width": 3, }, }; const App = () => { const [state, setState] = useState({}); const [selected, setSelected] = useState(null); const [guess, setGuess] = useState(null); const [loading, setLoading] = useState(true); const [form] = Form.useForm(); useEffect(() => { fetch("/api/state") .then((x) => x.json()) .then(setState) .then(() => setLoading(false)); }, []); useEffect(() => { if (guess != null) { setState(guess.state); } }, [guess]); const onFinish = (values) => { fetch("/api/state", { method: "POST", body: JSON.stringify(values), headers: { "content-type": "application/json" }, }) .then((x) => x.json()) .then(setState); }; const onReset = () => { form.resetFields(); }; const onNext = () => { setSelected(null); setGuess(null); setLoading(true); fetch("/api/next", { method: "POST", headers: { "content-type": "application/json" }, }) .then((x) => x.json()) .then(setState) .then(() => setLoading(false)); }; const onMapClick = (e) => { if (state.current_guid) { setSelected(e.lngLat); } }; const onGuess = () => { setLoading(true); fetch("/api/guess", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(selected), }) .then((x) => x.json()) .then(setGuess) .then(() => setLoading(false)); }; return ( <> {selected ? ( ) : null} {guess ? ( ) : null} {state.username ? (

{state.username}

{state.points} очков

) : null} {!loading && !state.current_guid ? ( ) : null} {!loading && state.current_guid ? ( ) : null} {!loading && guess ? ( <>

{guess.name}

Расстояние: {guess.distance / 1000}км.

) : null} {state.current_guid && !selected ? (

Нажмите на карте на точку, где по вашему мнение находится то, что на фотографии

) : null} {state.current_guid && selected ? ( ) : null}

Сделал Александр Кирюхин в 2024 году

Для начала игры необходимо представиться

); }; export default App;