gribnoysup / react-yandex-maps

Yandex Maps API bindings for React
MIT License
327 stars 114 forks source link

Get coordinates from RoutePanel #320

Open ukulya opened 2 years ago

ukulya commented 2 years ago

How can i get the coordinates from RoutePanel right now it's showing - undefined - it doesn't catch the changes in state

from: undefined
to: undefined
const [coords,setCoords] = React.useState({})
 React.useEffect(() => {
    console.log(coords);
  }, [coords]);
return(
<Map
          defaultState={{ center: mapGeopmetry, zoom: 13 }}
          width="100%"
          height="100%"
          modules={["geolocation", "geocode"]}
        >
          <RoutePanel
            instanceRef={(ref) => {
              if (ref) {
                setCoords(ref.routePanel.state);
              }
            }}
            options={{
              float: "none",
              maxWidth: "630px",
              showHeader: "true",
              position: {
                top: "780px",
                left: "0",
                right: "0",
              },
            }}
          />
        </Map>
)