django 在移动的设备上扩展表单Map大小

idfiyjo8  于 2022-11-18  发布在  Go
关注(0)|答案(2)|浏览(105)

我用Django做了一个网页应用程序,我在网页上有一个导航栏和一个Map。它在电脑和横向屏幕设备上工作得很好,但是在纵向屏幕设备上Map有一个自由空间。
我的Map代码:

current_map = folium.Map(location=start_location, zoom_start=6)    
fig = branca.element.Figure(height="100%")
fig.add_child(current_map)
context = {"current_map": current_map._repr_html_()}
return render(request, template_name="index.html", context=context)

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
    {{ current_map | safe }}
</body>
</html>

我该怎么填?

dzjeubhm

dzjeubhm1#

好吧,我可能会使用Figure并修改folium包。

current_map = folium.Map(location=(48.51, 32.25), zoom_start=6)
map_container = branca.element.Figure(height="100%")
map_container.add_child(current_map)
...
context = {"current_map": map_container.render(), "form": form}
return render(request, template_name="hub/index.html", context=context)

我下载了folium-0.12.1.post1.tar.gz,并从folium/folium.py中删除了列表_default_js_default_css中有关旧版本Bootstrap的内容。
requirements.txt中,我使用这个本地修改的distr:

./distr/folium-0.12.1.post1.tar.gz
bnlyeluc

bnlyeluc2#

试试看:

context = {'map': map.get_root().render()}
return render(request, template_name="index.html", context=context)

index.html:

<html> 
    {{map|safe}}
</html>

相关问题