2017-02-19 36 views
3

假設我有一個列表,或熊貓系列或緯度經度對。隨着大青葉,我可以用我可以在Folium地圖上添加一系列標記嗎?

coords = [46.8354, -121.7325] 
map_4 = folium.Map(location=[46.8527, -121.7649], tiles='Stamen Terrain', 
        zoom_start=13) 
folium.Marker(location=coords).add_to(map_4) 

繪製單對座標標記但是當我試圖通過名單列表,沒有繪製。我可以遍歷列表列表並繪製標記,但是我想知道是否可以傳遞一個參數並繪製多個標記。

回答

0

你可以這樣做:

map = folium.Map(location = [lat, lng], zoom_start = 4, tiles = "Mapbox bright") 
feature_group = folium.FeatureGroup("Locations") 

for lat, lng, name in zip(lat_lst, lng_lst, name_lst): 
    feature_group.add_child(folium.Marker(location=[lat,lon],popup=name)) 

map.add_child(feature_group) 

您還可以創建一個HTML文件,從中瞭解是否添加了標記或不

map.save(outfile = "test.html") 

現在打開的test.html文件在瀏覽器中,並檢查標記

相關問題