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

129
Views
How to access data objects inside an array of array in javascript/react for Google Maps lat/lng?

How do I map over this data in javascript? I am trying to loop over this data for Markers in google maps. Having trouble grabbing the lat and lng.

Data from the console.log array --> array --> object --> lat/lng

LatLng: [
        [
            {
                "lat": 28.0440005,
                "lng": -82.3992308
            },
            {
                "lat": 28.050104,
                "lng": -82.39597859999999
            },
            {
                "lat": 29.6900252,
                "lng": -82.3733803
            },
            {
                "lat": 29.6900252,
                "lng": -82.3733803
            },
            {
                "lat": 29.6900252,
                "lng": -82.3733803
            },
            {
                "lat": 29.6900252,
                "lng": -82.3733803
            }
        ]
    ]

This is my javascript code for Google Maps. Tried grabbing the lat/lng this way for the marker to loop through the data. Not sure of other methods to include. LatLng is an object of the array, so I could not use a map method at the beginning.

    {Object.values(LatLng).map(({ lat, lng }, index) => (
            <Marker lat={lat} lng={lng} key={index}>
              {console.log(Object.values(LatLng))}
            </Marker>
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

The LatLng array you shared is a 2-d array of objects.

You need to do loop over the first element in that array. Tree-shake and extract the LatLng array first.

const {LatLng} = // Insert your object structure here

 {LatLng[0].map(({ lat, lng }, index) => (
            <Marker lat={lat} lng={lng} key={index}>
              {console.log(Object.values(LatLng))}
            </Marker>)))}
about 4 years ago · Juan Pablo Isaza Report

0

{  
  LatLang && latLang[0].map((item, index) => (
  <Marker lat={item[lat]} lng={item[lng]}                key={index}> 
   {console.log(item[lat] , item[lng])}
  </Marker>
)}
about 4 years ago · Juan Pablo Isaza Report

0

Try:

{Array.isArray(data[0]) && data[0].map((element, index) => (
    <Marker lat={element.lat} lng={element.lng} key={index}>
        {console.log(element.lat, element.lng)}
    </Marker>
))}
about 4 years ago · Juan Pablo Isaza Report
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!