I currently have a database where I store marker locations along with their latitude, longitude, type, and timestamp. Right now, my code loads all markers from the database and displays them on the map with different icons based on their type. However, when I use the setInterval function, all markers reload again. I was advised to add a variable that checks the timestamp of the initial successful load and then updates it each time. This way, when the function is triggered again, only markers added after that time will be loaded. I'm not sure how to implement this in my existing code though. Any suggestions or help would be greatly appreciated. Thank you.
setInterval(function(){
//Load Markers from the XML File
$.get("json-data-locations_2.php", function(data) {
$(data).find("marker").each(function() {
var type = $(this).attr('type');
var point = new google.maps.LatLng(parseFloat($(this).attr('lat')), parseFloat($(this).attr('lng')));
var icons;
if (type === 'Drink') {
icons = 'NewMarkers/Blue.png';
}
else if (type === 'Food') {
icons = 'NewMarkers/Orange.png';
}
else {
icons = 'NewMarkers/Purple.png';
}
create_marker(point, type, "", false, false, false, icons);
});
});
}, 8000);