hwo to get address from lat and long in react code example
Example: react get lat long of address
import React, { useState, useEffect } from 'react';
import Geocode from 'react-geocode';
export default function FindLatLong () {
Geocode.setApiKey('<YOUR API HERE>');
Geocode.enableDebug();
var address = 'Area 51, NV, USA';
const [lat, setLat] = useState(0)
const [long, setLong] = useState(0)
useEffect(() => {
Geocode.fromAddress(address).then(
response => {
setLat(response.results[0].geometry.location.lat);
setLong(response.results[0].geometry.location.lng);
}
)}, []
)
return(
<div>
<p>Address: {address}</p>
<p>Lat: {lat}</p>
<p>long: {long}</p>
</div>
)
}