Folium にてマーカーのアイコンを変更する の続きです。
この記事では日本の国旗を東京の位置に表示する。
準備
(1) 横幅 40px くらいの国旗の画像を用意する
wikimedia: File:Flag of Japan.svg
(2) 東京の位置座標を取得する
( 35.6894, 139.6917 )
url_icon = 'https://raw.githubusercontent.com/ohwada/World_Countries/master/folium/tokyo_japan_flag/images/40px-Flag_of_Japan.png' width = 40 height = 26 icon = CustomIcon( icon_image = url_icon ,icon_size = (width, height) ,icon_anchor = ( (width/2) , 0) ,popup_anchor = (0, 0) ) # marker( Tokyo Japan) folium.Marker(location=[lat, lon], popup=name, icon=icon).add_to(map)
プログラムはGitHubに公開した。
https://github.com/ohwada/World_Countries/tree/main/folium/tokyo_japan_flag