問題描述
我正在開發(fā)一個(gè)圖形網(wǎng)絡(luò)應(yīng)用程序,我已經(jīng)決定傳單可以制作一個(gè)不錯(cuò)的圖形視圖.我讓它顯示(有點(diǎn)),但我需要一種方法來強(qiáng)制它在用戶輸入新公式進(jìn)行圖形時(shí)更新.
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,但這不重要.以下是相關(guān)代碼:
I'm using JQuery as well, but that shouldn't matter. Here is the relevant code:
這有效,但在用戶單擊時(shí)不會(huì)刷新,事件肯定正在運(yùn)行(我省略了其他更新文本顯示的代碼).它顯示正確,但是當(dāng)用戶添加一個(gè)功能來顯示視圖永遠(yuǎn)不會(huì)更新并且傳單繼續(xù)顯示緩存的圖像時(shí),只有新的縮放級(jí)別或平移到從未查看過的區(qū)域會(huì)導(dǎo)致它更新圖塊.我的問題是:如何強(qiáng)制傳單完全重新加載所有內(nèi)容并刪除并重新加載所有圖像?
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 添加了另一個(gè)失敗的嘗試
EDIT added another failed attempt
推薦答案
我找到了答案.盡管沒有緩存標(biāo)頭,但我的瀏覽器仍在緩存圖像.子域不是文檔聲稱的隨機(jī)選擇",它們是使用瓦片位置的哈希生成的.所以我不得不臨時(shí)想出一種方法來將&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.
新代碼如下所示:
希望這對(duì)其他人有所幫助.如果有更好的方法,請(qǐng)發(fā)表評(píng)論.
Hope this helps someone else. Please comment if there's a better way to do this.
這篇關(guān)于如何強(qiáng)制傳單地圖重新加載所有圖塊,包括可見圖塊?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!