0

Below is the code of my website. It refreshes every second. Upon refreshing the new lat/lng it will load the new markers but it keeps the old markers. I have tried many forums etc with no luck. Any help is appreciated thanks.

function initialize() {

var mapOptions = {
    center: new google.maps.LatLng(-36.363, 175.044),
    zoom: 5,
    mapTypeId: google.maps.MapTypeId.ROADMAP
}; 

var infoWindow = new google.maps.InfoWindow();
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); 
window.setInterval(function() {
        readData();
    }, 1000);
}
   function readData() {

    $.getJSON('https://crossorigin.me/http://radar1.ddns.net:3080/data/aircraft.json', function (data) {
        $.each(data.aircraft, function (i, value) {



            var myLatlng = new google.maps.LatLng(value.lat, value.lon, value.flight, value.altitude);
        var marker = new google.maps.Marker({
                position: myLatlng,
                icon: 'airplane.jpg',
                map: map,
                title: "Callsign   Altitude  " + value.flight + value.altitude


            });

}

            var infowindow = new google.maps.InfoWindow({
                 content: '<b>Speed:</b> ' + value.speed+  '<b>   HEX:</b>' + value.hex+ '<b>   Altidtude:   </b>' +value.altitude + '<b>    Vertical Rate:  </b>' +value.vert_rate


});

 google.maps.event.addListener(marker, 'click', function() {
 infowindow.open(map, marker);
});






        });
    });

}

0 Answers0