import webbrowser as wb
import folium
if __name__ == '__main__':
loc = [30.679943, 104.067923] # 成都中心位置經緯度
map = folium.Map(location=loc,
zoom_start=11,
zoom_control=True,
tiles='OpenStreetMap') # 默認OpenStreetMap
s1 = '地理位置標記點上的彈出窗口,展示標記點數據內容'
s2 = 'zhang phil'
s3 = 'https://zhangphil.blog.csdn.net/'
WIDTH = max(len(s1.encode('utf-8')), len(s2.encode('utf-8')), len(s3.encode('utf-8')))
pop = folium.Popup(html=folium.Html("""
{}/br>
{}/br>
{}/br>
""".format(s1, s2, s3),
script=True,
width=WIDTH * 4),
parse_html=True,
max_width=3000,
)
# 添加一個標記,然后設置彈窗。
folium.Marker(
location=loc,
popup=pop,
tooltip="標記點"
).add_to(map)
map.save('map.html')
wb.open('map.html')
# https://nbviewer.jupyter.org/github/python-visualization/folium/blob/master/examples/Popups.ipynb
到此這篇關于Python地理地圖可視化folium標記點彈窗設置代碼(推薦)的文章就介紹到這了,更多相關Python地圖可視化folium內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持腳本之家!