给定一批经纬度,在地图上画出路线,并且动态显示行进的路线,形式如流动的洋流、蚁群、蠕虫等
python代码:
import webbrowser as wb
import folium
from folium import plugins
if __name__ == '__main__':
city_name_list = ['北京', '上海', '广州', '深圳', '成都']
latlngs = [[39.929986, 116.395645], # 北京中心点经纬度
[31.249162, 121.487899], # 上海中心点经纬度
[23.120049, 113.30765], # 广州中心点经纬度
[22.546054, 114.025974], # 深圳中心点经纬度
[30.679943, 104.067923]] # 成都中心点经纬度
loc = [30., 104.]
map = folium.Map(loc, # 地图中心
tiles='OpenStreetMap', # stamentoner,Stamen Watercolor,OpenStreetMap'
zoom_start=5)
html = """
<h1> 这是大标题</h1><br>
<p>ZHANG PHIL</p>
"""
folium.Marker(latlngs[1], popup=html).add_to(map)
danger_line = folium.PolyLine(
locations=[latlngs[0], latlngs[4]], weight=10, color="orange", opacity=0.8
).add_to(map)
plugins.AntPath(
locations=latlngs, reverse="True", dash_array=[20, 30]
).add_to(map)
map.fit_bounds(map.get_bounds())
map.save('m.html')
wb.open('m.html')
输出结果: