javascript - Continuously Loading Markers from database depending on last loaded timestamp -
i have marker locations saved in database lat, lng, type, , timestamp. current code loads markers (displaying different icons depending on type), when use setinterval function reload again. 1 solution suggested me add variable checks timestamp on first successful load , updates each time, when function triggered again load markers added after time. i'm not sure how go adding in current code. help/suggestions appreciated.
setinterval(function(){ //load markers 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);
an other approach one. call function allready have once, use setinterval on new same function , change .php file request data new 1 returns latest marker based on timestamp query like:
select max(timestamp) timestamp mytable
Comments
Post a Comment