Folium を使って国連加盟国の国旗を地図に表示する

Folium を使って国旗をマーカーとして地図に表示する の続きです。

前回の記事では東京の位置に日本の国旗を東京の位置に表示した。

この記事では 国連加盟国 の国旗を首都の位置に表示する

JSON ファイル(国連加盟国の一覧) を読み込んで for ループで処理する。

for item in list_countries:
    country = item['country']
    url_country = item['url_country']
    url_flag_icon = item['url_flag_icon']
    icon_width = item['icon_width']
    icon_height = item['icon_height']
    lat = item['lat']
    lon = item['lon']
    icon = CustomIcon(
        icon_image =  url_flag_icon,
        icon_size = (icon_width, icon_height),
        icon_anchor = ( (icon_width/2) , 0),
        popup_anchor = (0, 0)
    )
    folium.Marker(location=[lat, lon], icon=icon, popup= 

Leaflet では  LatLngBounds を使って 画面に複数のマーカーが収まるようにできる。

Folium ではこの機能がないようです。

そこで 地図の中央をインド洋の赤道上に設定した。

lat_center = 0
lon_center = 77.209006
ZOOM = 2
map = folium.Map(location=[lat_center, lon_center], zoom_start=ZOOM)

プログラムはGitHubに公開した。

https://github.com/ohwada/World_Countries/tree/main/folium/un_member_states_flag