• <bdo id='SrUGR'></bdo><ul id='SrUGR'></ul>
      <tfoot id='SrUGR'></tfoot><legend id='SrUGR'><style id='SrUGR'><dir id='SrUGR'><q id='SrUGR'></q></dir></style></legend>

        <small id='SrUGR'></small><noframes id='SrUGR'>

        <i id='SrUGR'><tr id='SrUGR'><dt id='SrUGR'><q id='SrUGR'><span id='SrUGR'><b id='SrUGR'><form id='SrUGR'><ins id='SrUGR'></ins><ul id='SrUGR'></ul><sub id='SrUGR'></sub></form><legend id='SrUGR'></legend><bdo id='SrUGR'><pre id='SrUGR'><center id='SrUGR'></center></pre></bdo></b><th id='SrUGR'></th></span></q></dt></tr></i><div id='SrUGR'><tfoot id='SrUGR'></tfoot><dl id='SrUGR'><fieldset id='SrUGR'></fieldset></dl></div>

        如何强制传单地图重新加载所有图块,包括可见

        时间:2023-08-08

          <small id='NhmGc'></small><noframes id='NhmGc'>

            <tfoot id='NhmGc'></tfoot>
            • <legend id='NhmGc'><style id='NhmGc'><dir id='NhmGc'><q id='NhmGc'></q></dir></style></legend>
                  <bdo id='NhmGc'></bdo><ul id='NhmGc'></ul>
                • <i id='NhmGc'><tr id='NhmGc'><dt id='NhmGc'><q id='NhmGc'><span id='NhmGc'><b id='NhmGc'><form id='NhmGc'><ins id='NhmGc'></ins><ul id='NhmGc'></ul><sub id='NhmGc'></sub></form><legend id='NhmGc'></legend><bdo id='NhmGc'><pre id='NhmGc'><center id='NhmGc'></center></pre></bdo></b><th id='NhmGc'></th></span></q></dt></tr></i><div id='NhmGc'><tfoot id='NhmGc'></tfoot><dl id='NhmGc'><fieldset id='NhmGc'></fieldset></dl></div>

                    <tbody id='NhmGc'></tbody>
                  本文介绍了如何强制传单地图重新加载所有图块,包括可见图块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在开发一个图形网络应用程序,我已经决定传单可以制作一个不错的图形视图.我让它显示(有点),但我需要一种方法来强制它在用户输入新公式进行图形时更新.

                  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 the user enters a new formula to graph.

                  我也在使用 JQuery,但这不重要.以下是相关代码:

                  I'm using JQuery as well, but that shouldn't matter. Here is the relevant code:

                  function formulaChange(formula){
                       //submits a request to the server to add a graph to display
                       map.setView(map.getCenter(),map.getZoom(),true);//doesn't work
                       //and neither does:
                       //map.fire('viewreset');
                       //tiles.redraw();
                  }
                  
                  function enterHandler(event){
                      if(event.keyCode==13){
                          formulaChange(document.getElementById("formula").value);
                      }
                  
                  }
                  
                  var map;
                  var tiles;
                  $(document).ready(function(){
                      map=L.map('plot',{crs:L.CRS.Simple}).setView([0,0],10);
                      //url is actually a servlet on the server that generates an image on the fly
                      tiles = L.tileLayer('./GraphTile.png?x={x}&y={y}&z={z}&tilesize={tileSize}&{s}', 
                      {
                          maxZoom: 20,
                          continuousWorld: true,
                          tileSize: 128,
                          //subdomains used as a random in the URL to prevent caching
                          subdomains: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
                      }
                      ).addTo(map);
                  });
                  

                  这有效,但在用户单击时不会刷新,事件肯定正在运行(我省略了其他更新文本显示的代码).它显示正确,但是当用户添加一个功能来显示视图永远不会更新并且传单继续显示缓存的图像时,只有新的缩放级别或平移到从未查看过的区域会导致它更新图块.我的问题是:如何强制传单完全重新加载所有内容并删除并重新加载所有图像?

                  This works but won't refresh when the user clicks, the event is definitely running (I've omitted other code that updates a text display). It displays properly, but when the user adds a function to display the view never updates and leaflet continues to display cached images, only a new zoom level or panning to an area never before viewed causes it to update the tiles. The question I have is: How do I force leaflet to completely reload everything and drop and reload all the images?

                  EDIT 添加了另一个失败的尝试

                  EDIT added another failed attempt

                  推荐答案

                  我找到了答案.尽管没有缓存标头,但我的浏览器仍在缓存图像.子域不是文档声称的随机选择",它们是使用瓦片位置的哈希生成的.所以我不得不临时想出一种方法来将&RANDOM##"添加到 URL 的末尾而不是子域.

                  I found the answer. Despite the no-cache headers my browser was caching the images anyway. The subdomains are not "randomly chosen" as the documentation claims, they are generated using a hash of the tile location. So I had to improvise a way to add "&RANDOM##" to the end of the URL instead of the subdomain.

                  新代码如下所示:

                  function enterHandler(event){
                      if(event.keyCode==13){
                          formulaChange(document.getElementById("formula").value);
                      }
                  }
                  function formulaChange(formula){
                      val.item=Math.random();
                      tiles.redraw();
                  }
                  var map;
                  var tiles;
                  var val={
                      item: Math.random(),
                      toString: function(){
                          return this.item;
                      }
                  };
                  $(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: val
                      }
                      ).addTo(map);
                  });
                  

                  希望这对其他人有所帮助.如果有更好的方法,请发表评论.

                  Hope this helps someone else. Please comment if there's a better way to do this.

                  这篇关于如何强制传单地图重新加载所有图块,包括可见图块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 R 中自定义传单弹出窗口 下一篇:Leaflet + Polymer 2 使用扭曲的瓷砖加载地图,但适用

                  相关文章

                  最新文章

                  <i id='jjTDC'><tr id='jjTDC'><dt id='jjTDC'><q id='jjTDC'><span id='jjTDC'><b id='jjTDC'><form id='jjTDC'><ins id='jjTDC'></ins><ul id='jjTDC'></ul><sub id='jjTDC'></sub></form><legend id='jjTDC'></legend><bdo id='jjTDC'><pre id='jjTDC'><center id='jjTDC'></center></pre></bdo></b><th id='jjTDC'></th></span></q></dt></tr></i><div id='jjTDC'><tfoot id='jjTDC'></tfoot><dl id='jjTDC'><fieldset id='jjTDC'></fieldset></dl></div>
                  • <bdo id='jjTDC'></bdo><ul id='jjTDC'></ul>

                  1. <small id='jjTDC'></small><noframes id='jjTDC'>

                    1. <legend id='jjTDC'><style id='jjTDC'><dir id='jjTDC'><q id='jjTDC'></q></dir></style></legend><tfoot id='jjTDC'></tfoot>