How do I force a leaflet map to reload all tiles including visible ones?

后端 未结 2 1896
孤街浪徒
孤街浪徒 2021-01-13 19:20

I\'m working on a graphing web-app and I\'ve decided that leaflet would make a decent graph view. I have it displaying (sort of) but I need a way to force it to update when

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-13 19:59

    You can simplify this a bit by using a function instead of the global for the cache buster.

    In your case, you can remove the val global var and change the document ready function call to look something like:

    $(document).ready(function(){
        map=L.map('plot',{crs:L.CRS.Simple}).setView([0,0],10);
        tiles = L.tileLayer('./GraphTile.png?x={x}&y={y}&z={z}&tilesize={tileSize}&{test}', 
        {
            maxZoom: 20,
            continuousWorld: true,
            tileSize: 128,
            test: Math.random()
        }).addTo(map);
    });
    

提交回复
热议问题