question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

With redraw (), the tiles are not requested again

See original GitHub issue

How to reproduce

  • Leaflet version I’m using: 1.3.4
  • Browser (with version) I’m using: chrome 40
  • OS/Platform (with version) I’m using: window 10
  • step 1 add tileLayer var test=L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', { maxZoom: 18, attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' + '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + 'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>', id: 'mapbox.streets' }).addTo(mymap);
  • step 2 use redraw() setTimeout(function(){ test.redraw(); },5000);

What behaviour I’m expecting and which behaviour I’m seeing

the tile are requested once image if i use redraw(), the tiles should be requested twice

Minimal example reproducing the issue

` var mymap = L.map(‘mapid’).setView([51.505, -0.09], 13);

var test=L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
    maxZoom: 18,
    attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
    '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
    'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
    id: 'mapbox.streets'
}).addTo(mymap);


setTimeout(function(){
    test.redraw();
},5000);`
  • this example is as simple as possible
  • this example does not rely on any third party code

Using http://leafletjs.com/edit.html or any other jsfiddle-like site.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
songyumengcommented, Mar 13, 2019
L.TileLayer.Test = L.TileLayer.extend({
    getTileUrl: function(coords) {
        return L.TileLayer.prototype.getTileUrl.call(this,coords)+"?_t="+new Date().getTime();
    }
});

var l = new L.TileLayer.Test('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');

Try it , with a timestamp. But this may not be the best solution.

0reactions
Falke-Designcommented, Feb 21, 2022

The tiles are kept in the browser cache and not re-requested.

There is currently no way to force a request in browsers without modifing the url (like append a version ?v=123) which destroys chaching because of this I will close this issue and label it with wontfix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Any way to refresh tiles? - Leaflet.GridLayer.GoogleMutant
Sometimes after map container resizes the tiles did not update, and the map is gray. Ia there a way to force reload/update the...
Read more >
imageryProvider/ ImageryLayer redraw tiles - CesiumJS
I basically need a “refresh” method that requests the same tiles that are currently displayed and swaps them. I could reload the layer, ......
Read more >
redraw - How to keep old tiles until each new tile is loaded ...
I'm using a combined tilelayer, which I have to refresh (using .redraw() currently) each time a new layer has been added or an...
Read more >
Redraw/Refresh WMS layer in Leaflet - GIS Stack Exchange
Merges an object with the new parameters and re-requests tiles on the current screen (unless noRedraw was set to true).
Read more >
Dynamic Layer does not redraw in IE/Firefox - rendering issues ...
I got some suggestions that this might be caused by the browsers' cache. Maybe some bug in the MapSuite code that sends the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found