Django 新手在这里:我的目标是将 Folium 集成到 html 页面。所以我目前所拥有的:
民意调查/views.py
def show_map(request):
#creation of map comes here + business logic
m = folium.Map([51.5, -0.25], zoom_start=10)
test = folium.Html('<b>Hello world</b>', script=True)
popup = folium.Popup(test, max_width=2650)
folium.RegularPolygonMarker(location=[51.5, -0.25], popup=popup).add_to(m)
context = {'my_map': m}
return render(request, 'polls/show_folium_map.html', context)
Run Code Online (Sandbox Code Playgroud)
民意调查/网址.py
urlpatterns = [
path('show_my_map', views.show_map, name='show_map'),
Run Code Online (Sandbox Code Playgroud)
]
和show_folium_map.html
<h1>map result comes here</h1>
{{ my_map }}
Run Code Online (Sandbox Code Playgroud)
问题是我得到了地图的“to_string”值(我向你保证我看到了)。那么我怎样才能以这样的方式集成地图,我可以实际看到地图并定义大小?