视图.py
map = folium.Map(location=[df['latitude'].mean(),
df['longitude'].mean()],tiles="cartodbpositron",zoom_start=12)
map.save("map.html")
context = {'my_map': map}
return render(request, 'my_map.html', context)
Run Code Online (Sandbox Code Playgroud)
my_map.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
{{ my_map }}
</body>
Run Code Online (Sandbox Code Playgroud)
浏览器结果:
folium.folium.Map object at 0x7f49d85662b0
Run Code Online (Sandbox Code Playgroud)
我不确定在用户通过之前的 html 表单提交输入后如何让 html/js 在浏览器上工作...我似乎到处都在寻找,并且有很多类似的解决方案问题,但我可以没有人去工作!
谢谢!