Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

249
Views
TypeError: no se pueden leer las propiedades de undefined (leyendo 'lat') usando React versión-18 @react-google-maps/api con Rapid Api

Soy nuevo en React Google Maps. Estoy usando esta biblioteca para crear un mapa con varias ubicaciones e intento ajustar los límites y centrarlo. Lo estoy usando para ubicar restaurantes, hoteles y todo en esa ubicación en particular.

Este es mi código en el que recibo un error y también obtengo TypeError: no se pueden leer las propiedades de undefined (leyendo 'lat') console.log (bounds.sw,bounds.ne) == undefined console.log (datos) == indefinido

Aplicación.js

 function App(){ const [places, setPlaces] = useState([]); const [coordinates, setCoordinates] = useState({}); const [bounds, setBounds] = useState({}); useEffect(() => { // this use effect for detecting current location navigator.geolocation.getCurrentPosition(({ coords:{latitude, longitude} }) => { setCoordinates({ lat: latitude, lng: longitude }); // console.log(latitude,longitude) }) },[]); useEffect(() => { getPlacesData(bounds.sw, bounds.ne) // console.log(bounds.sw, bounds.ne) .then((data)=>{ // console.log(data); setPlaces(data) }) },[coordinates, bounds]); return(<> <Map setCoordinates={setCoordinates} setBounds = {setBounds} coordinates = {coordinates} /> <> )}

Api.js

 import axios from 'axios'; const URL = 'https://travel-advisor.p.rapidapi.com/restaurants/list-in-boundary' export const getPlacesData = async(sw, ne) =>{ try { const {data:{data}} = await axios.get(URL, { params: { bl_latitude: sw.lat, tr_latitude: ne.lat, bl_longitude: sw.lng, tr_longitude: ne.lng, }, headers: { 'X-RapidAPI-Host': 'travel-advisor.p.rapidapi.com', 'X-RapidAPI-Key': 'Key' } }); return data;
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!