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

83
Views
Viewing multiple markers on map

I'm trying to view multiple markers on the map, so I did this but unfortunately didn't work, any one would tell me where the error is? I'm using JavaScript.

        var studentAddresses = [
            [37.1, -78.024],
            [37.5, -78.044],
            [37.9, -78.064]
        ];



        add.locations.forEach((studentAddresses) => {
            // add marker to map
            var marker = new mapboxgl.Marker(el)
                .setLngLat([studentAddresses[0][0], studentAddresses[0][1]])
                .setPopup(popup)
                .addTo(map);
        
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are looping over whatever is in add.locations… If you want to loop over studentAddresses the forEach loop should look like this

studentAddresses.forEach((address) => {
            // add marker to map
            var marker = new mapboxgl.Marker(el)
               marker.setLngLat([address[0], address[1]])
                .setPopup(popup)
                .addTo(map);
    }
)
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!