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

134
Views
LeafletJS Multiple live markers

Would anyone know a way to update multiple marker positions live using LeafletJS?

I came across this post: Updating Leaflet Marker Position Every x Seconds with JSON, which works perfect for a single marker, but when I try to add more than one marker, the map beings to lag bad and the markers don't clear they just replicate.

function update_position() {
    $.getJSON('https://opensky-network.org/api/states/all', function(data) {
        var planes = data.states
        for(let i = 0; i < planes.length; i++){
            plane = planes[i]
            lat = plane[6]
            lon = plane[5]
            csfilter = plane[1].substring(0,3);
            if(csfilter == "EIN"){
                if(!aircraft){
                    //var live_position = [[plane[1], plane[6], plane[5]]]
                    aircraft = L.marker([lat,lon]).bindPopup("I am "+plane[1]).addTo(mymap);
                }
            }
        }
        aircraft.setLatLng([lat,lon]).update();
        setTimeout(update_position, 10000);
    });
}
update_position();

Would anyone assist or point me in the right direction for where I am going wrong?

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!