簡體   English   中英

網站的托管數據 map

[英]Hosting data for a folium map for a website

我在 python 上用大葉創建了一個交互式 map。 我打算將其部署在網站上。

在網站上,我計划有輸入字段以允許用戶過濾此數據以顯示在 map 上。

問:如何托管map的數據進行查詢?

我認為這個問題之所以受到很多反對,是因為您添加了 javascript、html 標簽,這些標簽在技術上與該主題相關,但實際上並沒有那么多:)

在 Folium 中,您可以使用 folium.Map.save('mymap.html') 將您的 folium map 保存為 mymap.html 文件。

這將生成一個非常大且不可讀的 html 文件,其中包含許多嵌入式 javascript 代碼。 Easiest way to include it to your main html file (let's say it's called index.html) is using iframe tag to import mymap.html to the main index.html

由於它會生成一個非常大的不可讀 html,因此幾乎不可能將其連接到主 index.html 中的輸入標簽。 在將其轉換為 mymap.html 之前,您需要在 python 腳本中包含輸入字段

我為這個問題找到了一篇完美的 Medium 文章: https://medium.com/generating-folium-maps-based-on-user-input-for-a/generating-folium-maps-based-on-user -input-for-a-dash-layout-16363da6ecd3

In short in the article, they used dash framework ( https://dash.plotly.com/ ) to make a dropdown user input fields, and then in the function that creates folium map, they put decorator called app.callback with a bunch dash.dependencies.Input 和 dash.dependencies.Output 作為@app.callback 的參數,將用戶輸入連接到 map。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM