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

149
Views
how i can change code from var array to code from json?

hi i need help to write a format code. i write javascript code to parse json and use the data, the json file contain latitude and longtitude data :

const api_url = 'json.php'
        async function getjsonlatest() {
            const response = await fetch(api_url);
            const data = await response.json();
            
            const latitude = data.map(loc => loc.latitude)
            const longitude = data.map(loc => loc.longtitude)
            
            var latlngs = [
                            [-7.3248841543504, 112.63356271278819],        
                            [-7.354508491243568, 112.62849870236622]       
                                                                    ];
            var polyline = L.polyline(latlngs, {color: 'green'}).addTo(mymap);
            

my question is how i can change :

var latlngs = [
                        [-7.3248841543504, 112.63356271278819],        
                        [-7.354508491243568, 112.62849870236622]       
                                                                ];

with data from :

const latitude = data.map(loc => loc.latitude)
const longitude = data.map(loc => loc.longtitude)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

const latlngs = data.map(loc => ([loc.latitude, loc.longitude])

You can return array from your map function building array of corteges.

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!