Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

118
Vistas
Markers in google maps don't draw

I'm coding using react + firestore 9 on an application that has to render a google map and then depending on the query it shows some markers.

I've been trying to get the aplication to draw some basic markers with some data I'm fetching from the database, the query is executed as quickly as it can, I've tried a lot of solutions but the map is not rendering the markers for me. The following is the code I'm using in the component:

      function fetchMarkers(){
            var markerData = [];
            getDocs(query(collection(db, "places")))
            .then((foo) => {        
                foo.forEach((doc) => {
                    markerData.push(doc.data())
                })
            })
            return markerData;
        }
    
        var arrayData = [];
    
        export default function Map() {
            fetchMarkers().then((value) => {
                arrayData = value;
                console.log(arrayData)
            })
   return (
            <div id="map">
               <LoadScript
                   googleMapsApiKey={apiKey}>
                   <GoogleMap
                      mapContainerStyle={containerStyle}
                      center={center}
                      zoom={13}
                      options={{ fullscreenControl: false, mapTypeControl: false, streetViewControl: false, styles: [{ elementType: "labels", featureType: "poi", stylers: [{ visibility: "off", }], }], }}>
                    {arrayData.map((marker) =>
                       <Marker
                          key={marker.id}
                          position={{
                             lat: marker.latitud,
                             lng: marker.longitud
                          }}
                       />)
                    }
                 </GoogleMap>
            </LoadScript>
        </div>
)

What is happening here is that the page is loading before the arrayData fills with the contents of the document related to it, and it's still not placing the markers after.

I'd appreciate a lot your suggestions, thanks in advance.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda