python - How to use 'Polyline'
问题描述
Using jupyter Notebook/python3
I want to use polyline with marker but it doesn't work
map = folium.Map(location=[37.4601908, 126.4406957])
for index,lat in enumerate(place_lat):
folium.Marker([lat,
place_lng[index]],
popup=('patient3 \n 74contacts'),
icon = folium.Icon(color='green',icon='plus')).add_to(map)
folium.Polyline(color='red').add_to(map)
map
I thought Polyline is in folium
But error says
AttributeError: module 'folium' has no attribute 'Polyline'
How can I use polyline?
解决方案
从文档中,您应该使用PolyLine
.
例如:
import folium
m = folium.Map(location=[37.4601908, 126.4406957],
zoom_start=15)
place_lat = [37.4601928, 37.4593108, 37.4641108, 37.4611508]
place_lng = [126.4406957, 126.4432957, 126.4476917, 126.4423957]
points = []
for i in range(len(place_lat)):
points.append([place_lat[i], place_lng[i]])
for index,lat in enumerate(place_lat):
folium.Marker([lat,
place_lng[index]],
popup=('patient{} \n 74contacts'.format(index)),
icon = folium.Icon(color='green',icon='plus')).add_to(m)
folium.PolyLine(points, color='red').add_to(m)
m
推荐阅读
- swift - 如何保护文本文件中的音频样本 --> Swift
- python - Pandas - Fillna 或 where 基于条件的函数
- karate - 空手道 UI:是否可以将具有用纯英语编写的场景的单独文件映射到空手道功能文件
- javascript - 有没有办法在解构对象时访问对象本身?
- javascript - 更改格式为“key=value&...”的字符串中的所有值
- excel - Excel时间计算在0时抛出错误
- node.js - 我的道具被传递给我的组件,但我无法找出正确的路径
- html - 如何在图像上叠加文本和按钮
- javascript - 如何在 DevTools 控制台中以编程方式模拟输入
- azure - Azure 应用服务中的启动脚本,用于从 keyvault 复制文件