【问题标题】:Expand folium map size on mobile devices在移动设备上扩大 folium 地图大小
【发布时间】:2022-09-24 03:43:19
【问题描述】:

我使用 Django Folium 制作了一个 Web 应用程序。我在网页上有一个导航栏和一个 Folium 地图。它适用于计算机和横向屏幕设备,但在纵向屏幕设备上,地图有一个可用空间。

我的地图代码:

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)

索引.html

<!DOCTYPE html>  # this line causes map cropping
<html lang=\"en\">
<head>
    <meta charset=\"utf-8\">
    <title></title>
</head>
<body>
    {{ current_map | safe }}
</body>
</html>

我发现,&lt;!DOCTYPE html&gt; 行会导致地图裁剪。

我该如何填写?

    标签: python django folium


    【解决方案1】:

    尝试这个:

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

    索引.html:

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

    【讨论】:

      猜你喜欢
      • 2016-02-15
      • 2016-02-21
      • 2014-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-10
      • 1970-01-01
      • 2013-07-27
      相关资源
      最近更新 更多