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

107
Views
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
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!