I am loading a tile layer as overlay into my leaflet map and my goal is to refresh the layer every n-minutes.
I use the redraw();
method but I figured out, that the data always came from the cache and not from the server.
after I zoom in or out of the map the tiles will be sometimes requested from the server.
the code for the layer and the refresh looks like this:
var TomTom_Incident = L.tileLayer('https://api.tomtom.com/traffic/map/4/tile/incidents/s3/{z}/{x}/{y}.png?key=<APIKEY>', {
maxZoom: 18,
attribution: '© <a href="https://www.tomtom.com/" target="_blank">TomTom</a>',
opacity: 0.85
});
var TomTom_Incident_intervall = "";
function refresh_TomTom_Incident() {
TomTom_Incident.redraw();
console.log(consoleLogTime.getHours()+':'+consoleLogTime.getMinutes()+':'+consoleLogTime.getSeconds()+'TomTom_Incident Intervall active');
}
TomTom_Incident.on('add', function(e) {
TomTom_Incident_intervall = setInterval(refresh_TomTom_Incident, 300000);
console.log('TomTom_Incident added');
});
if (map.hasLayer(TomTom_Incident)) {
console.log('TomTom_Incident present');
TomTom_Incident_intervall = setInterval(refresh_TomTom_Incident, 300000);
} else {
console.log('TomTom_Incident not present');
}
TomTom_Incident.on('remove', function(e) {
clearInterval(TomTom_Incident_intervall);
console.log('Intervall active');
});
is there a way to always request the tiles after redraw();
or to disable the cache for this tile layer?
link to the docs: https://developer.tomtom.com/online-traffic/online-traffic-documentation-online-traffic-incidents/traffic-incident-tiles
thanks in advance!