python-visualization / python-visualization/folium

Legend location in a DualMap

オープン
#1,167 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug plugin
主要言語
Python
スター
7.4k
フォーク
2.3k
平均マージ
17時間 22分
マージ済み PR(30日)
11

説明

Please add a code sample or a nbviewer link, copy-pastable if possible
# Your code here
# Add Dual-basemap
m = folium.plugins.DualMap(location=target_city, zoom_start = 9, tiles= 'openstreetmap')

# layer definition
layer_1= folium.features.Choropleth(
    geo_data= gjson
    ,name= 'column_1'
    ,key_on='feature.properties.postcode'
    ,data= zipcodes_geom
    ,columns= ['postcode', 'column_1']
    ,fill_color='YlGnBu'
    ,highlight=True
    ,legend_name='column_1'
    )
# popup window
tooltip_1= folium.features.GeoJsonTooltip(['postcode', 'column_1'])
layer_1.geojson.add_child(tooltip_1) # add it to the layer

#===========================================================================
layer_2= folium.features.Choropleth(
    geo_data= gjson
    ,name= 'column_2'
    ,key_on='feature.properties.postcode'
    ,data= zipcodes_geom
    ,columns= ['postcode', 'column_2']
    ,fill_color='BuPu'
    ,highlight=True
    ,legend_name='column_2'
    )
# popup window
tooltip_2 = folium.features.GeoJsonTooltip(['postcode', 'column_2'])
layer_2.geojson.add_child(tooltip_2) # add to the layer
#=============================================================
# dual map
# fg_both = folium.FeatureGroup(name='postcode_both').add_to(m)
fg_1= folium.FeatureGroup(name='column_1').add_to(m.m1)
fg_2= folium.FeatureGroup(name='column_2').add_to(m.m2)

layer_1.geojson.add_to(fg_1)
layer_2.geojson.add_to(fg_2)

# adding figure 1 and 2 to the basemap
fg_1.add_to(m.m1)
fg_2.add_to(m.m2)
#===========================
# add Layer control to Dual basemapa
# add legend for layer 1
folium.LayerControl(collapsed=True).add_to(m)
colormap_1= cm.linear.YlGnBu_06.scale(0,180)
colormap_1= colormap_1.to_step(index=[0,30,60,90,120,150,180])
colormap_1.caption= 'column_1'
colormap_1.add_to(m.m1)
# add legend for layer 2
colormap_2= cm.linear.PuBu_06.scale(0,180)
colormap_2= colormap_2.to_step(index=[0,14,29,43,58,72,87])
colormap_2.caption= 'column_2'
colormap_2.add_to(m.m2)
#===========================
# display map
display(m)
Problem description

Creating a Dual Map with two different geojson:
At the moment of adding the legends to the basemap (m), if I add one legend and define where to locate it could be grid 1(m.m1) or grid 2(m.m2) "It Works fine", but if I add the second legend, they get stack one on top of other, no mater that I assigned them to a different grid.
Also, It's there a way to move the legend to a different position in the basemap?

Expected Output

Would be that each grid of the Dual Map (basemap) contain one geojson and one legend.

Output of folium.__version__

0.8.3
dual_map

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、提供された DualMap の例を folium 0.8.3 で実行し、DualMap、LayerControl、colormap の add_to エントリーポイントを追跡します。各マップペインに割り当てられた凡例だけが表示され、凡例の位置を変更できれば完了です。レポートではリポジトリのファイルやテストを指定しません。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
data-visualization
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。