Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda